-
Notifications
You must be signed in to change notification settings - Fork 4
198 lines (172 loc) · 5.13 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
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
191
192
193
194
195
196
197
198
name: Tests
on:
workflow_dispatch: # allow to run manually
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
jobs:
lint:
strategy:
fail-fast: false
runs-on: ubuntu-24.04
# we always use the latest container from the master branch
# this is fine because we still run all our installs just in case
container:
image: ghcr.io/onegov/onegov-cloud:master
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: Lint
steps:
- name: Install packages
run: |
apt-get update
apt-get install -y \
wget \
apparmor \
curl \
git-core \
postgresql \
redis \
openjdk-8-jre-headless \
gcc \
libc-dev \
fonts-liberation \
libappindicator3-1 \
libasound2t64 \
libdrm2 \
libgbm1 \
libnspr4 \
libnss3 \
libu2f-udev \
libvulkan1 \
libx11-xcb1 \
libxcb-dri3-0 \
libxshmfence1 \
libxss1 \
xdg-utils
- name: Checkout repo
uses: actions/checkout@v4
- name: Install dependencies
run: |
source /app/bin/activate
python -m pip install --upgrade uv
uv pip install .[mypy,lint]
- name: Linting
run: /app/bin/flake8 src/ tests/ stubs/
- name: Check security issues
run: /app/bin/bandit --recursive --configfile pyproject.toml src/
- name: Static type checking
run: |
source /app/bin/activate
bash mypy.sh
test:
strategy:
fail-fast: false
matrix:
group: [1, 2, 3, 4, 5, 6]
runs-on: ubuntu-24.04
# we always use the latest container from the master branch
# this is fine because we still run all our installs just in case
container:
image: ghcr.io/onegov/onegov-cloud:master
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
defaults:
run:
shell: bash
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
name: Test group ${{ matrix.group }}
steps:
- name: Install packages
run: |
apt-get update
apt-get install -y \
wget \
apparmor \
curl \
chromium-browser \
git-core \
postgresql \
redis \
openjdk-8-jre-headless \
gcc \
libc-dev \
fonts-liberation \
libappindicator3-1 \
libasound2t64 \
libdrm2 \
libgbm1 \
libnspr4 \
libnss3 \
libu2f-udev \
libvulkan1 \
libx11-xcb1 \
libxcb-dri3-0 \
libxshmfence1 \
libxss1 \
unzip \
xdg-utils
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
with:
# FIXME: Unpin once selenium works with newer version
chrome-version: 127
install-chromedriver: true
- name: Checkout repo
uses: actions/checkout@v4
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
run: |
echo "CODECOV_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" \
>> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
run: |
echo "CODECOV_BRANCH=$(echo ${GITHUB_HEAD_REF} | tr / -)" \
>> $GITHUB_ENV
- name: Install dependencies
run: |
source /app/bin/activate
python -m pip install --upgrade uv
uv pip install pytest-split pytest-cov pytest-codecov pytest-xdist psutil
# TEMPORARY: editable build so we don't need a path-fix in codecov
uv pip install -e .[test]
- name: Prepare test environment
run: |
# reset the build asset permissions
# TEMPORARY: if we no longer do an editable install, then the base
# path needs to change to /app/lib/
find . -type d -iname assets -print0 | xargs -0 chmod a+w -R
# add unprivileged test user
adduser --disabled-password --gecos "" test
redis-server --daemonize yes
- name: Run tests
run: |
run-as "$(id -u test)":test /app/bin/py.test \
-n logical \
-o cache_dir=/tmp/pytest \
--dist loadgroup \
--splits "6" \
--group "${{matrix.group}}" \
--cov \
--cov-config=pyproject.toml \
--codecov \
--codecov-branch="$CODECOV_BRANCH" \
--codecov-commit="$GITHUB_SHA" \
--codecov-slug=OneGov/onegov-cloud \
--codecov-token="${{ secrets.CODECOV_TOKEN }}" \
tests
env:
LC_ALL: C.UTF-8
LANG: C.UTF-8
JAVA_HOME: /usr/lib/jvm/java-8-openjdk-amd64
SKIP_DRIVER_MANAGER: '1'