From 11a9eb8fb67dd557fe74d22cbf6ba76e5e10f84f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 16:57:09 +0100 Subject: [PATCH 01/60] Add GitHub Actions and Dockerfile for test environment --- .github/workflows/main.yml | 47 ++++++++++++++++++++++++++++++++++++++ Dockerfile | 7 ++++++ 2 files changed, 54 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 Dockerfile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 000000000..b3e14f236 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,47 @@ +name: ci + +on: push + +env: + DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: $DOCKER_IMAGE + + unit-test: + needs: docker-build + runs-on: ubuntu-latest + container: $DOCKER_IMAGE + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Unit Tests + run: | + make unit_test + + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..2ba6a8a01 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM mambaorg/micromamba:latest + +COPY --chown=$MAMBA_USER:$MAMBA_USER requirements /tmp/requirements/ + +RUN micromamba install -y -n base -f /tmp/requirements/env_climada.yml && \ + micromamba update -y -n base -f /tmp/requirements/env_developer.yml && \ + micromamba clean --all --yes From dc37cec82c4d2749a10e517dcbe33a489c5a6be2 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:00:47 +0100 Subject: [PATCH 02/60] Fix env var query in github workflow --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3e14f236..796e1f4b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,12 +29,12 @@ jobs: uses: docker/build-push-action@v3 with: push: true - tags: $DOCKER_IMAGE + tags: ${{ env.DOCKER_IMAGE }} unit-test: needs: docker-build runs-on: ubuntu-latest - container: $DOCKER_IMAGE + container: ${{ env.DOCKER_IMAGE }} steps: - name: Checkout Repo From 7a880a3e4520d1e759496115453904262daa928e Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:03:51 +0100 Subject: [PATCH 03/60] Revert "Fix env var query in github workflow" This reverts commit dc37cec82c4d2749a10e517dcbe33a489c5a6be2. --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 796e1f4b7..b3e14f236 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,12 +29,12 @@ jobs: uses: docker/build-push-action@v3 with: push: true - tags: ${{ env.DOCKER_IMAGE }} + tags: $DOCKER_IMAGE unit-test: needs: docker-build runs-on: ubuntu-latest - container: ${{ env.DOCKER_IMAGE }} + container: $DOCKER_IMAGE steps: - name: Checkout Repo From 8eb75e28b85640b83ac36e8012775f64005f9bcd Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:05:45 +0100 Subject: [PATCH 04/60] Try specifying Docker tag with variables --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b3e14f236..c3489c9f5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,12 +29,12 @@ jobs: uses: docker/build-push-action@v3 with: push: true - tags: $DOCKER_IMAGE + tags: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} unit-test: needs: docker-build runs-on: ubuntu-latest - container: $DOCKER_IMAGE + container: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} steps: - name: Checkout Repo From dfefe7bbe785475dd6a779c01009dbfd51bf13ea Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:08:47 +0100 Subject: [PATCH 05/60] Hardcode Docker Hub namespace --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c3489c9f5..ca8970e28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,12 +29,12 @@ jobs: uses: docker/build-push-action@v3 with: push: true - tags: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} + tags: peanutfunn/climada_env:${{ github.ref_name }} unit-test: needs: docker-build runs-on: ubuntu-latest - container: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} + container: peanutfunn/climada_env:${{ github.ref_name }} steps: - name: Checkout Repo From bec8823d077f97a1cba605c54c69b50c945fa6e3 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:31:42 +0100 Subject: [PATCH 06/60] Conditionally run jobs and try to fix unittest job --- .github/workflows/main.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ca8970e28..b7a5c21af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,8 @@ name: ci -on: push +on: + push: + branches: env: DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} @@ -8,6 +10,7 @@ env: jobs: docker-build: runs-on: ubuntu-latest + if: github.event == 'create' steps: - name: Checkout Repo @@ -33,8 +36,11 @@ jobs: unit-test: needs: docker-build + if: ${{ always }} runs-on: ubuntu-latest - container: peanutfunn/climada_env:${{ github.ref_name }} + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo From f5ef2d58a1fd5f02ec36511367708aaff70397f2 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:32:42 +0100 Subject: [PATCH 07/60] Fix syntax error in github workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7a5c21af..7f2b137fa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,7 +36,7 @@ jobs: unit-test: needs: docker-build - if: ${{ always }} + if: ${{ always() }} runs-on: ubuntu-latest container: image: peanutfunn/climada_env:${{ github.ref_name }} From a4806c0639cfbc44616c16e69a0ac41c494551d0 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:35:14 +0100 Subject: [PATCH 08/60] Do not call make in github workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7f2b137fa..ef1169f16 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,6 +48,6 @@ jobs: - name: Run Unit Tests run: | - make unit_test + python -m coverage run tests_runner.py unit From 84223c46b708400336502f68fb38b3e5186ce788 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 17:56:36 +0100 Subject: [PATCH 09/60] Try fixing the shell inside Docker container for github workflow --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef1169f16..ea5b824f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,9 @@ jobs: container: image: peanutfunn/climada_env:${{ github.ref_name }} options: --user root + defaults: + run: + shell: bash -el {0} steps: - name: Checkout Repo From d9b3696069ee15f23d347390ade59decba953080 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 12 Jan 2023 18:08:54 +0100 Subject: [PATCH 10/60] Call micromamba directly in github workflow --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea5b824f9..45da7d509 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,6 +51,6 @@ jobs: - name: Run Unit Tests run: | - python -m coverage run tests_runner.py unit + micromamba run python -m coverage run tests_runner.py unit From 9bf105408a5f2b791e84cb9e77be79b1aa1ad34b Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 13 Jan 2023 16:52:21 +0100 Subject: [PATCH 11/60] Use 'micromamba install' because 'update' does not update pip deps --- .github/workflows/main.yml | 3 --- Dockerfile | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45da7d509..6aac0ec73 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,9 +41,6 @@ jobs: container: image: peanutfunn/climada_env:${{ github.ref_name }} options: --user root - defaults: - run: - shell: bash -el {0} steps: - name: Checkout Repo diff --git a/Dockerfile b/Dockerfile index 2ba6a8a01..8403b0787 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,5 +3,5 @@ FROM mambaorg/micromamba:latest COPY --chown=$MAMBA_USER:$MAMBA_USER requirements /tmp/requirements/ RUN micromamba install -y -n base -f /tmp/requirements/env_climada.yml && \ - micromamba update -y -n base -f /tmp/requirements/env_developer.yml && \ + micromamba install -y -n base -f /tmp/requirements/env_developer.yml && \ micromamba clean --all --yes From b9e9c256441c2d43e3ab3355b432c9f9fce7ade5 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 13 Jan 2023 17:39:50 +0100 Subject: [PATCH 12/60] Split GitHub workflows --- .github/workflows/build.yml | 21 +++++++++++++++++++ .github/workflows/docker.yml | 38 +++++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 4 ---- .github/workflows/test.yml | 39 ++++++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..4b0dc9d15 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: build + +on: + push: + branches: + +jobs: + docker-build: + uses: ./.github/workflows/docker.yml + secrets: inherit + + unit-tests: + needs: docker-build + uses: ./.github/workflows/test.yml + with: + test-type: unit-test + + data-api-tests: + uses: ./.github/workflows/test.yml + with: + test-type: data-test diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..283870b28 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,38 @@ +name: docker + +on: + workflow_call: + secrets: + DOCKER_USERNAME: + required: true + DOCKER_ACCESS_TOKEN: + required: true + +env: + DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} + +jobs: + build-image: + runs-on: ubuntu-latest + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - + name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_ACCESS_TOKEN }} + - + name: Build and push + uses: docker/build-push-action@v3 + with: + push: true + tags: peanutfunn/climada_env:${{ github.ref_name }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6aac0ec73..ee4214c94 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,5 @@ name: ci -on: - push: - branches: - env: DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..732bb28b9 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: test + +on: + workflow_call: + inputs: + test-type: + required: true + type: string + +jobs: + unit-test: + if: inputs.test-type == 'unit-test' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Unit Tests + run: | + micromamba run python -m coverage run tests_runner.py unit + + data-test: + if: inputs.test-type == 'data-test' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Unit Tests + run: | + micromamba run python test_data_api.py From 9302bf2a1732df1e48bb60f74bbde35b19d62c6a Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:22:03 +0100 Subject: [PATCH 13/60] Consolidate GitHub Workflows --- .github/workflows/build.yml | 11 +++----- .github/workflows/docker.yml | 16 ++++++++++- .github/workflows/main.yml | 49 ---------------------------------- .github/workflows/test.yml | 6 ++--- Dockerfile | 7 ++++- requirements/env_developer.yml | 1 + 6 files changed, 29 insertions(+), 61 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4b0dc9d15..19fb1b0e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,14 +8,11 @@ jobs: docker-build: uses: ./.github/workflows/docker.yml secrets: inherit - - unit-tests: - needs: docker-build - uses: ./.github/workflows/test.yml with: - test-type: unit-test + new_image: ${{ github.event.created }} - data-api-tests: + tests: + needs: docker-build uses: ./.github/workflows/test.yml with: - test-type: data-test + test_types: unit-test,data-test diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 283870b28..fa6057403 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -2,6 +2,10 @@ name: docker on: workflow_call: + inputs: + new_image: + required: true + type: boolean secrets: DOCKER_USERNAME: required: true @@ -33,6 +37,16 @@ jobs: - name: Build and push uses: docker/build-push-action@v3 + if: inputs.new_image + with: + push: true + tags: ${{ env.DOCKER_IMAGE }} + - + name: Update and push + uses: docker/build-push-action@v3 + if: !(inputs.new_image) with: push: true - tags: peanutfunn/climada_env:${{ github.ref_name }} + tags: ${{ env.DOCKER_IMAGE }} + build_args: + - base_image=${{ env.DOCKER_IMAGE }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index ee4214c94..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: ci - -env: - DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} - -jobs: - docker-build: - runs-on: ubuntu-latest - if: github.event == 'create' - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - push: true - tags: peanutfunn/climada_env:${{ github.ref_name }} - - unit-test: - needs: docker-build - if: ${{ always() }} - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Unit Tests - run: | - micromamba run python -m coverage run tests_runner.py unit - - diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 732bb28b9..5c8c0da4a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,13 +3,13 @@ name: test on: workflow_call: inputs: - test-type: + test_types: required: true type: string jobs: unit-test: - if: inputs.test-type == 'unit-test' + if: contains( inputs.test_types, 'unit-test' ) runs-on: ubuntu-latest container: image: peanutfunn/climada_env:${{ github.ref_name }} @@ -24,7 +24,7 @@ jobs: micromamba run python -m coverage run tests_runner.py unit data-test: - if: inputs.test-type == 'data-test' + if: contains( inputs.test_types, 'data-test' ) runs-on: ubuntu-latest container: image: peanutfunn/climada_env:${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile index 8403b0787..e960678b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,12 @@ -FROM mambaorg/micromamba:latest +# Define the base image for the task +ARG base_image=mambaorg/micromamba:latest +FROM $base_image +# Copy the requirements into the container COPY --chown=$MAMBA_USER:$MAMBA_USER requirements /tmp/requirements/ +# Install requirements, drop in an update for good measure RUN micromamba install -y -n base -f /tmp/requirements/env_climada.yml && \ micromamba install -y -n base -f /tmp/requirements/env_developer.yml && \ + micromamba update -y -n base && \ micromamba clean --all --yes diff --git a/requirements/env_developer.yml b/requirements/env_developer.yml index ba828e60d..f3ffdb732 100644 --- a/requirements/env_developer.yml +++ b/requirements/env_developer.yml @@ -6,6 +6,7 @@ dependencies: - ipython - ipykernel - mccabe>=0.6 + - make - pandoc - sphinx>=2.0 - pip From bb320bbb442faeebb11bf2a197e7c7430c1d759f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:24:18 +0100 Subject: [PATCH 14/60] Try fixing syntax for GitHub workflow expression --- .github/workflows/docker.yml | 2 +- climada.conf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index fa6057403..10e54f2bb 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -44,7 +44,7 @@ jobs: - name: Update and push uses: docker/build-push-action@v3 - if: !(inputs.new_image) + if: ${{ ! inputs.new_image }} with: push: true tags: ${{ env.DOCKER_IMAGE }} diff --git a/climada.conf b/climada.conf index 3d07e07ca..daf9f719c 100644 --- a/climada.conf +++ b/climada.conf @@ -26,5 +26,5 @@ "data_api": { "supported_exposures_types": ["litpop", "crop_production", "base"] }, - "log_level": "INFO" -} \ No newline at end of file + "log_level": "DEBUG" +} From e43e582df44ff231760ccbc8caf9059232f6dc9b Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:26:03 +0100 Subject: [PATCH 15/60] Fix typo in docker workflow --- .github/workflows/docker.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 10e54f2bb..9aa3ff1a4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -48,5 +48,5 @@ jobs: with: push: true tags: ${{ env.DOCKER_IMAGE }} - build_args: + build-args: - base_image=${{ env.DOCKER_IMAGE }} From 0022546d5abe1218de6dcf474a875aa905777eec Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:29:39 +0100 Subject: [PATCH 16/60] Fix list input for docker.yml workflow --- .github/workflows/docker.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9aa3ff1a4..d1455375c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -48,5 +48,5 @@ jobs: with: push: true tags: ${{ env.DOCKER_IMAGE }} - build-args: - - base_image=${{ env.DOCKER_IMAGE }} + build-args: | + base_image=${{ env.DOCKER_IMAGE }} From 36c5cd10b4bf62ccdb3079bd648cee97cb69ab78 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:45:13 +0100 Subject: [PATCH 17/60] Run all tests in GitHub workflow --- .github/workflows/build.yml | 2 +- .github/workflows/test.yml | 57 ++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 19fb1b0e3..d498da4c5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,4 +15,4 @@ jobs: needs: docker-build uses: ./.github/workflows/test.yml with: - test_types: unit-test,data-test + test_types: all diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c8c0da4a..b5ef1ae97 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,13 +7,15 @@ on: required: true type: string -jobs: - unit-test: - if: contains( inputs.test_types, 'unit-test' ) - runs-on: ubuntu-latest - container: +defaults: + runs-on: ubuntu-latest + container: image: peanutfunn/climada_env:${{ github.ref_name }} options: --user root + +jobs: + unit-test: + if: contains( inputs.test_types, 'unit-test' ) || inputs.test_types == 'all' steps: - name: Checkout Repo @@ -21,19 +23,48 @@ jobs: - name: Run Unit Tests run: | - micromamba run python -m coverage run tests_runner.py unit + micromamba run make unit_test data-test: - if: contains( inputs.test_types, 'data-test' ) - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root + if: contains( inputs.test_types, 'data-test' ) || inputs.test_types == 'all' steps: - name: Checkout Repo uses: actions/checkout@v3 - - name: Run Unit Tests + name: Run Data API Tests + run: | + micromamba run make data_test + + integ-test: + if: contains( inputs.test_types, 'integ-test' ) || inputs.test_types == 'all' + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Data API Tests + run: | + micromamba run make integ_test + + notebook-test: + if: contains( inputs.test_types, 'notebook-test' ) || inputs.test_types == 'all' + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Data API Tests + run: | + micromamba run make notebook_test + + install-test: + if: contains( inputs.test_types, 'install-test' ) || inputs.test_types == 'all' + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Run Data API Tests run: | - micromamba run python test_data_api.py + micromamba run make install_test From e38a8359ff252d18cd3fdc3ee960c2dd209cf82d Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:47:39 +0100 Subject: [PATCH 18/60] Do not use 'defaults' in workflow --- .github/workflows/test.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b5ef1ae97..aff6ba398 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,14 +8,15 @@ on: type: string defaults: - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root + jobs: unit-test: if: contains( inputs.test_types, 'unit-test' ) || inputs.test_types == 'all' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo @@ -27,6 +28,10 @@ jobs: data-test: if: contains( inputs.test_types, 'data-test' ) || inputs.test_types == 'all' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo @@ -38,6 +43,10 @@ jobs: integ-test: if: contains( inputs.test_types, 'integ-test' ) || inputs.test_types == 'all' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo @@ -49,6 +58,10 @@ jobs: notebook-test: if: contains( inputs.test_types, 'notebook-test' ) || inputs.test_types == 'all' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo @@ -60,6 +73,10 @@ jobs: install-test: if: contains( inputs.test_types, 'install-test' ) || inputs.test_types == 'all' + runs-on: ubuntu-latest + container: + image: peanutfunn/climada_env:${{ github.ref_name }} + options: --user root steps: - name: Checkout Repo From 9e3b15b39d947ef2e91c13842a23c4ef4f2a7439 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 14:48:22 +0100 Subject: [PATCH 19/60] Fix stray 'defaults' in workflow --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aff6ba398..5f7c859db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,9 +7,6 @@ on: required: true type: string -defaults: - - jobs: unit-test: if: contains( inputs.test_types, 'unit-test' ) || inputs.test_types == 'all' From 089ba8e8412e44e59e880943bc9c4a0a74361d34 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 16:29:35 +0100 Subject: [PATCH 20/60] Rename testing steps --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5f7c859db..4272996b1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,7 @@ jobs: name: Checkout Repo uses: actions/checkout@v3 - - name: Run Data API Tests + name: Run Integration Tests run: | micromamba run make integ_test @@ -64,7 +64,7 @@ jobs: name: Checkout Repo uses: actions/checkout@v3 - - name: Run Data API Tests + name: Run Jupyter Notebooks run: | micromamba run make notebook_test @@ -79,6 +79,6 @@ jobs: name: Checkout Repo uses: actions/checkout@v3 - - name: Run Data API Tests + name: Run Installation Check run: | micromamba run make install_test From 9be863270d43b840536c4752ab7298807c03e5ca Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 16:30:02 +0100 Subject: [PATCH 21/60] Do not use multiprocessing for integration tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a5046e254..e35578ea0 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ notebook_test : ## Test notebooks in doc/tutorial .PHONY : integ_test integ_test : ## Integration tests execution with xml reports - python -m coverage run --parallel-mode --concurrency=multiprocessing tests_runner.py integ + python -m coverage run tests_runner.py integ python -m coverage combine python -m coverage xml -o coverage.xml python -m coverage html -d coverage From ad5cb0f94050398380d2e5ae86619c1a48d61904 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 16 Jan 2023 17:08:39 +0100 Subject: [PATCH 22/60] Revert climada.conf to 9302bf2a --- climada.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/climada.conf b/climada.conf index daf9f719c..3d07e07ca 100644 --- a/climada.conf +++ b/climada.conf @@ -26,5 +26,5 @@ "data_api": { "supported_exposures_types": ["litpop", "crop_production", "base"] }, - "log_level": "DEBUG" -} + "log_level": "INFO" +} \ No newline at end of file From 58601ed42697dc2baa8fc154ae7cf2fcc07d5fef Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:55:35 +0100 Subject: [PATCH 23/60] Revert "Do not use multiprocessing for integration tests" This reverts commit 9be863270d43b840536c4752ab7298807c03e5ca. The command does not actually use multiprocessing but makes coverage aware of multiprocessing used by the called tests. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e35578ea0..a5046e254 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ notebook_test : ## Test notebooks in doc/tutorial .PHONY : integ_test integ_test : ## Integration tests execution with xml reports - python -m coverage run tests_runner.py integ + python -m coverage run --parallel-mode --concurrency=multiprocessing tests_runner.py integ python -m coverage combine python -m coverage xml -o coverage.xml python -m coverage html -d coverage From ab73601a97b5db186b95f31b455677625247384c Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:11:51 +0100 Subject: [PATCH 24/60] Skip failing integration tests for now --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d498da4c5..7e4b1e4fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,4 +15,4 @@ jobs: needs: docker-build uses: ./.github/workflows/test.yml with: - test_types: all + test_types: unit-test,data-test,notebook-test,install-test From 3fb11ccb81f7bdac0e1e687dcc091bd6e877a094 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:25:56 +0100 Subject: [PATCH 25/60] Add action to publish test results --- .github/workflows/test.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4272996b1..777947898 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -14,6 +14,8 @@ jobs: container: image: peanutfunn/climada_env:${{ github.ref_name }} options: --user root + permissions: # For publishing results + checks: write steps: - name: Checkout Repo @@ -22,6 +24,14 @@ jobs: name: Run Unit Tests run: | micromamba run make unit_test + - + name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + junit_files: "coverage.xml" + check_name: "Unit Test Results" + comment_mode: "off" data-test: if: contains( inputs.test_types, 'data-test' ) || inputs.test_types == 'all' From c6e8949d953aed51d1098e07db3a12837bbaa78e Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:26:16 +0100 Subject: [PATCH 26/60] Run pipeline on branches and pull requests --- .github/workflows/build.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e4b1e4fe..4f6ae209a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,8 +1,6 @@ name: build -on: - push: - branches: +on: [push, pull_request] jobs: docker-build: From b68c4a38938f13c8fbe6aa1adf25cf0baa039601 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:29:34 +0100 Subject: [PATCH 27/60] Grant permissions from top-level job --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f6ae209a..46ea7626e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,5 +12,7 @@ jobs: tests: needs: docker-build uses: ./.github/workflows/test.yml + permissions: # For publishing results + checks: write with: test_types: unit-test,data-test,notebook-test,install-test From bc5499ba429425fba440975e41a77eadd0fb848d Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 20 Jan 2023 16:55:08 +0100 Subject: [PATCH 28/60] Use other XML test reports for displaying results --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 777947898..c4b1dc5d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -29,7 +29,7 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - junit_files: "coverage.xml" + junit_files: tests_xml/*.xml check_name: "Unit Test Results" comment_mode: "off" From 7bf2c5eeb75cdd0f9b42a087498e202dd9d05747 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 9 Feb 2023 15:19:50 +0100 Subject: [PATCH 29/60] Add new workflow using micromamba directly --- .github/workflows/ci.yml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..edaf93865 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,39 @@ +name: ci + +on: [push, pull_request] + +# Use bash explicitly for being able to enter the conda environment +defaults: + run: + shell: bash -l {0} + +jobs: + unit-tests: + runs-on: ubuntu-latest + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Install Conda environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: requirements/env_climada.yml + cache-env: true + channels: conda-forge, defaults + extra-specs: | + coverage + nbformat + make + - + name: Run Unit Tests + run: | + make unit_test + - + name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + junit_files: tests_xml/*.xml + check_name: "Unit Test Results" + comment_mode: "off" From a2afaa7c3cb310265a98c4be30b095fdcf16a9e1 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 9 Feb 2023 15:32:24 +0100 Subject: [PATCH 30/60] Add data and notebook tests to new workflow --- .github/workflows/ci.yml | 71 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edaf93865..08218e9d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,9 @@ defaults: jobs: unit-tests: runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write steps: - name: Checkout Repo @@ -37,3 +40,71 @@ jobs: junit_files: tests_xml/*.xml check_name: "Unit Test Results" comment_mode: "off" + + data-tests: + needs: unit-tests + runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Install Conda environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: requirements/env_climada.yml + cache-env: true + channels: conda-forge, defaults + extra-specs: | + coverage + nbformat + make + - + name: Run Data Tests + run: | + make data_test + - + name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + junit_files: tests_xml/*.xml + check_name: "Data Test Results" + comment_mode: "off" + + notebook-tests: + needs: unit-tests + runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Install Conda environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: requirements/env_climada.yml + cache-env: true + channels: conda-forge, defaults + extra-specs: | + coverage + nbformat + make + - + name: Run Data Tests + run: | + make notebook_test + - + name: Publish Test Results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() + with: + junit_files: tests_xml/*.xml + check_name: "Notebook Test Results" + comment_mode: "off" From fe64e6576e6a01de2d6190cabf79f18d76cb4f49 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 24 Feb 2023 11:50:41 +0100 Subject: [PATCH 31/60] Separately build conda environment This avoids building a new environment for every job. --- .github/workflows/ci.yml | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08218e9d6..81fd7f543 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,7 +8,29 @@ defaults: shell: bash -l {0} jobs: + # --- Build the environment --- + # This job is somewhat superfluous but in case the cached environment is outdated, + # we only build it once instead of one time per job. + build-env: + runs-on: ubuntu-latest + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Build Conda environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: requirements/env_climada.yml + cache-env: true + channels: conda-forge, defaults + extra-specs: | + coverage + nbformat + make + unit-tests: + needs: build-env runs-on: ubuntu-latest permissions: # For publishing results @@ -42,7 +64,7 @@ jobs: comment_mode: "off" data-tests: - needs: unit-tests + needs: build-env runs-on: ubuntu-latest permissions: # For publishing results @@ -76,7 +98,7 @@ jobs: comment_mode: "off" notebook-tests: - needs: unit-tests + needs: build-env runs-on: ubuntu-latest permissions: # For publishing results From 615779d29941bfba6be3ccc55ade6e1f17fad96e Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:06:31 +0100 Subject: [PATCH 32/60] Add integration tests and separate test result reporting --- .github/workflows/ci.yml | 61 ++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 81fd7f543..d0d0619a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,14 +54,10 @@ jobs: name: Run Unit Tests run: | make unit_test - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() + - uses: actions/upload-artifact@v3 with: - junit_files: tests_xml/*.xml - check_name: "Unit Test Results" - comment_mode: "off" + name: unit-test-report + path: tests_xml/ data-tests: needs: build-env @@ -88,14 +84,10 @@ jobs: name: Run Data Tests run: | make data_test - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() + - uses: actions/upload-artifact@v3 with: - junit_files: tests_xml/*.xml - check_name: "Data Test Results" - comment_mode: "off" + name: data-test-report + path: tests_xml/ notebook-tests: needs: build-env @@ -119,9 +111,48 @@ jobs: nbformat make - - name: Run Data Tests + name: Run Notebook Tests run: | make notebook_test + + integration-tests: + needs: build-env + runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Install Conda environment + uses: mamba-org/provision-with-micromamba@main + with: + environment-file: requirements/env_climada.yml + cache-env: true + channels: conda-forge, defaults + extra-specs: | + coverage + nbformat + make + - + name: Run Integration Tests + run: | + make integ_test + - uses: actions/upload-artifact@v3 + with: + name: integration-test-report + path: tests_xml/ + + report-test-results: + if: ${{ always() }} + needs: [unit-tests, data-tests, integration-tests] + steps: + - + uses: actions/download-artifact@v3 + with: + path: tests_xml/ - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 From ff987658b6d5dcd8030f73f33ce4fd4a08cc4e07 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:07:27 +0100 Subject: [PATCH 33/60] Fix missing 'runs-on' --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d0d0619a1..f9fa3d921 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -148,6 +148,7 @@ jobs: report-test-results: if: ${{ always() }} needs: [unit-tests, data-tests, integration-tests] + runs-on: ubuntu-latest steps: - uses: actions/download-artifact@v3 From 95505f17f2a373b6ec8f3d97d46f0e53bc11afcc Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:12:23 +0100 Subject: [PATCH 34/60] ci: Add ipython to extra requirements --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9fa3d921..a5e37f51e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,7 @@ jobs: channels: conda-forge, defaults extra-specs: | coverage + ipython nbformat make @@ -48,6 +49,7 @@ jobs: channels: conda-forge, defaults extra-specs: | coverage + ipython nbformat make - @@ -78,6 +80,7 @@ jobs: channels: conda-forge, defaults extra-specs: | coverage + ipython nbformat make - @@ -108,6 +111,7 @@ jobs: channels: conda-forge, defaults extra-specs: | coverage + ipython nbformat make - @@ -134,6 +138,7 @@ jobs: channels: conda-forge, defaults extra-specs: | coverage + ipython nbformat make - From b568c6900a181208432badf39c8260de73067d87 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 24 Feb 2023 12:18:48 +0100 Subject: [PATCH 35/60] ci: Fix publish results * Fix permissions. * Fix path to artifacts. --- .github/workflows/ci.yml | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5e37f51e..ddbb2a268 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,9 +33,6 @@ jobs: unit-tests: needs: build-env runs-on: ubuntu-latest - permissions: - # For publishing results - checks: write steps: - name: Checkout Repo @@ -64,9 +61,6 @@ jobs: data-tests: needs: build-env runs-on: ubuntu-latest - permissions: - # For publishing results - checks: write steps: - name: Checkout Repo @@ -95,9 +89,6 @@ jobs: notebook-tests: needs: build-env runs-on: ubuntu-latest - permissions: - # For publishing results - checks: write steps: - name: Checkout Repo @@ -122,9 +113,6 @@ jobs: integration-tests: needs: build-env runs-on: ubuntu-latest - permissions: - # For publishing results - checks: write steps: - name: Checkout Repo @@ -154,6 +142,9 @@ jobs: if: ${{ always() }} needs: [unit-tests, data-tests, integration-tests] runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write steps: - uses: actions/download-artifact@v3 @@ -164,6 +155,6 @@ jobs: uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - junit_files: tests_xml/*.xml + junit_files: tests_xml/**/*.xml check_name: "Notebook Test Results" comment_mode: "off" From aafd6b2d74834c4729c076b676c3b381fec1059d Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:30:45 +0200 Subject: [PATCH 36/60] Remove all but the mamba pipelines --- .github/workflows/build.yml | 18 ------- .github/workflows/docker.yml | 52 -------------------- .github/workflows/test.yml | 94 ------------------------------------ 3 files changed, 164 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 46ea7626e..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: build - -on: [push, pull_request] - -jobs: - docker-build: - uses: ./.github/workflows/docker.yml - secrets: inherit - with: - new_image: ${{ github.event.created }} - - tests: - needs: docker-build - uses: ./.github/workflows/test.yml - permissions: # For publishing results - checks: write - with: - test_types: unit-test,data-test,notebook-test,install-test diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index d1455375c..000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: docker - -on: - workflow_call: - inputs: - new_image: - required: true - type: boolean - secrets: - DOCKER_USERNAME: - required: true - DOCKER_ACCESS_TOKEN: - required: true - -env: - DOCKER_IMAGE: ${{ secrets.DOCKER_USERNAME }}/climada_env:${{ github.ref_name }} - -jobs: - build-image: - runs-on: ubuntu-latest - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - if: inputs.new_image - with: - push: true - tags: ${{ env.DOCKER_IMAGE }} - - - name: Update and push - uses: docker/build-push-action@v3 - if: ${{ ! inputs.new_image }} - with: - push: true - tags: ${{ env.DOCKER_IMAGE }} - build-args: | - base_image=${{ env.DOCKER_IMAGE }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c4b1dc5d1..000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,94 +0,0 @@ -name: test - -on: - workflow_call: - inputs: - test_types: - required: true - type: string - -jobs: - unit-test: - if: contains( inputs.test_types, 'unit-test' ) || inputs.test_types == 'all' - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - permissions: # For publishing results - checks: write - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Unit Tests - run: | - micromamba run make unit_test - - - name: Publish Test Results - uses: EnricoMi/publish-unit-test-result-action@v2 - if: always() - with: - junit_files: tests_xml/*.xml - check_name: "Unit Test Results" - comment_mode: "off" - - data-test: - if: contains( inputs.test_types, 'data-test' ) || inputs.test_types == 'all' - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Data API Tests - run: | - micromamba run make data_test - - integ-test: - if: contains( inputs.test_types, 'integ-test' ) || inputs.test_types == 'all' - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Integration Tests - run: | - micromamba run make integ_test - - notebook-test: - if: contains( inputs.test_types, 'notebook-test' ) || inputs.test_types == 'all' - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Jupyter Notebooks - run: | - micromamba run make notebook_test - - install-test: - if: contains( inputs.test_types, 'install-test' ) || inputs.test_types == 'all' - runs-on: ubuntu-latest - container: - image: peanutfunn/climada_env:${{ github.ref_name }} - options: --user root - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Run Installation Check - run: | - micromamba run make install_test From 18fb3eddb4e841414bf10a7e97607b1da75933e1 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 10:43:27 +0200 Subject: [PATCH 37/60] Run test matrix with different Python versions Remove version pip for Python in environment specs. --- .github/workflows/ci.yml | 120 ++++++----------------------------- requirements/env_climada.yml | 2 +- 2 files changed, 21 insertions(+), 101 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ddbb2a268..0ab6c7ba2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,43 +8,27 @@ defaults: shell: bash -l {0} jobs: - # --- Build the environment --- - # This job is somewhat superfluous but in case the cached environment is outdated, - # we only build it once instead of one time per job. - build-env: + build-and-test: runs-on: ubuntu-latest - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Build Conda environment - uses: mamba-org/provision-with-micromamba@main - with: - environment-file: requirements/env_climada.yml - cache-env: true - channels: conda-forge, defaults - extra-specs: | - coverage - ipython - nbformat - make - unit-tests: - needs: build-env - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.9, 3.10, 3.11] + steps: - name: Checkout Repo uses: actions/checkout@v3 - - name: Install Conda environment + name: Build Python ${{ matrix.python-version }} environment uses: mamba-org/provision-with-micromamba@main with: environment-file: requirements/env_climada.yml cache-env: true - channels: conda-forge, defaults + channels: conda-forge extra-specs: | + python=${{ matrix.python-version }} coverage ipython nbformat @@ -53,94 +37,30 @@ jobs: name: Run Unit Tests run: | make unit_test - - uses: actions/upload-artifact@v3 - with: - name: unit-test-report - path: tests_xml/ - - data-tests: - needs: build-env - runs-on: ubuntu-latest - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Install Conda environment - uses: mamba-org/provision-with-micromamba@main - with: - environment-file: requirements/env_climada.yml - cache-env: true - channels: conda-forge, defaults - extra-specs: | - coverage - ipython - nbformat - make - name: Run Data Tests run: | make data_test - - uses: actions/upload-artifact@v3 - with: - name: data-test-report - path: tests_xml/ - - notebook-tests: - needs: build-env - runs-on: ubuntu-latest - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - name: Install Conda environment - uses: mamba-org/provision-with-micromamba@main - with: - environment-file: requirements/env_climada.yml - cache-env: true - channels: conda-forge, defaults - extra-specs: | - coverage - ipython - nbformat - make + name: Run Integration Tests + run: | + make integ_test + # TODO: Maybe run Notebook tests only on specific Python version? - name: Run Notebook Tests run: | make notebook_test - - integration-tests: - needs: build-env - runs-on: ubuntu-latest - steps: - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Install Conda environment - uses: mamba-org/provision-with-micromamba@main - with: - environment-file: requirements/env_climada.yml - cache-env: true - channels: conda-forge, defaults - extra-specs: | - coverage - ipython - nbformat - make - - - name: Run Integration Tests - run: | - make integ_test - - uses: actions/upload-artifact@v3 + name: Upload Artifacts Python ${{ matrix.python-version }} + if: always() + uses: actions/upload-artifact@v3 with: - name: integration-test-report + name: data-test-report path: tests_xml/ report-test-results: - if: ${{ always() }} - needs: [unit-tests, data-tests, integration-tests] + if: always() + needs: build-and-test runs-on: ubuntu-latest permissions: # For publishing results @@ -156,5 +76,5 @@ jobs: if: always() with: junit_files: tests_xml/**/*.xml - check_name: "Notebook Test Results" + check_name: "Test Results" comment_mode: "off" diff --git a/requirements/env_climada.yml b/requirements/env_climada.yml index ba6685932..d6d4214a0 100644 --- a/requirements/env_climada.yml +++ b/requirements/env_climada.yml @@ -24,7 +24,7 @@ dependencies: - pycountry>=20.7 - pyepsg>=0.4 - pytables>=3.6 - - python=3.9 + - python>3.8 - pyxlsb>=1.0 - rasterio>=1.2.7,<1.3 # 1.3 yields different results for some tests (#512) - requests>=2.24 From 270afabae423e8f039b392c4e016457e9ee3dc16 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:22:21 +0200 Subject: [PATCH 38/60] Fix Python version parsing in CI --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ab6c7ba2..932288c5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.9, 3.10, 3.11] + python-version: ["3.9", "3.10", "3.11"] steps: - From e6b8c1e8cfab5bbcb640c2d432fe704bcbcf5a3f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:23:04 +0200 Subject: [PATCH 39/60] Add linting job to CI --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 932288c5c..98643f1fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -78,3 +78,15 @@ jobs: junit_files: tests_xml/**/*.xml check_name: "Test Results" comment_mode: "off" + + linting: + runs-on: ubuntu-latest + steps: + - + name: Checkout Repo + uses: actions/checkout@v3 + - + name: Lint Code + uses: marian-code/python-lint-annotate@v3 + with: + python-root-list: climada/ From 94d60f24a9ffd1a9dc7f4abd5b5b89b56174ec56 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 12:23:30 +0200 Subject: [PATCH 40/60] Skip integration tests in GitHub CI --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 98643f1fc..9c509dfc5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,10 +41,10 @@ jobs: name: Run Data Tests run: | make data_test - - - name: Run Integration Tests - run: | - make integ_test + # - + # name: Run Integration Tests + # run: | + # make integ_test # TODO: Maybe run Notebook tests only on specific Python version? - name: Run Notebook Tests From 5bc9e5dbbaf767ea0f10740755f2977e16d3b71c Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 13:59:06 +0200 Subject: [PATCH 41/60] Use custom conda environment cache key in CI --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c509dfc5..f63af0a36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,20 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 + # Fetch the date for setting a cache key. + - + id: date + run: | + echo "TODAY=$(date -Idate)" >> $GITHUB_OUTPUT - name: Build Python ${{ matrix.python-version }} environment uses: mamba-org/provision-with-micromamba@main with: environment-file: requirements/env_climada.yml cache-env: true + # Special cache key because we are using a matrix + # NOTE: The cache will be invalidated if the key changes. + cache-env-key: ${{ steps.date.outputs.TODAY }}-Python${{ matrix.python-version }} channels: conda-forge extra-specs: | python=${{ matrix.python-version }} From 61d1cb4af5f6e2795ffa6a6d0411965af88c401b Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 15:11:07 +0200 Subject: [PATCH 42/60] Add matchers and custom linting step to CI --- .github/matchers/pylint-error.json | 18 ++++++++++++++++++ .github/matchers/pylint-warning.json | 18 ++++++++++++++++++ .github/workflows/ci.yml | 20 ++++++++------------ 3 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 .github/matchers/pylint-error.json create mode 100644 .github/matchers/pylint-warning.json diff --git a/.github/matchers/pylint-error.json b/.github/matchers/pylint-error.json new file mode 100644 index 000000000..8c65937fd --- /dev/null +++ b/.github/matchers/pylint-error.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "severity": "error", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-error" + } + ] + } diff --git a/.github/matchers/pylint-warning.json b/.github/matchers/pylint-warning.json new file mode 100644 index 000000000..0226c8cc8 --- /dev/null +++ b/.github/matchers/pylint-warning.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "severity": "warning", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-warning" + } + ] + } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f63af0a36..e5eeddac2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,14 @@ jobs: ipython nbformat make + - + name: Run Linter + if: ${{ matrix.python-version == '3.9' }} + run: | + micromamba install -y pylint + echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" + echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-error.json" + pylint -ry climada - name: Run Unit Tests run: | @@ -86,15 +94,3 @@ jobs: junit_files: tests_xml/**/*.xml check_name: "Test Results" comment_mode: "off" - - linting: - runs-on: ubuntu-latest - steps: - - - name: Checkout Repo - uses: actions/checkout@v3 - - - name: Lint Code - uses: marian-code/python-lint-annotate@v3 - with: - python-root-list: climada/ From 1adb4bf84e4acf199a74906d9fc836f79be729d4 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 28 Mar 2023 15:34:26 +0200 Subject: [PATCH 43/60] Ignore pylint errors in CI --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5eeddac2..a970012e2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,7 @@ jobs: - name: Run Linter if: ${{ matrix.python-version == '3.9' }} + continue-on-error: true # Pylint reports as bit-encoded return values run: | micromamba install -y pylint echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" From 566b7fb589ff021a6bb33a7bd8de7a1f88f2738a Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:00:38 +0200 Subject: [PATCH 44/60] ci: Debug matcher path --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a970012e2..52f1dc938 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,8 @@ jobs: continue-on-error: true # Pylint reports as bit-encoded return values run: | micromamba install -y pylint + echo Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json + echo "Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json" echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-error.json" pylint -ry climada From 41bb4c2e2fe29a2c1ed0afd85bf93904f7f3fb49 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:23:31 +0200 Subject: [PATCH 45/60] ci: Lint with ruff --- .github/matchers/pylint-error.json | 18 ------------------ .github/matchers/pylint-warning.json | 18 ------------------ .github/workflows/ci.yml | 10 +++------- 3 files changed, 3 insertions(+), 43 deletions(-) delete mode 100644 .github/matchers/pylint-error.json delete mode 100644 .github/matchers/pylint-warning.json diff --git a/.github/matchers/pylint-error.json b/.github/matchers/pylint-error.json deleted file mode 100644 index 8c65937fd..000000000 --- a/.github/matchers/pylint-error.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "severity": "error", - "pattern": [ - { - "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", - "file": 1, - "line": 2, - "column": 3, - "code": 4, - "message": 5 - } - ], - "owner": "pylint-error" - } - ] - } diff --git a/.github/matchers/pylint-warning.json b/.github/matchers/pylint-warning.json deleted file mode 100644 index 0226c8cc8..000000000 --- a/.github/matchers/pylint-warning.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "severity": "warning", - "pattern": [ - { - "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", - "file": 1, - "line": 2, - "column": 3, - "code": 4, - "message": 5 - } - ], - "owner": "pylint-warning" - } - ] - } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 52f1dc938..506413575 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,17 +41,13 @@ jobs: ipython nbformat make + ruff - name: Run Linter if: ${{ matrix.python-version == '3.9' }} - continue-on-error: true # Pylint reports as bit-encoded return values + continue-on-error: true # Ruff may throw errors run: | - micromamba install -y pylint - echo Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json - echo "Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json" - echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" - echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-error.json" - pylint -ry climada + ruff --format=github --target-version=py37 climada/ - name: Run Unit Tests run: | From 60ee28fb2bab149ab5559ef319a17173ca4a3e8f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:24:05 +0200 Subject: [PATCH 46/60] ci: Fix Python target version for ruff --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 506413575..8b9965213 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: if: ${{ matrix.python-version == '3.9' }} continue-on-error: true # Ruff may throw errors run: | - ruff --format=github --target-version=py37 climada/ + ruff --format=github --target-version=py39 climada/ - name: Run Unit Tests run: | From dc3c556b58c7758cbfa5adf392525487a1684db7 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Wed, 29 Mar 2023 10:41:13 +0200 Subject: [PATCH 47/60] ci: Add permissions for publishing checks to test job --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b9965213..a50b276f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,11 @@ jobs: matrix: python-version: ["3.9", "3.10", "3.11"] + permissions: + # For publishing linter checks and annotations + checks: write + contents: write + steps: - name: Checkout Repo From cda0f6064aeac9935b5a627cc72311ddab1c29da Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:36:09 +0200 Subject: [PATCH 48/60] Revert "ci: Lint with ruff" This reverts commits 41bb4c2e2fe29a2c1ed0afd85bf93904f7f3fb49 and 60ee28fb2bab149ab5559ef319a17173ca4a3e8f. --- .github/matchers/pylint-error.json | 18 ++++++++++++++++++ .github/matchers/pylint-warning.json | 18 ++++++++++++++++++ .github/workflows/ci.yml | 10 +++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 .github/matchers/pylint-error.json create mode 100644 .github/matchers/pylint-warning.json diff --git a/.github/matchers/pylint-error.json b/.github/matchers/pylint-error.json new file mode 100644 index 000000000..8c65937fd --- /dev/null +++ b/.github/matchers/pylint-error.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "severity": "error", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-error" + } + ] + } diff --git a/.github/matchers/pylint-warning.json b/.github/matchers/pylint-warning.json new file mode 100644 index 000000000..0226c8cc8 --- /dev/null +++ b/.github/matchers/pylint-warning.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "severity": "warning", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-warning" + } + ] + } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a50b276f7..0a9a492f0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,13 +46,17 @@ jobs: ipython nbformat make - ruff - name: Run Linter if: ${{ matrix.python-version == '3.9' }} - continue-on-error: true # Ruff may throw errors + continue-on-error: true # Pylint reports as bit-encoded return values run: | - ruff --format=github --target-version=py39 climada/ + micromamba install -y pylint + echo Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json + echo "Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json" + echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" + echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-error.json" + pylint -ry climada - name: Run Unit Tests run: | From c0ed9e10eec8198bd99fc024896289a2f2013dab Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Fri, 23 Jun 2023 10:36:17 +0200 Subject: [PATCH 49/60] Update CI configuration * Use new micromamba action. * Do not lint. * Upload coverage reports as artifacts. * Report test results for every Python version individually. --- .github/workflows/ci.yml | 88 ++++++++++------------------------------ 1 file changed, 22 insertions(+), 66 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a9a492f0..b33a88596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: ci -on: [push, pull_request] +on: [push] # Use bash explicitly for being able to enter the conda environment defaults: @@ -10,95 +10,51 @@ defaults: jobs: build-and-test: runs-on: ubuntu-latest + permissions: + # For publishing results + checks: write strategy: fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11"] - permissions: - # For publishing linter checks and annotations - checks: write - contents: write - steps: - name: Checkout Repo uses: actions/checkout@v3 - # Fetch the date for setting a cache key. - - - id: date - run: | - echo "TODAY=$(date -Idate)" >> $GITHUB_OUTPUT - - name: Build Python ${{ matrix.python-version }} environment - uses: mamba-org/provision-with-micromamba@main + name: Create Environment with Mamba + uses: mamba-org/setup-micromamba@v1 with: + environment-name: climada_env_${{ matrix.python-version }} environment-file: requirements/env_climada.yml - cache-env: true - # Special cache key because we are using a matrix - # NOTE: The cache will be invalidated if the key changes. - cache-env-key: ${{ steps.date.outputs.TODAY }}-Python${{ matrix.python-version }} - channels: conda-forge - extra-specs: | + create-args: >- python=${{ matrix.python-version }} - coverage - ipython - nbformat make + cache-environment: true + init-shell: >- + bash - - name: Run Linter - if: ${{ matrix.python-version == '3.9' }} - continue-on-error: true # Pylint reports as bit-encoded return values + name: Install CLIMADA run: | - micromamba install -y pylint - echo Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json - echo "Adding matcher: ${{ github.workspace }}/.github/matchers/pylint-warning.json" - echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-warning.json" - echo "::add-matcher::${{ github.workspace }}/.github/matchers/pylint-error.json" - pylint -ry climada + python -m pip install ".[test]" - name: Run Unit Tests run: | make unit_test - - - name: Run Data Tests - run: | - make data_test - # - - # name: Run Integration Tests - # run: | - # make integ_test - # TODO: Maybe run Notebook tests only on specific Python version? - - - name: Run Notebook Tests - run: | - make notebook_test - - - name: Upload Artifacts Python ${{ matrix.python-version }} - if: always() - uses: actions/upload-artifact@v3 - with: - name: data-test-report - path: tests_xml/ - - report-test-results: - if: always() - needs: build-and-test - runs-on: ubuntu-latest - permissions: - # For publishing results - checks: write - steps: - - - uses: actions/download-artifact@v3 - with: - path: tests_xml/ - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action@v2 if: always() with: - junit_files: tests_xml/**/*.xml - check_name: "Test Results" + junit_files: tests_xml/tests.xml + check_name: "Test Results Python ${{ matrix.python-version }}" comment_mode: "off" + - + name: Upload Coverage Reports + if: always() + uses: actions/upload-artifact@v3 + with: + name: coverage-report-py${{ matrix.python-version }} + path: coverage/ From 6ed83e65c72da24a556d78a3addbd4ed45692807 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 26 Jun 2023 10:43:55 +0200 Subject: [PATCH 50/60] Stop testing Python 3.11 due to incompatibilities with dataclass --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b33a88596..a3429aeae 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10"] steps: - From 4807bab1732bcccec190c43e176931672fa46c9f Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:01:59 +0200 Subject: [PATCH 51/60] Revert "Stop testing Python 3.11 due to incompatibilities with dataclass" This reverts commit 6ed83e65c72da24a556d78a3addbd4ed45692807. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a3429aeae..b33a88596 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - From 8dd46d78deacd843d8379b482607e7408334bea8 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:10:54 +0200 Subject: [PATCH 52/60] Set environment caching for GitHub workflow --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b33a88596..b69c7a72f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,9 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 + - name: Get current date + id: date + run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" - name: Create Environment with Mamba uses: mamba-org/setup-micromamba@v1 @@ -32,9 +35,10 @@ jobs: create-args: >- python=${{ matrix.python-version }} make - cache-environment: true init-shell: >- bash + # Persist environment for branch, Python version, single day + cache-environment-key: env-${{ github.ref }}-${{ matrix.python-version }}-${{ steps.date.outputs.date }} - name: Install CLIMADA run: | From e1e52a2b1ca7e7ac5ea3934fefeb53fc9ed17d98 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 4 Jul 2023 14:12:13 +0200 Subject: [PATCH 53/60] Remove unused files --- .github/matchers/pylint-error.json | 18 ------------------ .github/matchers/pylint-warning.json | 18 ------------------ Dockerfile | 12 ------------ 3 files changed, 48 deletions(-) delete mode 100644 .github/matchers/pylint-error.json delete mode 100644 .github/matchers/pylint-warning.json delete mode 100644 Dockerfile diff --git a/.github/matchers/pylint-error.json b/.github/matchers/pylint-error.json deleted file mode 100644 index 8c65937fd..000000000 --- a/.github/matchers/pylint-error.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "severity": "error", - "pattern": [ - { - "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", - "file": 1, - "line": 2, - "column": 3, - "code": 4, - "message": 5 - } - ], - "owner": "pylint-error" - } - ] - } diff --git a/.github/matchers/pylint-warning.json b/.github/matchers/pylint-warning.json deleted file mode 100644 index 0226c8cc8..000000000 --- a/.github/matchers/pylint-warning.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "problemMatcher": [ - { - "severity": "warning", - "pattern": [ - { - "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", - "file": 1, - "line": 2, - "column": 3, - "code": 4, - "message": 5 - } - ], - "owner": "pylint-warning" - } - ] - } diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index e960678b9..000000000 --- a/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -# Define the base image for the task -ARG base_image=mambaorg/micromamba:latest -FROM $base_image - -# Copy the requirements into the container -COPY --chown=$MAMBA_USER:$MAMBA_USER requirements /tmp/requirements/ - -# Install requirements, drop in an update for good measure -RUN micromamba install -y -n base -f /tmp/requirements/env_climada.yml && \ - micromamba install -y -n base -f /tmp/requirements/env_developer.yml && \ - micromamba update -y -n base && \ - micromamba clean --all --yes From 36f2ed431d502d3e52a78b02fd0e0acd0a8564eb Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 17 Aug 2023 11:52:02 +0200 Subject: [PATCH 54/60] Fix mutable default values in ImpactFreqCurve --- climada/engine/impact.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/climada/engine/impact.py b/climada/engine/impact.py index 84840c613..39cd327b1 100644 --- a/climada/engine/impact.py +++ b/climada/engine/impact.py @@ -1854,10 +1854,10 @@ class ImpactFreqCurve(): """dictionary of tags of exposures, impact functions set and hazard: {'exp': Tag(), 'impf_set': Tag(), 'haz': Tag()}""" - return_per : np.array = np.array([]) + return_per : np.ndarray = field(default_factory=lambda: np.empty(0)) """return period""" - impact : np.array = np.array([]) + impact : np.ndarray = field(default_factory=lambda: np.empty(0)) """impact exceeding frequency""" unit : str = '' From 4335e2250b7ae0f628928c05b4753a0389105888 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 17 Aug 2023 13:53:35 +0200 Subject: [PATCH 55/60] Fix Nightlight and LitPop tests * Move file checks to integration tests. They require file downloads. * Fix assertion for almost equal arrays. --- climada/entity/exposures/test/test_litpop.py | 2 +- .../entity/exposures/test/test_nightlight.py | 52 +------------------ climada/test/test_nightlight.py | 51 ++++++++++++++++++ 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/climada/entity/exposures/test/test_litpop.py b/climada/entity/exposures/test/test_litpop.py index 851c910fb..d8ec001cd 100644 --- a/climada/entity/exposures/test/test_litpop.py +++ b/climada/entity/exposures/test/test_litpop.py @@ -317,7 +317,7 @@ def test_gridpoints_core_calc_offsets_exp_rescale(self): self.assertEqual(result_array.shape, results_check.shape) self.assertAlmostEqual(result_array.sum(), tot) self.assertEqual(result_array[1,2], results_check[1,2]) - np.testing.assert_array_almost_equal_nulp(result_array, results_check) + np.testing.assert_allclose(result_array, results_check) def test_grp_read_pass(self): """test _grp_read() to pass and return either dict with admin1 values or None""" diff --git a/climada/entity/exposures/test/test_nightlight.py b/climada/entity/exposures/test/test_nightlight.py index beaca1a84..b2ba19b0f 100644 --- a/climada/entity/exposures/test/test_nightlight.py +++ b/climada/entity/exposures/test/test_nightlight.py @@ -56,22 +56,6 @@ def test_required_files(self): self.assertRaises(ValueError, nightlight.get_required_nl_files, (-90, 90)) - def test_check_files_exist(self): - """Test check_nightlight_local_file_exists""" - # If invalid directory is supplied it has to fail - try: - nightlight.check_nl_local_file_exists( - np.ones(np.count_nonzero(BM_FILENAMES)), 'Invalid/path')[0] - raise Exception("if the path is not valid, check_nl_local_file_exists should fail") - except ValueError: - pass - files_exist = nightlight.check_nl_local_file_exists( - np.ones(np.count_nonzero(BM_FILENAMES)), SYSTEM_DIR) - self.assertTrue( - files_exist.sum() > 0, - f'{files_exist} {BM_FILENAMES}' - ) - def test_download_nightlight_files(self): """Test check_nightlight_local_file_exists""" # Not the same length of arguments @@ -117,41 +101,7 @@ def test_get_required_nl_files(self): req_files = nightlight.get_required_nl_files(bounds = bounds_c3) bool = np.array_equal(np.array([0, 0, 0, 0, 0, 0, 1, 0]), req_files) self.assertTrue(bool) - - def test_check_nl_local_file_exists(self): - """ Test that an array with the correct number of already existing files - is produced, the LOGGER messages logged and the ValueError raised. """ - - # check logger messages by giving a to short req_file - with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='WARNING') as cm: - nightlight.check_nl_local_file_exists(required_files = np.array([0, 0, 1, 1])) - self.assertIn('The parameter \'required_files\' was too short and is ignored', - cm.output[0]) - - # check logger message: not all files are available - with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='DEBUG') as cm: - nightlight.check_nl_local_file_exists() - self.assertIn('Not all satellite files available. ' - f'Found 5 out of 8 required files in {Path(SYSTEM_DIR)}', cm.output[0]) - - # check logger message: no files found in checkpath - check_path = Path('climada/entity/exposures') - with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='INFO') as cm: - # using a random path where no files are stored - nightlight.check_nl_local_file_exists(check_path=check_path) - self.assertIn(f'No satellite files found locally in {check_path}', - cm.output[0]) - - # test raises with wrong path - check_path = Path('/random/wrong/path') - with self.assertRaises(ValueError) as cm: - nightlight.check_nl_local_file_exists(check_path=check_path) - self.assertEqual(f'The given path does not exist: {check_path}', - str(cm.exception)) - - # test that files_exist is correct - files_exist = nightlight.check_nl_local_file_exists() - self.assertEqual(int(sum(files_exist)), 5) + # Execute Tests if __name__ == "__main__": diff --git a/climada/test/test_nightlight.py b/climada/test/test_nightlight.py index ce571cef2..636679eab 100644 --- a/climada/test/test_nightlight.py +++ b/climada/test/test_nightlight.py @@ -254,6 +254,57 @@ def test_untar_noaa_stable_nighlight(self): self.assertIn('found more than one potential intensity file in', cm.output[0]) path_tar.unlink() + def test_check_nl_local_file_exists(self): + """ Test that an array with the correct number of already existing files + is produced, the LOGGER messages logged and the ValueError raised. """ + + # check logger messages by giving a to short req_file + with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='WARNING') as cm: + nightlight.check_nl_local_file_exists(required_files = np.array([0, 0, 1, 1])) + self.assertIn('The parameter \'required_files\' was too short and is ignored', + cm.output[0]) + + # check logger message: not all files are available + with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='DEBUG') as cm: + nightlight.check_nl_local_file_exists() + self.assertIn("Not all satellite files available.", cm.output[0]) + self.assertIn(f"files in {Path(SYSTEM_DIR)}", cm.output[0]) + + # check logger message: no files found in checkpath + check_path = Path('climada/entity/exposures') + with self.assertLogs('climada.entity.exposures.litpop.nightlight', level='INFO') as cm: + # using a random path where no files are stored + nightlight.check_nl_local_file_exists(check_path=check_path) + self.assertIn(f'No satellite files found locally in {check_path}', + cm.output[0]) + + # test raises with wrong path + check_path = Path('/random/wrong/path') + with self.assertRaises(ValueError) as cm: + nightlight.check_nl_local_file_exists(check_path=check_path) + self.assertEqual(f'The given path does not exist: {check_path}', + str(cm.exception)) + + # test that files_exist is correct + files_exist = nightlight.check_nl_local_file_exists() + self.assertEqual(int(sum(files_exist)), 5) + + def test_check_files_exist(self): + """Test check_nightlight_local_file_exists""" + # If invalid directory is supplied it has to fail + try: + nightlight.check_nl_local_file_exists( + np.ones(np.count_nonzero(BM_FILENAMES)), 'Invalid/path')[0] + raise Exception("if the path is not valid, check_nl_local_file_exists should fail") + except ValueError: + pass + files_exist = nightlight.check_nl_local_file_exists( + np.ones(np.count_nonzero(BM_FILENAMES)), SYSTEM_DIR) + self.assertTrue( + files_exist.sum() > 0, + f'{files_exist} {BM_FILENAMES}' + ) + # Execute Tests if __name__ == "__main__": TESTS = unittest.TestLoader().loadTestsFromTestCase(TestNightlight) From 109d99443b5f72498e3291b42535eb3e6571ce13 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:25:36 +0200 Subject: [PATCH 56/60] Fix accuracy in default Emanuel impact func test --- climada/entity/impact_funcs/test/test_tc.py | 39 +++++++++++++-------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/climada/entity/impact_funcs/test/test_tc.py b/climada/entity/impact_funcs/test/test_tc.py index c469b12a1..e2db9e609 100644 --- a/climada/entity/impact_funcs/test/test_tc.py +++ b/climada/entity/impact_funcs/test/test_tc.py @@ -39,21 +39,30 @@ def test_default_values_pass(self): self.assertTrue(np.array_equal(imp_fun.intensity, np.arange(0, 121, 5))) self.assertTrue(np.array_equal(imp_fun.paa, np.ones((25,)))) self.assertTrue(np.array_equal(imp_fun.mdd[0:6], np.zeros((6,)))) - self.assertTrue(np.array_equal(imp_fun.mdd[6:10], - np.array([0.0006753419543492556, 0.006790495604105169, - 0.02425254393374475, 0.05758706257339458]))) - self.assertTrue(np.array_equal(imp_fun.mdd[10:15], - np.array([0.10870556455111065, 0.1761433569521351, - 0.2553983618763961, 0.34033822528795565, - 0.4249447743109498]))) - self.assertTrue(np.array_equal(imp_fun.mdd[15:20], - np.array([0.5045777092933046, 0.576424302849412, - 0.6393091739184916, 0.6932203123193963, - 0.7388256596555696]))) - self.assertTrue(np.array_equal(imp_fun.mdd[20:25], - np.array([0.777104531116526, 0.8091124649261859, - 0.8358522190681132, 0.8582150905529946, - 0.8769633232141456]))) + np.testing.assert_allclose( + imp_fun.mdd[6:25], + [ + 0.0006753419543492556, + 0.006790495604105169, + 0.02425254393374475, + 0.05758706257339458, + 0.10870556455111065, + 0.1761433569521351, + 0.2553983618763961, + 0.34033822528795565, + 0.4249447743109498, + 0.5045777092933046, + 0.576424302849412, + 0.6393091739184916, + 0.6932203123193963, + 0.7388256596555696, + 0.777104531116526, + 0.8091124649261859, + 0.8358522190681132, + 0.8582150905529946, + 0.8769633232141456, + ], + ) def test_values_pass(self): """Compute mdr interpolating values.""" From c18cb769705779e1989e76937d7c77119d421ab9 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:28:30 +0200 Subject: [PATCH 57/60] Improve names in Github CI --- .github/workflows/ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b69c7a72f..bbe9e54b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: ci +name: GitHub CI on: [push] @@ -9,6 +9,7 @@ defaults: jobs: build-and-test: + name: Build Env, Install, Unit Tests runs-on: ubuntu-latest permissions: # For publishing results @@ -23,7 +24,8 @@ jobs: - name: Checkout Repo uses: actions/checkout@v3 - - name: Get current date + - + name: Get current date id: date run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" - @@ -53,12 +55,12 @@ jobs: if: always() with: junit_files: tests_xml/tests.xml - check_name: "Test Results Python ${{ matrix.python-version }}" + check_name: "Unit Test Results Python ${{ matrix.python-version }}" comment_mode: "off" - name: Upload Coverage Reports if: always() uses: actions/upload-artifact@v3 with: - name: coverage-report-py${{ matrix.python-version }} + name: coverage-report-unittests-py${{ matrix.python-version }} path: coverage/ From d55e0ea9c06d97e2cb6afeec19db01cc2bd6e4cd Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Thu, 17 Aug 2023 14:32:23 +0200 Subject: [PATCH 58/60] Disallow Python 3.11 for Climada The unsequa module throws segmentation faults while unit testing. --- .github/workflows/ci.yml | 2 +- requirements/env_climada.yml | 2 +- setup.py | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbe9e54b3..a9c52931a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.9", "3.10"] steps: - diff --git a/requirements/env_climada.yml b/requirements/env_climada.yml index 7d2d6280f..e198e2b82 100644 --- a/requirements/env_climada.yml +++ b/requirements/env_climada.yml @@ -26,7 +26,7 @@ dependencies: - pycountry>=22.3 - pyepsg>=0.4 - pytables>=3.7 - - python>=3.9 + - python>=3.9,<3.11 - pyxlsb>=1.0 - rasterio>=1.3 - requests>=2.31 diff --git a/setup.py b/setup.py index 875e7756c..f27b63288 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,8 @@ packages=find_packages() + ['data'], + python_requires=">=3.9,<3.11", + install_requires=[ 'bottleneck', 'cartopy', From ceab9334b2385514a6f8a87e87045ba641b432d8 Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Mon, 28 Aug 2023 15:21:03 +0200 Subject: [PATCH 59/60] Try testing Python v3.11 again --- .github/workflows/ci.yml | 2 +- requirements/env_climada.yml | 2 +- setup.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9c52931a..bbe9e54b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.9", "3.10"] + python-version: ["3.9", "3.10", "3.11"] steps: - diff --git a/requirements/env_climada.yml b/requirements/env_climada.yml index e198e2b82..138ea1f08 100644 --- a/requirements/env_climada.yml +++ b/requirements/env_climada.yml @@ -26,7 +26,7 @@ dependencies: - pycountry>=22.3 - pyepsg>=0.4 - pytables>=3.7 - - python>=3.9,<3.11 + - python>=3.9,<3.12 - pyxlsb>=1.0 - rasterio>=1.3 - requests>=2.31 diff --git a/setup.py b/setup.py index f27b63288..51a7b647f 100644 --- a/setup.py +++ b/setup.py @@ -62,7 +62,7 @@ packages=find_packages() + ['data'], - python_requires=">=3.9,<3.11", + python_requires=">=3.9,<3.12", install_requires=[ 'bottleneck', From f42da0ac45b414c60b7f274d2e07b807e8c18eed Mon Sep 17 00:00:00 2001 From: Lukas Riedel <34276446+peanutfun@users.noreply.github.com> Date: Tue, 19 Sep 2023 16:19:35 +0200 Subject: [PATCH 60/60] Improve GitHub Actions documentation * Add introduction to GitHub Actions to the docs. * Add information to the CI guide. * Improve comments in the ci.yml workflow definition. --- .github/workflows/ci.yml | 4 +++ ...e_Continuous_Integration_and_Testing.ipynb | 7 ++++- doc/guide/github-actions.rst | 29 +++++++++++++++++++ doc/index.rst | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 doc/guide/github-actions.rst diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bbe9e54b3..686ec1e9a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,6 @@ name: GitHub CI +# Execute this for every push on: [push] # Use bash explicitly for being able to enter the conda environment @@ -15,7 +16,9 @@ jobs: # For publishing results checks: write + # Run this test for different Python versions strategy: + # Do not abort other tests if only a single one fails fail-fast: false matrix: python-version: ["3.9", "3.10", "3.11"] @@ -25,6 +28,7 @@ jobs: name: Checkout Repo uses: actions/checkout@v3 - + # Store the current date to use it as cache key for the environment name: Get current date id: date run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}" diff --git a/doc/guide/Guide_Continuous_Integration_and_Testing.ipynb b/doc/guide/Guide_Continuous_Integration_and_Testing.ipynb index fa6383471..ce1800d50 100644 --- a/doc/guide/Guide_Continuous_Integration_and_Testing.ipynb +++ b/doc/guide/Guide_Continuous_Integration_and_Testing.ipynb @@ -299,7 +299,12 @@ "\n", "- All tests must pass before submitting a pull request.\n", "- Integration tests don't run on feature branches in Jenkins, therefore developers are requested to run them locally.\n", - "- After a pull request was accepted and the changes are merged to the develop branch, integration tests may still fail there and have to be addressed." + "- After a pull request was accepted and the changes are merged to the develop branch, integration tests may still fail there and have to be addressed.\n", + "\n", + "#### GitHub Actions\n", + "\n", + "We adopted test automation via GitHub Actions in an experimental state.\n", + "See [GitHub Actions CI](github-actions.rst) for details." ] }, { diff --git a/doc/guide/github-actions.rst b/doc/guide/github-actions.rst new file mode 100644 index 000000000..efaddc276 --- /dev/null +++ b/doc/guide/github-actions.rst @@ -0,0 +1,29 @@ +================= +GitHub Actions CI +================= + +CLIMADA has been using a private Jenkins instance for automated testing (Continuous Integration, CI), see :doc:`Guide_Continuous_Integration_and_Testing`. +We recently adopted `GitHub Actions `_ for automated unit testing. +GitHub Actions is a service provided by GitHub, which lets you configure CI/CD pipelines based on YAML configuration files. +GitHub provides servers which ample computational resources to create software environments, install software, test it, and deploy it. +See the `GitHub Actions Overview `_ for a technical introduction, and the `Workflow Syntax `_ for a reference of the pipeline definitions. + +The CI results for each pull request can be inspected in the "Checks" tab. +For GitHub Actions, users can inspect the logs of every step for every job. + +.. note:: + + As of CLIMADA v4.0, the default CI technology remains Jenkins. + GitHub Actions CI is currently considered experimental for CLIMADA development. + +--------------------- +Unit Testing Pipeline +--------------------- + +This pipeline is defined by the ``.github/workflows/ci.yml`` file. +It contains a single job which will create a CLIMADA environment with Mamba for multiple Python versions, install CLIMADA, run the unit tests, and report the test coverage as well as the simplified test results. +The job has a `strategy `_ which runs it for multiple times for different Python versions. +This way, we make sure that CLIMADA is compatible with all currently supported versions of Python. + +The coverage reports in HTML format will be uploaded as job artifacts and can be downloaded as ZIP files. +The test results are simple testing summaries that will appear as individual checks/jobs after the respective job completed. diff --git a/doc/index.rst b/doc/index.rst index 61a2d00bb..8b11d1c96 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -101,6 +101,7 @@ Jump right in: Performance and Best Practices Coding Conventions Building the Documentation + guide/github-actions .. toctree::