-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (125 loc) · 4.17 KB
/
reusable-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
name: Run tests
on:
pull_request:
types: [opened, edited, reopened, synchronize]
workflow_call:
jobs:
datahub-client-path-filter:
runs-on: ubuntu-latest
outputs:
datahub-client: ${{ steps.changes.outputs.datahub-client }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
datahub-client:
- 'lib/datahub-client/**'
datahub-client-tests:
name: Run datahub client tests
needs: datahub-client-path-filter
if: ${{ needs.datahub-client-path-filter.outputs.datahub-client == 'true' }}
runs-on: ubuntu-latest
defaults:
run:
working-directory: lib/datahub-client
strategy:
fail-fast: false
max-parallel: 4
matrix:
python-version:
- "3.10"
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
- name: Install poetry
run: pipx install poetry
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: ${{ matrix.python-version }}
cache: poetry
cache-dependency-path: lib/datahub-client/poetry.lock
- name: Poetry install
run: |
poetry install
- name: Run tests
run: |
poetry run pytest
app-unit-tests:
name: Django app unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f
with:
python-version: "3.11"
cache: poetry
cache-dependency-path: ./poetry.lock
- name: Install project
run: poetry install --no-interaction --no-root
- name: Install compilemessages prereqs
run: sudo apt-get install gettext
- name: Make compilemessages
run: make compilemessages
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install npm dependencies
id: install_dependencies
run: npm install
- name: Collect static files
run: poetry run python manage.py collectstatic --no-input
- name: Run unit tests with coverage
id: fast-tests
run: TESTING=True make gha_fast_tests
- name: Set up chromedriver
# https://github.com/marketplace/actions/setup-chromedriver
uses: nanasess/[email protected]
- name: Run integration tests
id: slow-tests
if: steps.fast-tests.outcome == 'success'
run: TESTING=True poetry run pytest tests/integration --axe-version 4.9.1 --chromedriver-path /usr/local/bin/chromedriver
javascript-only-tests:
name: Javascript tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
- name: Get npm cache directory
id: npm-cache-dir
shell: bash
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- name: Load cached npm
uses: actions/cache@v4
id: npm-cache
with:
path: ${{ steps.npm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
id: install_dependencies
run: npm install
- name: Run javascript tests
run: npm test