-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (139 loc) · 6.45 KB
/
Copy pathtest_python_code.yml
File metadata and controls
159 lines (139 loc) · 6.45 KB
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
name: Code
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
packages: read
pull-requests: write # required for mshick/add-pr-comment
concurrency:
group: test_python_code_${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
run_natively:
name: 🛠 (native Python tests)
runs-on: ubuntu-latest
timeout-minutes: 25 # something is off if we need more than this
defaults:
run:
shell: bash -elo pipefail {0}
env:
# Some GitHub Actions runners (Azure VMs) expose an InfiniBand/MANA network
# device that UCX tries to use but cannot. Restrict UCX to TCP to
# prevent MPI_Init from aborting with "Operation not supported".
UCX_TLS: tcp,self,sm
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup
run: bash 00_setup.bash
- name: Run Python Tests
run: |-
source 01_activate_env.bash
pytest -v
- name: Store actual results as expected ones (on test failure)
if: failure()
run: |
rm -rf tests/expected_output
bash tests/update_expected_output_from_actual_output.bash
- name: Upload actual results (on failure)
if: ${{ failure() && !env.ACT }} # skip during local actions testing
id: upload_on_failure
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: actual_results_natively
path: tests/expected_output/
if-no-files-found: error
- name: Report test failures
if: ${{ always() && !env.ACT }} # skip during local actions testing
uses: mshick/add-pr-comment@ec328af66588ab8f77cdeb2c264f14aba45bbf59 # v3
with:
message-id: test_python_code_natively
refresh-message-position: true
message-failure: |-
Python Tests (🛠 [native execution](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/GETTING_STARTED.md) mode) failed in [test_python_code.yml](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/.github/workflows/test_python_code.yml) workflow, see [runs/${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!
See [tests/README.md](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/tests/README.md) on how to update expected results.
Downloaded [actual_results_natively.zip from this run](${{ steps.upload_on_failure.outputs.artifact-url }}) as `/tmp/actual_results_natively.zip` and execute the following to inspect locally:
```bash
cd tests/expected_output/
unzip -o /tmp/actual_results_natively.zip
cd -
pytest -v
```
delete-on-status: success
run_dockerised:
name: 🐳 (dockerised Python tests)
runs-on: ubuntu-latest
timeout-minutes: 25 # something is off if we need more than this
defaults:
run:
shell: bash -elo pipefail {0}
env:
# Some GitHub Actions runners (Azure VMs) expose an InfiniBand/MANA network
# device that UCX tries to use but cannot. Restrict UCX to TCP to
# prevent MPI_Init from aborting with "Operation not supported".
UCX_TLS: tcp,self,sm
COMPOSE_FILE: docker/docker-compose.yml
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Log in to GHCR
uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee # v4.2.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Detect Docker-related changes
id: detect
# Ensure to keep this in sync with the `path` field in the docker-publish.yml
run: |
if git diff --name-only origin/main -- \
docker/Dockerfile conda-linux-64.lock 00_setup.bash \
| grep -q .; then
echo "docker_changed=true" >> "$GITHUB_OUTPUT"
else
echo "docker_changed=false" >> "$GITHUB_OUTPUT"
fi
- name: Pull image (Docker setup unchanged)
if: steps.detect.outputs.docker_changed == 'false'
run: docker compose pull dev
- name: Build image (Docker setup changed)
if: steps.detect.outputs.docker_changed == 'true'
run: docker compose build dev
- name: Run Python Tests
run: docker compose run --rm dev pytest -v
- name: Store actual results as expected ones (on test failure)
if: failure()
run: |
rm -rf tests/expected_output
bash tests/update_expected_output_from_actual_output.bash
- name: Upload actual results (on failure)
if: ${{ failure() && !env.ACT }} # skip during local actions testing
id: upload_on_failure
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: actual_results_dockerised
path: tests/expected_output/
if-no-files-found: error
- name: Report test failures
if: ${{ always() && !env.ACT }} # skip during local actions testing
uses: mshick/add-pr-comment@ec328af66588ab8f77cdeb2c264f14aba45bbf59 # v3
with:
message-id: test_python_code_dockerised
refresh-message-position: true
message-failure: |-
Python Tests (🐳 [dockerised execution](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/GETTING_STARTED.md) mode) failed in [test_python_code.yml](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/.github/workflows/test_python_code.yml) workflow, see [runs/${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})!
See [tests/README.md](https://github.com/pymor/2026_paper_code/blob/${{ github.head_ref || github.ref_name }}/tests/README.md) on how to update expected results.
Downloaded [actual_results_dockerised.zip from this run](${{ steps.upload_on_failure.outputs.artifact-url }}) as `/tmp/actual_results_dockerised.zip` and execute the following to inspect locally:
```bash
cd tests/expected_output/
unzip -o /tmp/actual_results_dockerised.zip
cd -
CI=1 docker compose -f docker/docker-compose.yml run --rm dev pytest -v
```
delete-on-status: success