forked from django/djangoproject.com
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (82 loc) · 3.68 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
name: Tests
on:
push:
branches:
- main
- fix/fixes-#1831
pull_request:
jobs:
tests:
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
# tox-gh-actions will only run the tox environments which match the currently
# running python-version. See [gh-actions] in tox.ini for the mapping.
python-version: ["3.12"]
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
python -m pip install -r requirements/tests.txt
- name: Set up databases
run: |
PGPASSWORD="postgres" createuser -U postgres -d djangoproject --superuser -h localhost
PGPASSWORD="postgres" createdb -U postgres -O djangoproject djangoproject -h localhost
PGPASSWORD="postgres" createuser -U postgres -d code.djangoproject --superuser -h localhost
PGPASSWORD="postgres" createdb -U postgres -O code.djangoproject code.djangoproject -h localhost
PGPASSWORD="postgres" psql -U postgres -h localhost -c "ALTER USER djangoproject WITH PASSWORD 'secret';"
PGPASSWORD="postgres" psql -U postgres -h localhost -c "ALTER USER \"code.djangoproject\" WITH PASSWORD 'secret';"
- name: Load Trac data
run: |
PGPASSWORD="postgres" psql -U postgres -d code.djangoproject -h localhost < tracdb/trac.sql
- name: Create secrets.json
working-directory: ..
run: |
mkdir conf
echo '{"db_host": "localhost", ' > conf/secrets.json
echo '"db_password": "secret", ' >> conf/secrets.json
echo '"trac_db_host": "localhost", ' >> conf/secrets.json
echo '"trac_db_password": "secret", ' >> conf/secrets.json
echo '"secret_key": "a"}' >> conf/secrets.json
- name: Run collectstatic with ManifestStaticFilesStorage
env:
DJANGO_SETTINGS_MODULE: "djangoproject.settings.dev"
run: |
python manage.py collectstatic --noinput || (
echo "Collectstatic failed. Debugging file paths..."
find staticfiles/ -type f -exec echo "Static file: {}" \;
exit 1
)
- name: Cleanup static files
run: |
rm -rf staticfiles/static
- name: Run tox
run: |
python -m tox
- name: Coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_PARALLEL: true
COVERALLS_FLAG_NAME: "${{ matrix.python-version }}"
COVERALLS_SERVICE_NAME: github
COVERALLS_SERVICE_JOB_ID: "${{ github.run_id }}"
COVERALLS_SERVICE_NUMBER: "${{ github.workflow }}-${{ github.run_number }}"
run: coveralls --service=github