Skip to content

added changelog entry #413

added changelog entry

added changelog entry #413

Workflow file for this run

name: Unittest xcube-geodb
on:
workflow_dispatch:
push:
release:
types: [published]
env:
APP_NAME: xcube-geodb
ORG_NAME: bcdev
# Skip PSQL tests in unittests. Can make sense if you have e.g. installation issues with postgis
SKIP_PSQL_TESTS: "0"
# When developing jobs it could make sense to switch off the test sections as they take time
# Unfortunately, you cannot set an if statement on job level. Hence, these variables are used in each step
# of a unittest/nb-test job.
RUN_UNITTESTS: "1"
RUN_NB_TESTS: "1"
# Determines whether the dev branch ouy are working on shall have a docker image (default 0)
DOCKER_BUILD_MY_BRANCH: "0"
jobs:
unittest:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
# Print info
- run: |
echo "Skipping SQL tests: ${{ env.SKIP_PSQL_TESTS }}"
echo "RUN_UNITTESTS: ${{ env.RUN_UNITTESTS }}"
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
if: ${{ env.RUN_UNITTESTS == '1' }}
with:
channels: conda-forge
auto-update-conda: true
activate-environment: xcube-geodb
environment-file: etc/environment-workflow.linux-64.lock
- run: |
conda info
conda list
conda config --show-sources
conda config --show
printenv | sort
- name: setup xcube-geodb
if: ${{ env.RUN_UNITTESTS == '1' }}
run: |
pip install gsconfig-py3 testing.postgresql requests_mock
python setup.py develop
- name: unittest-xcube-geodb
if: ${{ env.RUN_UNITTESTS == '1' }}
run: |
export SKIP_PSQL_TESTS=${{ env.SKIP_PSQL_TESTS }}
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml
- uses: codecov/codecov-action@v2
if: ${{ env.RUN_UNITTESTS == '1' }}
with:
fail_ci_if_error: true
verbose: true
# Testing notebooks that come with the xcube-geodb repo
nb-test:
runs-on: ubuntu-latest
env:
GEODB_API_SERVER_URL: ${{ secrets.GEODB_API_SERVER_URL }}
GEODB_AUTH_CLIENT_ID: ${{ secrets.GEODB_AUTH_CLIENT_ID }}
GEODB_AUTH_CLIENT_SECRET: ${{ secrets.GEODB_AUTH_CLIENT_SECRET }}
GEODB_AUTH_DOMAIN: ${{ secrets.GEODB_AUTH_DOMAIN }}
GEOSERVER_SERVER_URL: ${{ secrets.GEOSERVER_SERVER_URL }}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
if: ${{ env.RUN_NB_TESTS == '1' }}
with:
channels: conda-forge
activate-environment: xcube-geodb
environment-file: etc/environment-workflow.linux-64.lock
- name: setup xcube-geodb
if: ${{ env.RUN_NB_TESTS == '1' }}
shell: bash -l {0}
run: |
conda info
conda list
python setup.py develop
- name: install papermill
if: ${{ env.RUN_NB_TESTS == '1' }}
shell: bash -l {0}
run: pip install papermill[all]
- name: test-notebooks
if: ${{ env.RUN_NB_TESTS == '1' }}
shell: bash -l {0}
working-directory: notebooks
run: |
for nb in $(ls *.ipynb | grep -v publish_collection)
do
papermill $nb $(basename -s .ipynb $nb)_out.ipynb
done
build-docker-image:
runs-on: ubuntu-latest
needs: [nb-test, unittest]
name: build-docker-image
steps:
- name: git-checkout
uses: actions/checkout@v2
# Get the base release tag used in docker images
- name: get-release-tag
id: release
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# The docker backend image always needs the version as in version.py
- name: get-xcube-geodb-version
id: real-version
run: |
VERSION=$(echo "`cat xcube_geodb/version.py | cut -d "'" -f2`")
echo ::set-output name=version::${VERSION}
# Determine the deployment phase (dev/stage/prod) will be 'ignore' if a dev branch is processed
- name: deployment-phase
id: deployment-phase
uses: bc-org/gha-determine-phase@v0.1
with:
event_name: ${{ github.event_name }}
tag: ${{ steps.release.outputs.tag }}
- name: info
id: info
run: |
echo "TAG: ${{ steps.release.outputs.tag }}"
echo "DEPLOYMENT_PHASE: ${{ steps.deployment-phase.outputs.phase }}"
echo "REAL_VERSION: ${{ steps.real-version.outputs.version }}"
echo "EVENT: ${{ github.event_name }}"
# Build jupyter lab docker image
- uses: mr-smithers-excellent/docker-build-push@v5.5
name: build-push-docker-image-latest
# Build the image only for dev/stage/prod phases or if DOCKER_BUILD_MY_BRANCH is set to '1'
if: ${{ steps.deployment-phase.outputs.phase != 'ignore' || env.DOCKER_BUILD_MY_BRANCH == '1' }}
with:
image: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}-lab
# Adds 'latest' tag when main is built (see: https://github.com/mr-smithers-excellent/docker-build-push#tagging-the-image-using-gitops)
addLatest: true
dockerfile: docker/jupyterlab/Dockerfile
registry: quay.io
username: ${{ secrets.QUAY_REG_USERNAME }}
password: ${{ secrets.QUAY_REG_PASSWORD }}
# Build PostGIS docker image
- uses: mr-smithers-excellent/docker-build-push@v5.5
name: build-push-docker-backend-image-latest
if: ${{ steps.deployment-phase.outputs.phase != 'ignore' || env.DOCKER_BUILD_MY_BRANCH == '1' }}
with:
image: ${{ env.ORG_NAME }}/${{ env.APP_NAME }}-backend
directory: xcube_geodb/sql
dockerfile: docker/postgis/Dockerfile
# Adds 'latest' tag when main is built (see: https://github.com/mr-smithers-excellent/docker-build-push#tagging-the-image-using-gitops)
addLatest: true
registry: quay.io
buildArgs: GEODB_VERSION=${{ steps.real-version.outputs.tag }}
username: ${{ secrets.QUAY_REG_USERNAME }}
password: ${{ secrets.QUAY_REG_PASSWORD }}
update-version-deployment:
env:
PUSH: 1
runs-on: ubuntu-latest
needs: build-docker-image
name: update-tag
steps:
- name: Get installation token
id: get_installation_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.TOKEN_PROVIDER_APP_ID }}
private_key: ${{ secrets.TOKEN_PROVIDER_KEY }}
repository: bc-org/k8s-configs
# the installationId of the GitHub app we are using
installationId: 36950178
- name: git-checkout
uses: actions/checkout@v2
# Clone k8s-config into path 'k8s'
- name: checkout-k8s
run: |
mkdir k8s
cd k8s
git clone https://x-access-token:${{ steps.get_installation_token.outputs.token }}@github.com/bc-org/k8s-configs.git
# Get the release tag (or main on push)
- name: get-release-tag
id: release
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
# Determine the deployment phase
- name: deployment-phase
id: deployment-phase
uses: bc-org/gha-determine-phase@v0.1
with:
event_name: ${{ github.event_name }}
tag: ${{ steps.release.outputs.tag }}
- name: get-hash
id: get-hash
run: |
HASH=$(skopeo inspect docker://quay.io/bcdev/${{ env.APP_NAME }}-lab:${{ steps.release.outputs.tag }} | jq '.Digest')
if [[ "$HASH" == *"sha256"* ]]; then
echo ::set-output name=hash::$HASH
else
echo "No hash present. Using none as hash. This will use the version tag instead for deployment."
echo ::set-output name=hash::none
fi
- name: info
run: |
echo "Event: ${{ github.event_name }}"
echo "Deployment Stage: ${{ steps.deployment-phase.outputs.phase }}"
echo "Release Tag: ${{ steps.release.outputs.tag }}"
echo "Deployment Release Tag: ${{ steps.deployment-phase.outputs.tag }}"
echo "Deployment Digest: ${{ steps.get-hash.outputs.hash }}"
- name: set-version-tag
uses: bc-org/update-application-version-tags@main
with:
app: ${{ env.APP_NAME }}
phase: ${{ steps.deployment-phase.outputs.phase }}
delimiter: ' '
tag: ${{ steps.deployment-phase.outputs.tag }}
hash: ${{ steps.get-hash.outputs.hash }}
working-directory: "./k8s/k8s-configs/${{ env.APP_NAME }}-jh/helm"
- name: cat-result
working-directory: "./k8s/k8s-configs/${{ env.APP_NAME }}-jh/helm"
run: |
head values-dev.yaml
head values-stage.yaml
# No production deployment at the moment
# head values-prod.yaml
- name: Pushes to another repository
# Don't run if run locally and should be ignored
if: ${{ steps.deployment-phase.outputs.phase != 'ignore' && !env.ACT }}
run: |
cd ./k8s/k8s-configs
git config user.name github-actions
git config user.email github-actions@github.com
git commit -am "${{ github.event.release }}. Set version to ${{ steps.release.outputs.tag }}" || true
git remote set-url origin https://x-access-token:${{ steps.get_installation_token.outputs.token }}@github.com/bc-org/k8s-configs.git
git push origin main