diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index 6f94df8e9..e29cdd2f4 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -1,3 +1,5 @@ +name: Build Docker-Image + on: push: branches: @@ -10,7 +12,7 @@ jobs: runs-on: ubuntu-latest name: Build Docker Image steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Build image id: build-image uses: OGGM/docker-build-and-push-action@v1 diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 000000000..48d982b6c --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,48 @@ +name: Run Tests + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + test: + name: Test + strategy: + fail-fast: false + matrix: + test-env: + - prepro + - numerics + - models + - benchmark + - utils + - vascaling + - workflow-single + - workflow-multi + - graphics-mpl + container: + - oggm/untested_base:20200323 + - oggm/untested_base:py36 + include: + - container: python:3.7-slim + test-env: minimal + runs-on: ubuntu-latest + container: ${{ matrix.container }} + continue-on-error: ${{ contains(matrix.container, 'py3') }} + steps: + - name: Install tools + if: ${{ contains(matrix.container, 'slim') }} + run: apt-get -y update && apt-get -y install git curl + - name: Checkout + uses: actions/checkout@v2 + - name: Test + run: ./ci/run_tests.sh ${{ matrix.test-env }} + - name: Upload Coverage + if: ${{ !contains(matrix.container, 'py3') }} + run: | + curl -o codecov.sh --max-time 10 --retry 5 --retry-delay 15 --retry-max-time 120 https://codecov.io/bash + bash codecov.sh -n "${{ matrix.test-env }} on ${{ matrix.container }}" diff --git a/ci/run_tests.sh b/ci/run_tests.sh new file mode 100755 index 000000000..0a6a73c57 --- /dev/null +++ b/ci/run_tests.sh @@ -0,0 +1,41 @@ +#!/bin/bash +set -e +set -x + +chown -R "$(id -u):$(id -g)" "$HOME" + +export OGGM_TEST_ENV="$1" +export OGGM_TEST_MODE=unset +export MPLBACKEND=agg + +if [[ $OGGM_TEST_ENV == *-* ]]; then + export OGGM_TEST_MODE="${OGGM_TEST_ENV/*-/}" + export OGGM_TEST_ENV="${OGGM_TEST_ENV/-*/}" +fi + +[[ $OGGM_TEST_MODE == single ]] && export OGGM_TEST_MULTIPROC=False +[[ $OGGM_TEST_MODE == multi ]] && export OGGM_TEST_MULTIPROC=True +[[ $OGGM_TEST_MODE == mpl ]] && export OGGM_MPL=--mpl + +if [[ $OGGM_TEST_ENV == minimal ]]; then + # Special Mode for minimal tests on minimal Python-Image + + export PIP=pip3 + $PIP install --upgrade pytest git+https://github.com/OGGM/pytest-mpl.git +fi + +[[ -d .git ]] || export SETUPTOOLS_SCM_PRETEND_VERSION="g$GITHUB_SHA" + +$PIP install --upgrade coverage git+https://github.com/fmaussion/salem.git +$PIP install -e . + +export COVERAGE_RCFILE="$PWD/.coveragerc" + +coverage erase + +coverage run --source=./oggm --parallel-mode --module \ + pytest --verbose --mpl-upload $OGGM_MPL --run-slow --run-test-env $OGGM_TEST_ENV oggm + +coverage combine +coverage xml +coverage report --skip-covered