forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (166 loc) · 5.38 KB
/
tests.yml
File metadata and controls
190 lines (166 loc) · 5.38 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Reusable Tests Workflow
on:
workflow_call:
inputs:
ignoreLowerCoverage:
description: 'Ignore Lower Coverage'
default: false
required: true
type: boolean
skipSelenium:
description: 'Skip Selenium Tests'
default: false
required: false
type: boolean
targetBaseVersion:
description: 'Target Base Image Version'
default: latest
required: false
type: string
jobs:
tests-python:
name: Python Tests
runs-on: ubuntu-latest
container: ghcr.io/ietf-tools/datatracker-app-base:${{ inputs.targetBaseVersion }}
services:
db:
image: ghcr.io/ietf-tools/datatracker-db:latest
blobstore:
image: ghcr.io/ietf-tools/datatracker-devblobstore:latest
steps:
- uses: actions/checkout@v6
- name: Prepare for tests
run: |
chmod +x ./dev/tests/prepare.sh
sh ./dev/tests/prepare.sh
- name: Ensure DB is ready
run: |
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
- name: Run all tests
shell: bash
run: |
echo "Running checks..."
./ietf/manage.py check
./ietf/manage.py migrate --fake-initial
echo "Validating migrations..."
if ! ( ietf/manage.py makemigrations --dry-run --check --verbosity 3 ) ; then
echo "Model changes without migrations found."
exit 1
fi
if [[ "x${{ inputs.skipSelenium }}" == "xtrue" ]]; then
echo "Disable selenium tests..."
rm /usr/bin/geckodriver
fi
echo "Running tests..."
if [[ "x${{ inputs.ignoreLowerCoverage }}" == "xtrue" ]]; then
echo "Lower coverage failures will be ignored."
HOME=/root ./ietf/manage.py test -v2 --validate-html-harder --settings=settings_test --ignore-lower-coverage
else
HOME=/root ./ietf/manage.py test -v2 --validate-html-harder --settings=settings_test
fi
coverage xml
- name: Upload geckodriver.log
uses: actions/upload-artifact@v7
if: ${{ failure() }}
with:
name: geckodriverlog
path: geckodriver.log
- name: Upload Coverage Results to Codecov
uses: codecov/codecov-action@v6
with:
disable_search: true
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
- name: Convert Coverage Results
if: ${{ always() }}
run: |
mv latest-coverage.json coverage.json
- name: Upload Coverage Results as Build Artifact
uses: actions/upload-artifact@v7
if: ${{ always() }}
with:
name: coverage
path: coverage.json
tests-playwright:
name: Playwright Tests
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
project: [chromium, firefox]
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '18'
- name: Run all tests
run: |
echo "Installing dependencies..."
yarn
echo "Installing Playwright..."
cd playwright
mkdir test-results
npm ci
npx playwright install --with-deps ${{ matrix.project }}
echo "Running tests..."
npx playwright test --project=${{ matrix.project }}
- name: Upload Report
uses: actions/upload-artifact@v7
if: ${{ always() }}
continue-on-error: true
with:
name: playwright-results-${{ matrix.project }}
path: playwright/test-results/
if-no-files-found: ignore
tests-playwright-legacy:
if: ${{ false }} # disable until we sort out suspected test runner issue
name: Playwright Legacy Tests
runs-on: ubuntu-latest
container: ghcr.io/ietf-tools/datatracker-app-base:${{ inputs.targetBaseVersion }}
strategy:
fail-fast: false
matrix:
project: [chromium, firefox]
services:
db:
image: ghcr.io/ietf-tools/datatracker-db:latest
steps:
- uses: actions/checkout@v6
- name: Prepare for tests
run: |
chmod +x ./dev/tests/prepare.sh
sh ./dev/tests/prepare.sh
- name: Ensure DB is ready
run: |
/usr/local/bin/wait-for db:5432 -- echo "DB ready"
- name: Start Datatracker
run: |
echo "Running checks..."
./ietf/manage.py check
./ietf/manage.py migrate --fake-initial
echo "Starting datatracker..."
./ietf/manage.py runserver 0.0.0.0:8000 --settings=settings_local &
echo "Waiting for datatracker to be ready..."
/usr/local/bin/wait-for localhost:8000 -- echo "Datatracker ready"
- name: Run all tests
env:
# Required to get firefox to run as root:
HOME: ""
run: |
echo "Installing dependencies..."
yarn
echo "Installing Playwright..."
cd playwright
mkdir test-results
npm ci
npx playwright install --with-deps ${{ matrix.project }}
echo "Running tests..."
npx playwright test --project=${{ matrix.project }} -c playwright-legacy.config.js
- name: Upload Report
uses: actions/upload-artifact@v7
if: ${{ always() }}
continue-on-error: true
with:
name: playwright-legacy-results-${{ matrix.project }}
path: playwright/test-results/
if-no-files-found: ignore