-
-
Notifications
You must be signed in to change notification settings - Fork 55
117 lines (115 loc) · 4.42 KB
/
test.yml
File metadata and controls
117 lines (115 loc) · 4.42 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
109
110
111
112
113
114
115
116
117
name: Test
on: [push, pull_request]
jobs:
test:
services:
postgres:
image: postgres:18.3-alpine@sha256:4da1a4828be12604092fa55311276f08f9224a74a62dcb4708bd7439e2a03911
ports:
- 5432: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
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: weblate
POSTGRES_DB: weblate
mariadb:
image: mariadb:10.11.16@sha256:8d9046cdb0b0961b3d2119bcb4bea62a185f11944be5968bc42b81d47801902e
env:
MARIADB_ROOT_PASSWORD: weblate
MARIADB_DATABASE: weblate
ports:
- 3306:3306
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
python-version:
- '3.11'
- '3.12'
- '3.13'
database:
- sqlite
- mariadb
- postgresql
name: Python ${{ matrix.python-version }}, ${{ matrix.database }}
env:
CI_DATABASE: ${{ matrix.database }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: true
fetch-depth: 0
- name: Install apt dependencies
# gettext is needed as Django uses msgfmt to compile MO files
run: |
sudo apt update
sudo apt install gettext
- name: Start validation service
env:
# renovate: datasource=github-releases depName=gflohr/e-invoice-eu-validator versioning=loose
VALIDATOR_VERSION: 2.16.4
run: |
curl -L "https://github.com/gflohr/e-invoice-eu-validator/releases/download/v$VALIDATOR_VERSION/validator-$VALIDATOR_VERSION-jar-with-dependencies.jar" > /tmp/validator.jar
PORT=7070 java -jar /tmp/validator.jar > /tmp/validator.log 2>&1 &
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: ${{ matrix.python-version }}
- uses: astral-sh/setup-uv@6ee6290f1cbc4156c0bdd66691b2c144ef8df19a # v7.4.0
with:
cache-suffix: test
version: 0.10.9
- name: Install pip dependencies
run: uv pip install --system -r requirements-dev.txt
- name: Compile MO files
run: ./scripts/generate-locales
- name: Collect static files
run: ./manage.py collectstatic
- name: Django checks
run: ./manage.py check
- name: Test with Django
env:
EINVOICE_VALIDATOR_URL: http://localhost:7070/
run: |
pytest --junitxml=junit.xml weblate_web
cp .coverage .coverage.pytest
- name: Migrations
run: |
# First version with database backends tests
git checkout 7ba420b18ec3c7d32fb71823335e068f15b96855
./manage.py migrate
./manage.py shell -c 'customer = Customer.objects.create(user_id=-1); payment = Payment.objects.create(customer=customer, amount=1); Payment.objects.create(customer=customer, amount=1, repeat=payment)'
EXISTING_PK=$(./manage.py dumpdata payments.Payment | jq '.[].pk' | tr -d - | sort)
EXISTING_REPEAT=$(./manage.py dumpdata payments.Payment | jq '.[].fields.repeat' | tr -d - | sort)
git checkout "$GITHUB_SHA"
coverage run ./manage.py migrate
NEW_PK=$(./manage.py dumpdata payments.Payment | jq '.[].pk' | tr -d - | sort)
NEW_REPEAT=$(./manage.py dumpdata payments.Payment | jq '.[].fields.repeat' | tr -d - | sort)
if [ "$NEW_PK" != "$EXISTING_PK" ] ; then
echo "Migration failed (pk): $NEW_PK != $EXISTING_PK"
exit 1
fi
if [ "$NEW_REPEAT" != "$EXISTING_REPEAT" ] ; then
echo "Migration failed (repeat): $NEW_REPEAT != $EXISTING_REPEAT"
exit 1
fi
- name: Coverage
run: |
coverage combine
coverage xml
- uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2
with:
token: ${{secrets.CODECOV_TOKEN}}
flags: unittests
name: Python ${{ matrix.python-version }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@0fa95f0e1eeaafde2c782583b36b28ad0d8c77d3 # v1.2.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Show validation logs
if: ${{ !cancelled() }}
run: cat /tmp/validator.log
permissions:
contents: read