-
Notifications
You must be signed in to change notification settings - Fork 9
108 lines (95 loc) · 3.51 KB
/
run_tests.yml
File metadata and controls
108 lines (95 loc) · 3.51 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
name: tests
on:
workflow_call:
secrets:
CODECOV_TOKEN:
description: 'Codecov token'
required: true
inputs:
build-tag:
required: true
type: string
jobs:
style:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install black
run: pip install black==22.8.0
- name: Style check
run : make style_check
migration_check:
runs-on: ubuntu-latest
services:
mysql:
image: mysql:8.0.30
ports:
- 8877:3306
# needed because the container does not provide a healthcheck
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root --entrypoint sh mysql:8.0.30 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
steps:
- name: Download artifacts (Docker images) from previous workflows
uses: actions/download-artifact@v4
with:
name: surface-tests
path: /tmp
- name: Load Docker images from previous workflows
run: docker load --input /tmp/myimage.tar
- name: Check for not-migrated changes in models
run: |
docker run --network host \
-e SURF_DATABASE_URL="mysql://root:root@127.0.0.1:8877/surface" \
ghcr.io/${{ github.repository }}:${{ inputs.build-tag }} \
sh -c './manage.py makemigrations --dry-run --check'
pytest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
database:
- db: mysql
url: mysql://root:root@127.0.0.1:8877/surface
- db: postgresql
url: psql://root:root@127.0.0.1:8878/surface
services:
mysql:
image: mysql:8.0.30
ports:
- 8877:3306
# needed because the container does not provide a healthcheck
options: --health-cmd "mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries=5 -e MYSQL_ROOT_PASSWORD=root --entrypoint sh mysql:8.0.30 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
postgres:
image: postgres:15
env:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: surface
ports:
- 8878:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Download artifacts (Docker images) from previous workflows
uses: actions/download-artifact@v4
with:
name: surface-tests
path: /tmp
- name: Load Docker images from previous workflows
run: docker load --input /tmp/myimage.tar
- name: run tests
run: |
docker run --network host \
-e SURF_DATABASE_URL=${{ matrix.database.url }} \
-v $(pwd)/cov/:/report \
ghcr.io/${{ github.repository }}:${{ inputs.build-tag }} \
sh -c 'pip install -r requirements_test.txt && pytest -n4 --cov --cov-report=xml:/report/coverage.xml'
- name: Publish CodeCov Report
uses: codecov/codecov-action@v4
with:
files: ./cov/coverage.xml
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}