Crude initial attempt to migrate to github-actions #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |