-
Notifications
You must be signed in to change notification settings - Fork 10
83 lines (71 loc) · 2.93 KB
/
ci.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
on:
workflow_call:
inputs:
PYTHON_VERSION:
required: true
type: string
jobs:
test:
name: Build distribution and run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Python ${{ inputs.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.PYTHON_VERSION }}
- name: Get pre-built package
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Checkout sources
inputs:
archiveFilePatterns: "dist/package/repo-source.tar.gz"
destinationFolder: "./src"
- name: Install package
run: |
set -eux
pip install -r "./src/requirements_dev.txt"
pip install "./src"
- name: Set up test database
run: |
set -eu
cat >~/.my.cnf <<EOF
[client]
user=root
host=127.0.0.1
password=mysql_root_pwd
database=ispybtest
EOF
cp "./src/conf/config.example.cfg" "./src/conf/config.cfg"
cp "./src/conf/ws_config.example.cfg" "./src/conf/ws_config.cfg"
mkdir schema
cd schema
tar xfz "dist/package/ispyb-database.tar.gz"
printf 'Waiting for MySQL database to accept connections'
until mysql -e "SHOW DATABASES" >/dev/null; do printf '.'; sleep 0.5; done
printf '\n'
mysql -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}...
mysql < $f
done
mysql -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@'%';"
mysql -e "CREATE USER ispyb_api_future@'%' IDENTIFIED BY 'password_4321'; GRANT SELECT ON ispybtest.* to ispyb_api_future@'%';"
mysql -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="./src/conf/config.cfg"
PYTHONDEVMODE=1 pytest tests -ra --cov=ispyb --cov-report=xml --cov-branch
- name: Publish coverage stats
run: bash <(curl -s https://codecov.io/bash) -n "Python ${{ inputs.PYTHON_VERSION }}"
continue-on-error: true
working-directory: ./src
timeout-inutes: 2