forked from pretalx/pretalx
-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (129 loc) · 4.7 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
name: Tests
on:
push:
branches: [ main ]
paths-ignore:
- 'doc/**'
- 'src/pretalx/locale/**'
pull_request:
branches: [ main ]
paths-ignore:
- 'doc/**'
- 'src/pretalx/locale/**'
permissions:
contents: write
checks: write
pull-requests: write
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
FORCE_COLOR: 1
jobs:
test:
runs-on: ubuntu-latest
name: Tests
strategy:
fail-fast: false
matrix:
python-version: ['3.10', 3.11, 3.12]
database: [sqlite, postgres]
exclude:
- database: sqlite
python-version: '3.10'
- database: sqlite
python-version: '3.11'
steps:
- uses: actions/checkout@v4
- uses: harmon758/postgresql-action@v1
with:
postgresql version: '14'
postgresql db: 'pretalx'
postgresql user: 'postgres'
postgresql password: 'postgres'
if: matrix.database == 'postgres'
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 'latest'
- name: Install system dependencies
run: |
sudo apt update
sudo apt install gettext
- name: Install Python dependencies
run: python -m pip install -Ue ".[dev]"
- name: Install Postgres dependencies
run: python -m pip install -Ue ".[postgres]"
if: matrix.database == 'postgres'
- name: Install frontend dependencies
run: npm ci
working-directory: ./src/pretalx/frontend/schedule-editor
- name: Run checks
run: python manage.py check --deploy
working-directory: ./src
- name: Run checks
run: python manage.py compilemessages
working-directory: ./src
- name: Run tests
working-directory: ./src
run: |
# tee will gobble up our exit code without pipefail
set -o pipefail
python -m pytest \
-nauto -p no:sugar \
--junitxml=pytest.xml \
--reruns 3 \
--cov-report=term-missing:skip-covered \
tests | tee pytest-coverage.txt
env:
PRETALX_CONFIG_FILE: 'tests/ci_${{ matrix.database }}.cfg'
- name: Coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./src/pytest-coverage.txt
junitxml-path: ./src/pytest.xml
junitxml-title: Test summary
report-only-changed-files: true
title: Full coverage report
if: always() && matrix.database == 'postgres' && matrix.python-version == '3.12' && github.event_name == 'pull_request'
- name: Coverage data (non-PR, do not comment)
id: coverageData
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./src/pytest-coverage.txt
junitxml-path: ./src/pytest.xml
junitxml-title: Test summary
report-only-changed-files: true
hide-comment: true
title: Full coverage report
if: always() && matrix.database == 'postgres' && matrix.python-version == '3.12' && github.event_name != 'pull_request'
- name: Show coverage as build info
working-directory: ./src
shell: bash # needed to make echo work as expected
run: |
python -m coverage json
export TOTAL_COV=$(python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "TOTAL_COV=$TOTAL_COV" >> $GITHUB_ENV
echo "## Test coverage: $TOTAL_COV%" >> $GITHUB_STEP_SUMMARY
echo ${{ steps.coverageData.outputs.summaryReport }} >> $GITHUB_STEP_SUMMARY
echo ${{ steps.coverageComment.outputs.summaryReport }} >> $GITHUB_STEP_SUMMARY
python -m coverage report --skip-covered --skip-empty --show-missing --format=markdown >> $GITHUB_STEP_SUMMARY
python -m coverage report
if: always() && matrix.database == 'postgres' && matrix.python-version == '3.12'
- name: "Make badge"
uses: schneegans/[email protected]
with:
# GIST_TOKEN is a GitHub personal access token with scope "gist".
auth: ${{ secrets.GIST_TOKEN }}
gistID: 0ac3e4314d780e809c0164c8c329f36f
filename: covbadge.json
label: coverage
message: ${{ env.TOTAL_COV }}%
color: "#3aa57c"
if: env.TOTAL_COV && github.ref == 'refs/heads/main'