-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (121 loc) · 4.05 KB
/
test.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Pull request
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
lint:
name: Lint content
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3.3.0
with:
fetch-depth: 0 # Enable gitlint to check all PR commit messages
- uses: cachix/install-nix-action@v18
- uses: cachix/cachix-action@v12
with:
name: linz
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Cache pre-commit
uses: actions/cache@v3.2.3
with:
path: ~/.cache/pre-commit
key:
${{ secrets.CACHE_SEED }}-${{ hashFiles('.pre-commit-config.yaml')
}}
- name: Run pre-commit hooks
run: nix-shell --pure --run 'pre-commit run --all-files'
- name: Check all commit messages in Pull Request
run:
nix-shell --pure --run 'gitlint --commits origin/${{ github.base_ref
}}..${{ github.event.pull_request.head.sha }}'
test-nix:
name: Test using Nix
runs-on: ubuntu-22.04
steps:
- name: Check out repository
uses: actions/checkout@v3.3.0
- uses: cachix/install-nix-action@v18
- uses: cachix/cachix-action@v12
with:
name: linz
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Run test
run:
nix-shell --pure --run 'jupyter nbconvert --debug --execute --inplace
--to=notebook sentinel2_water_extraction.ipynb'
working-directory: flooding/sentinel2_water_extraction
test-poetry:
name:
Test on ${{ matrix.runner }}, using Poetry with Python ${{ matrix.python
}}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
runner:
- macos-12
- ubuntu-22.04
python:
- "3.8"
- "3.9"
- "3.10"
include:
- runner: macos-12
pip-cache-dir: ~/Library/Caches/pip
- runner: ubuntu-22.04
pip-cache-dir: ~/.cache/pip
steps:
- name: Check out repository
uses: actions/checkout@v3.3.0
- name: Use Python ${{ matrix.python }}
id: setup-python
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python }}
- name: Cache pip
uses: actions/cache@v3.2.3
with:
path: ${{ matrix.pip-cache-dir }}
key:
${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ matrix.python
}}-${{
hashFiles('./flooding/sentinel2_water_extraction/poetry.lock') }}
restore-keys:
${{ runner.os }}-pip-${{ secrets.CACHE_SEED }}-${{ matrix.python }}-
- name: Install Poetry
run: pip install --disable-pip-version-check --progress-bar=off poetry
- name: Get GDAL Python package version
run:
echo "GDAL_VERSION=$(poetry show gdal | tr -d ' ' | grep '^version:' |
cut -d ':' -f 2)" >> $GITHUB_ENV
working-directory: flooding/sentinel2_water_extraction
- name: Setup Conda
uses: s-weigand/setup-conda@v1.1.1
with:
conda-channels: conda-forge
python-version: ${{ steps.setup-python.outputs.python-version }}
- name: Install Conda environment packages
run:
conda install --channel=conda-forge --quiet --yes gdal=${{
env.GDAL_VERSION }} poetry
- name: Install Python packages
run: poetry install --only=main --no-root
working-directory: flooding/sentinel2_water_extraction
- name: Run test
run:
poetry run jupyter nbconvert --debug --execute --inplace --to=notebook
sentinel2_water_extraction.ipynb
working-directory: flooding/sentinel2_water_extraction
finalise:
if: always()
needs:
- lint
- test-nix
- test-poetry
runs-on: ubuntu-22.04
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@v1.2.2
with:
jobs: ${{ toJSON(needs) }}