-
Notifications
You must be signed in to change notification settings - Fork 14
99 lines (93 loc) · 3.09 KB
/
testing.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Petals Testing
# 'Reusable workflow', can be triggered from other workflows
on:
workflow_call:
inputs:
petals_branch:
description: Branch of CLIMADA Petals to check out
type: string
default: develop
required: false
core_branch:
description: Branch of CLIMADA Core to test against
type: string
default: develop
required: false
# Use bash explicitly for being able to enter the conda environment
defaults:
run:
shell: bash -el {0}
jobs:
build-and-test:
name: Unit Test Pipeline
runs-on: ubuntu-latest
permissions:
# 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"]
steps:
-
name: Checkout Petals
uses: actions/checkout@v4
with:
repository: CLIMADA-project/climada_petals
path: climada_petals
ref: ${{ inputs.petals_branch }}
-
name: Checkout Core
uses: actions/checkout@v4
with:
repository: CLIMADA-project/climada_python
path: climada_python
ref: ${{ inputs.core_branch }}
-
# 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}"
-
name: Create Environment with Mamba
uses: mamba-org/setup-micromamba@v1
with:
environment-name: climada_env_${{ matrix.python-version }}
environment-file: climada_python/requirements/env_climada.yml
# NOTE: Might be able to give second spec file in create-args in future
# micromamba version
create-args: >-
python=${{ matrix.python-version }}
make
# Persist environment for branch, Python version, single day
cache-environment-key: env-${{ github.ref }}-${{ matrix.python-version }}-${{ steps.date.outputs.date }}
-
name: Update Environment for Petals
run: |
micromamba update -n climada_env_${{ matrix.python-version }} -f climada_petals/requirements/env_climada.yml
-
name: Install CLIMADA Core and Petals
run: |
python -m pip install "./climada_python[test]" "./climada_petals"
-
name: Run Unit Tests
working-directory: climada_petals/
run: |
make unit_test
-
name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
junit_files: climada_petals/tests_xml/tests.xml
check_name: "Petals / Unit Test Results (${{ matrix.python-version }})"
comment_mode: "off"
-
name: Upload Coverage Reports
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report-petals-unittests-py${{ matrix.python-version }}
path: climada_petals/coverage/