Report PR changes phase B #5470
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
# Test straxen on each PR. | |
# We run three types of tests: | |
# - Pytest -> these are the "normal" tests and should be run for all | |
# python versions | |
# - Coveralls -> this is to see if we are covering all our lines of | |
# code with our tests. The results get uploaded to | |
# coveralls.io/github/XENONnT/straxen | |
# - pytest_no_database -> we want to make sure we can run the tests even | |
# if we don't have access to our database since this will e.g. happen | |
# when someone is pushing a PR from their own fork as we don't | |
# propagate our secrets there. | |
name: Test package | |
# Trigger this code when a new release is published | |
on: | |
workflow_dispatch: | |
release: | |
types: [ created ] | |
pull_request: | |
push: | |
branches: | |
- master | |
- stable | |
- development | |
jobs: | |
update: | |
name: "${{ matrix.test }}_py${{ matrix.python-version }}" | |
runs-on: ubuntu-latest | |
env: | |
HAVE_ACCESS_TO_SECTETS: ${{ secrets.RUNDB_API_URL }} | |
strategy: | |
fail-fast: False | |
matrix: | |
python-version: [ 3.8, 3.9, "3.10" ] | |
test: [ 'coveralls', 'pytest', 'pytest_no_database' ] | |
# Only run on py3.8. Py3.10 is quite slow, so no coveralls | |
exclude: | |
- python-version: "3.10" | |
test: coveralls | |
- python-version: 3.9 | |
test: pytest_no_database | |
- python-version: "3.10" | |
test: pytest_no_database | |
steps: | |
# Setup and installation | |
- name: Checkout repo | |
uses: actions/checkout@v4 | |
- name: Setup python | |
uses: actions/setup-python@v4.7.1 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install requirements | |
run: | | |
pip install -r extra_requirements/requirements-tests.txt | |
- name: Start MongoDB | |
uses: supercharge/mongodb-github-action@1.10.0 | |
with: | |
mongodb-version: 4.4.1 | |
- name: patch utilix file | |
# Secrets and required files | |
# Patch this file if we want to have access to the database | |
if: matrix.test != 'pytest_no_database' | |
run: bash .github/scripts/create_readonly_utilix_config.sh | |
env: | |
# RunDB | |
RUNDB_API_URL: ${{ secrets.RUNDB_API_URL }} | |
RUNDB_API_USER_READONLY: ${{ secrets.RUNDB_API_USER_READONLY }} | |
RUNDB_API_PASSWORD_READONLY: ${{ secrets.RUNDB_API_PASSWORD_READONLY}} | |
PYMONGO_URL: ${{ secrets.PYMONGO_URL }} | |
PYMONGO_USER: ${{ secrets.PYMONGO_USER }} | |
PYMONGO_PASSWORD: ${{ secrets.PYMONGO_PASSWORD }} | |
PYMONGO_DATABASE: ${{ secrets.PYMONGO_DATABASE }} | |
# SCADA | |
SCADA_URL: ${{ secrets.SCADA_URL }} | |
SCADA_VALUE_URL: ${{ secrets.SCADA_VALUE_URL }} | |
SCADA_USER: ${{ secrets.SCADA_USER }} | |
SCADA_LOGIN_URL: ${{ secrets.SCADA_LOGIN_URL }} | |
SCADA_PWD: ${{ secrets.SCADA_PWD }} | |
- name: Create pre-apply function file | |
# In case we do not have database. We need to make a local file for | |
# The pre_apply_function (see #559). | |
if: env.HAVE_ACCESS_TO_SECTETS == null || matrix.test == 'pytest_no_database' | |
run: bash .github/scripts/create_pre_apply_function.sh $HOME | |
- name: Test package | |
# This is running a normal test | |
if: (matrix.test == 'pytest_no_database' || matrix.test == 'pytest') | |
env: | |
ALLOW_WFSIM_TEST: 1 | |
TEST_MONGO_URI: 'mongodb://localhost:27017/' | |
run: | | |
coverage run --source=straxen -m pytest --durations 0 | |
coverage report | |
- name: Coveralls | |
# Make the coverage report and upload | |
env: | |
TEST_MONGO_URI: 'mongodb://localhost:27017/' | |
ALLOW_WFSIM_TEST: 1 | |
NUMBA_DISABLE_JIT: 1 | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
if: matrix.test == 'coveralls' && (github.actor != 'dependabot[bot]') && env.HAVE_ACCESS_TO_SECTETS != null | |
run: | | |
# Omit ./straxen/storage/rucio_remote.py since it's only tested in base_env | |
coverage run --source=straxen -m pytest -v | |
# Test notebooks | |
coverage run --append --source=straxen -m pytest -v --nbmake -n=auto notebooks/tutorials/SuperrunsExample.ipynb | |
coverage run --append --source=straxen -m pytest -v --nbmake -n=auto notebooks/tutorials/ScadaInterfaceExample.ipynb | |
# Run twice, once without and once with db access | |
if test -f ~/.xenon_config; then | |
rm ~/.xenon_config | |
fi | |
bash .github/scripts/create_pre_apply_function.sh $HOME | |
coverage run --append --source=straxen -m pytest -v | |
coveralls --service=github | |
- name: goodbye | |
run: echo "tests done, bye bye" |