-
Notifications
You must be signed in to change notification settings - Fork 11
98 lines (87 loc) · 3.51 KB
/
ci.yml
File metadata and controls
98 lines (87 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
name: Run tests
on:
workflow_call:
secrets:
CODECOV_TOKEN:
required: true
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
sqlalchemy-version: ["sqlalchemy>=2,<3"]
services:
mariadb:
image: mariadb:10.6
env:
MARIADB_DATABASE: ispybtest
MARIADB_ROOT_PASSWORD: mariadb_root_pwd
ports:
- 3306:3306
options: --health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v4
- name: Use Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
set -eux
python -m pip install . -r ./requirements_dev.txt "${{ matrix.sqlalchemy-version }}"
- name: Get database
uses: actions/download-artifact@v4
with:
name: database
path: database/
- uses: shogo82148/actions-setup-mysql@v1
with:
distribution: "mariadb"
mysql-version: "10.6"
auto-start: false
- name: Set up test database
run: |
set -eu
cat > .my.cnf <<EOF
[client]
user = root
password = mariadb_root_pwd
host = 127.0.0.1
port = 3306
database = ispybtest
EOF
cp "./conf/config.example.cfg" "./conf/config.cfg"
cp "./conf/ws_config.example.cfg" "./conf/ws_config.cfg"
tar xfz "database/ispyb-database.tar.gz"
printf 'Waiting for MySQL database to accept connections'
until mariadb --defaults-file=.my.cnf -e "SHOW DATABASES" >/dev/null; do printf '.'; sleep 10; done
printf '\n'
mariadb --defaults-file=.my.cnf -e "SET GLOBAL log_bin_trust_function_creators = 1;"
for f in schemas/ispyb/tables.sql \
schemas/ispyb/lookups.sql \
schemas/ispyb/data.sql \
schemas/ispyb/routines.sql \
grants/ispyb_processing.sql \
grants/ispyb_import.sql; do
echo Importing ${f}...
mariadb --defaults-file=.my.cnf < $f
done
mariadb --defaults-file=.my.cnf -e "CREATE USER ispyb_api@'%' IDENTIFIED BY 'password_1234'; GRANT ispyb_processing to ispyb_api@'%'; GRANT ispyb_import to ispyb_api@'%'; SET DEFAULT ROLE ispyb_processing FOR ispyb_api@'%';"
mariadb --defaults-file=.my.cnf -e "CREATE USER ispyb_api_future@'%' IDENTIFIED BY 'password_4321'; GRANT SELECT ON ispybtest.* to ispyb_api_future@'%';"
mariadb --defaults-file=.my.cnf -e "CREATE USER ispyb_api_sqlalchemy@'%' IDENTIFIED BY 'password_5678'; GRANT SELECT ON ispybtest.* to ispyb_api_sqlalchemy@'%'; GRANT INSERT ON ispybtest.* to ispyb_api_sqlalchemy@'%'; GRANT UPDATE ON ispybtest.* to ispyb_api_sqlalchemy@'%';"
rm .my.cnf
- name: Run tests
run: |
export ISPYB_CREDENTIALS="./conf/config.cfg"
PYTHONDEVMODE=1 pytest tests -ra --cov=ispyb --cov-report=xml --cov-branch
- name: Upload to Codecov
uses: codecov/codecov-action@v4
with:
name: ${{ matrix.python-version }}
files: coverage.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
continue-on-error: true
timeout-minutes: 2