-
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (79 loc) · 2.83 KB
/
ci.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
name: Python CI
on:
push:
branches: []
paths-ignore:
- 'README.md'
pull_request:
branches: []
paths-ignore:
- 'README.md'
# Specify concurrency such that only one workflow can run at a time
# * Different workflow files are not affected
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# Define a dependencies job that runs on all branches and PRs
# * Installs dependencies and caches them
build-venv:
runs-on: ubuntu-latest
container: quay.io/condaforge/miniforge3:latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Restore cached virtualenv, if available
# * The pyproject.toml hash is part of the cache key, invalidating
# the cache if the file changes
- name: Restore cached virtualenv
id: restore-cache
uses: actions/cache/restore@v3
with:
path: ./venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/pyproject.toml') }}
# Should mirror the build-venv stage in the Containerfile
- name: Build venv
run: |
apt -qq update && apt -qq install -y build-essential
conda create -p ./venv python=3.10
./venv/bin/python -m pip install --upgrade -q pip wheel setuptools
if: steps.restore-cache.outputs.cache-hit != 'true'
# Should mirror the build-reqs stage in the Containerfile
# * Except this installs the dev dependencies and binaries as well
- name: Install all dependencies
run: |
conda install -p ./venv -q -y eccodes zarr
./venv/bin/python -m pip install -q .[dev]
if: steps.restore-cache.outputs.cache-hit != 'true'
# Cache the virtualenv for future runs
- name: Cache virtualenv
uses: actions/cache/save@v3
with:
path: ./venv
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
if: steps.restore-cache.outputs.cache-hit != 'true'
# Define a unittest job that runs on all branches and PRs
test-unit:
runs-on: ubuntu-latest
needs: build-venv
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Restore cached virtualenv
- name: Restore cached virtualenv
uses: actions/cache/restore@v3
with:
path: ./venv
key: ${{ runner.os }}-venv-${{ hashFiles('**/pyproject.toml') }}
# Run unittests
# * Produce JUnit XML report
- name: Run unit tests
run: ./venv/bin/python -m pytest --junitxml=ut-report.xml dags_tests
# Create test summary to be visualised on the job summary screen on GitHub
# * Runs even if previous steps fail
- name: Create test summary
uses: test-summary/action@v2
with:
paths: "*t-report.xml"
show: "fail, skip"
if: always()