Skip to content

Unit Tests

Unit Tests #514

Workflow file for this run

name: Unit Tests
on:
push:
pull_request:
workflow_dispatch:
schedule:
- cron: '00 6 * * *' # daily at 6AM UTC
jobs:
run_tests:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ${{ matrix.host-os }}
strategy:
matrix:
host-os: ["ubuntu-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Set env vars
run: |
export REPOSITORY_NAME=${GITHUB_REPOSITORY#*/} # just the repo, as opposed to org/repo
echo "REPOSITORY_NAME=${REPOSITORY_NAME}" >> $GITHUB_ENV
- name: Checkout the code
uses: actions/checkout@v3
# - name: Start MongoDB
# uses: supercharge/mongodb-github-action@1.6.0
# - name: Start Sirepo Docker container
# uses: NSLS-II/start-sirepo-action@v2
# with:
# docker-binary: docker
# - name: Copy databroker config file
# run: |
# set -vxeuo pipefail
# mkdir -v -p ~/.config/databroker/
# wget https://raw.githubusercontent.com/NSLS-II/sirepo-bluesky/main/examples/local.yml -O ~/.config/databroker/local.yml
# - name: Set up Python ${{ matrix.python-version }} with conda
# uses: conda-incubator/setup-miniconda@v2
# with:
# activate-environment: ${{ env.REPOSITORY_NAME }}-py${{ matrix.python-version }}
# auto-update-conda: true
# miniconda-version: "latest"
# python-version: ${{ matrix.python-version }}
# mamba-version: "*"
# channels: conda-forge
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install the package and its dependencies
run: |
# For reference: https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html.
set -vxeo pipefail
pip install --upgrade pip wheel
pip install -v .[dev]
pip list
- name: Test with pytest
run: |
set -vxeuo pipefail
coverage run -m pytest -vv -s
coverage report -m