-
Notifications
You must be signed in to change notification settings - Fork 5
159 lines (134 loc) · 4.66 KB
/
tests.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Tests
on:
pull_request:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PRIVATE_REPO_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_REPO_RO_TOKEN }}
STATA_LICENSE: ${{ secrets.STATA_LICENSE }}
jobs:
check:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: "actions/setup-python@v5"
with:
python-version: "3.8"
cache: "pip"
cache-dependency-path: requirements.*.txt
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Check formatting, linting and import sorting
run: just check
test-job:
strategy:
matrix:
os: [ubuntu-20.04, ubuntu-22.04, windows-2019, macos-12]
# Python 3.8 is what we currently support for running cohortextractor
# locally, and 3.9 is what we required for databuilder so we need to make
# sure we can run with those
python: ["3.8", "3.9", "3.10"]
runs-on: ${{ matrix.os }}
name: Run test suite
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: "pip"
cache-dependency-path: requirements.*.txt
- name: Set up default Python 3.8 for MacOS
if: ${{ matrix.os == 'macos-12' && matrix.python != '3.8' }}
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: requirements.*.txt
- name: install Docker/Colima on MacOS
if: ${{ matrix.os == 'macos-12' }}
run: brew install docker
- name: start Colima on MacOS
if: ${{ matrix.os == 'macos-12' }}
run: colima start
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Run actual tests on ${{ matrix.os }}
if: ${{ matrix.os == 'ubuntu-20.04' }}
run: just test -vvv
- name: Run actual tests on ${{ matrix.os }}
if: ${{ matrix.os == 'windows-2019' || matrix.os == 'macos-12' }}
run: just test-no-docker -vvv
test-package-build:
runs-on: ubuntu-20.04
name: Test we can build PyPI package
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: requirements.*.txt
# We need to set this to a valid version string in order to keep pip happy,
# but it doesn't really matter what version we use
- name: Set version
run: echo '1.0' > VERSION
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Check the wheel installs and runs
run: just package-test wheel
- name: Check the sdist installs and runs
run: just package-test sdist
test-docker:
runs-on: ubuntu-20.04
name: Test docker image
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Just
uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Build image
run: just docker/build
- name: Run tests in docker-image
run: just docker/test
test-github-workflow-output:
runs-on: ubuntu-20.04
name: Inspect test runner output in the context of a Github Workflow
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: 3.8
cache: "pip"
cache-dependency-path: requirements.*.txt
- uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d
- name: Install dependencies
run: just devenv
- name: Run equivalent command used by test runner
# We don't care if this command succeeds or not, we just want to be able
# to look at the output
run: |
python -m jobrunner.local_run run_all \
--project-dir=tests/fixtures/full_project \
--continue-on-error --timestamps --format-output-for-github \
|| true
required-checks:
if: always()
needs:
- check
- test-job
- test-package-build
- test-github-workflow-output
runs-on: Ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
with:
jobs: ${{ toJSON(needs) }}