-
Notifications
You must be signed in to change notification settings - Fork 4
198 lines (175 loc) · 6.83 KB
/
test.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: Inyoka CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
env:
DEFAULT_BRANCH: 'refs/heads/staging'
REQUIREMENTS_FILE: extra/requirements/linux-py${{ matrix.python-version }}-development.txt
strategy:
matrix:
python-version: [3.9]
database: ['postgresql', 'sqlite']
include:
- python-version: 3.9
database: 'postgresql'
build_docs: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
# - name: Dump github.event.pull_request context
# env:
# GITHUB_CONTEXT: ${{ toJSON(github.event.pull_request) }}
# run: echo "$GITHUB_CONTEXT"
- name: Checkout theme from repo branch # (e.g. staging)
id: checkout-branch
continue-on-error: true
if: ${{ !github.event.pull_request }}
uses: actions/checkout@v4
with:
repository: inyokaproject/theme-ubuntuusers
ssh-key: ${{ secrets.SSH_KEY_THEME_UBUNTUUSERS }} # ssh key of inyokatestci, read only, see https://docs.github.com/en/actions/reference/encrypted-secrets
ref: ${{ github.ref }}
path: theme-ubuntuusers
persist-credentials: false
- name: Checkout theme in PR
id: checkout-pr
continue-on-error: true
if: ${{ github.event.pull_request }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.owner.login }}/theme-ubuntuusers
ssh-key: ${{ secrets.SSH_KEY_THEME_UBUNTUUSERS }}
ref: ${{ github.head_ref }}
path: theme-ubuntuusers
persist-credentials: false
- name: "Checkout fallback theme: repo theme-ubuntuusers, staging branch"
if: steps.checkout-branch.outcome == 'failure' || steps.checkout-pr.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: inyokaproject/theme-ubuntuusers
ssh-key: ${{ secrets.SSH_KEY_THEME_UBUNTUUSERS }}
ref: staging
path: theme-ubuntuusers
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache venv
id: cache-venv
uses: actions/cache@v4
with:
path: ~/venv/
key: ${{ runner.os }}-venv-py${{ matrix.python-version }}-${{ hashFiles(env.REQUIREMENTS_FILE) }}
- name: Build virtualenv
if: steps.cache-venv.outputs.cache-hit != 'true'
run: |
python -m venv ~/venv
. ~/venv/bin/activate
python -m pip install --upgrade pip
pip install --no-deps --require-hashes -r ${{ env.REQUIREMENTS_FILE }}
- name: Link theme
working-directory: ./theme-ubuntuusers
run: |
. ~/venv/bin/activate
pip install -e .
- name: Build static files
working-directory: ./theme-ubuntuusers
run: |
npm ci
npm run all
- name: Create inyoka settings
run: |
cp example_development_settings.py development_settings.py
sed -i "s/None/'supersecreteTest'/g" development_settings.py
sed -i "s/inyoka_theme_default/inyoka_theme_ubuntuusers/g" development_settings.py
- name: Start postgres
if: ${{ matrix.database == 'postgresql' }}
run: |
cat << '__EOF__' | sudo tee /etc/postgresql/14/main/pg_hba.conf > /dev/null
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
__EOF__
sudo systemctl start postgresql.service
pg_isready
- name: Install redis (server and cli)
run: |
sudo apt-get install redis-server
- name: Check for missing migrations (postgresql)
if: ${{ matrix.database == 'postgresql' }}
run: |
. ~/venv/bin/activate
python manage.py makemigrations --check --dry-run --settings tests.settings.${{ matrix.database }}_staticdbname
- name: Check for missing migrations (no postgresql)
if: ${{ matrix.database != 'postgresql' }}
run: |
. ~/venv/bin/activate
python manage.py makemigrations --check --dry-run --settings tests.settings.${{ matrix.database }}
- name: Run Tests
env:
PYTHONWARNINGS: 'always'
run: |
. ~/venv/bin/activate
coverage run manage.py test --settings tests.settings.${{ matrix.database }}
coverage html
- name: Compress coverage report
run: zip htmlcov.zip -r htmlcov
- name: Save coverage report for tests
uses: actions/upload-artifact@v4
with:
name: coverage-py${{ matrix.python-version }}-${{ matrix.database }}
path: htmlcov.zip
- name: Run BDD tests
if: ${{ matrix.database == 'postgresql' }}
env:
DJANGO_SETTINGS_MODULE: 'tests.bdd.settings.headless'
#PATH: '$PATH:/usr/lib/chromium-browser/'
COVERAGE_RCFILE: 'tests/bdd/settings/.coveragerc'
run: |
. ~/venv/bin/activate
cat << '__EOF__' | sudo tee -a /etc/hosts > /dev/null
127.0.0.1 ubuntuusers.local forum.ubuntuusers.local paste.ubuntuusers.local wiki.ubuntuusers.local planet.ubuntuusers.local ikhaya.ubuntuusers.local static.ubuntuusers.local media.ubuntuusers.local
__EOF__
python manage.py collectstatic --noinput
coverage run -m behave --tags=-skip
coverage html -d bdd_coverage
- name: Compress BDD results
if: ${{ matrix.database == 'postgresql' }}
run: zip bdd_coverage.zip -r bdd_coverage
- name: Save BDD results
if: ${{ matrix.database == 'postgresql' }}
uses: actions/upload-artifact@v4
with:
name: BDD-coverage-py${{ matrix.python-version }}-${{ matrix.database }}
path: bdd_coverage.zip
- name: Build documentation
if: ${{ matrix.build_docs }}
run: |
. ~/venv/bin/activate
make -C docs html
- name: Compress documentation
if: ${{ matrix.build_docs }}
run: zip doc.zip -r docs/build/html
- name: Save documentation
if: ${{ matrix.build_docs }}
uses: actions/upload-artifact@v4
with:
name: 'Inyoka_Documentation'
path: doc.zip
- name: Compress statics
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.build_docs }}
run: zip static-collected.zip -r inyoka/static-collected
- name: Save statics
if: ${{ startsWith(github.ref, 'refs/tags/') && matrix.build_docs }}
uses: actions/upload-artifact@v4
with:
name: 'Static_files'
path: static-collected.zip