Skip to content

Merge pull request #245 from BCDA-APS/184-ophyd-registry #492

Merge pull request #245 from BCDA-APS/184-ophyd-registry

Merge pull request #245 from BCDA-APS/184-ophyd-registry #492

name: Unit Tests
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # allow manual triggering
defaults:
run:
shell: bash -l {0}
jobs:
lint:
name: Code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install Dependencies
run: |
which python
which pip
python -m pip install --upgrade pip
pip install flake8
- name: Run flake8
run: |
flake8
test-matrix:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
max-parallel: 5
steps:
- name: Set time zone
run: echo "TZ=America/Chicago" >> "$GITHUB_ENV"
- name: Checkout the project from GitHub
uses: actions/checkout@v3
- name: Diagnostics
run: |
echo $(pwd)
ls -lAFgh ./
echo "------------------"
ls -lAFgh "$(pwd)/bluesky/"
grep primary bluesky/user_group_permissions.yaml
- name: Create Python ${{ matrix.python-version }} environment
uses: mamba-org/setup-micromamba@v1
with:
cache-environment: true
cache-environment-key: env-key-${{ matrix.python-version }}
# channel-priority: flexible
environment-file: environment.yml
environment-name: anaconda-test-env-py-${{ matrix.python-version }}
create-args: >-
coveralls
pytest
pytest-cov
python=${{ matrix.python-version }}
setuptools-scm
- name: Initial Diagnostics
run: |
micromamba env list
micromamba info
micromamba list
conda config --show-sources
conda config --show
printenv | sort
- name: Directories before Docker
run: ls -lAFghrt ~/
- name: Start EPICS IOCs in Docker
run: |
bash ./.github/scripts/iocmgr.sh start GP gp
bash ./.github/scripts/iocmgr.sh start ADSIM ad
docker ps -a
ls -lAFgh /tmp/docker_ioc/iocad/
ls -lAFgh /tmp/docker_ioc/iocgp/
- name: Directories after Docker
run: ls -lAFghrt ~/
- name: Confirm EPICS is available with caget
run: |
which caget
caget gp:UPTIME
caget ad:cam1:Acquire_RBV
- name: Confirm EPICS IOC is available via PyEpics
run: |
which python
python -c "import epics; print(epics.caget('gp:UPTIME'))"
- name: Confirm EPICS IOC is available via ophyd
run: |
CMD="import ophyd"
CMD+="; up = ophyd.EpicsSignalRO('gp:UPTIME', name='up')"
CMD+="; up.wait_for_connection()"
CMD+="; print(up.get())"
python -c "${CMD}"
- name: Install Redis & screen
run: |
sudo apt-get install redis screen
- name: Run Bluesky queueserver
run: |
conda env list
pushd ./bluesky/
bash ./qserver.sh run &
# bash ./qserver.sh start
sleep 10
bash ./qserver.sh status
qserver status
popd
- name: Run tests with pytest & coverage
run: |
coverage run --concurrency=thread --parallel-mode -m pytest -vvv .
coverage combine
coverage report --precision 3
# - name: Gather coverage data from matrix run
# shell: bash -l {0}
# run: |
# micromamba list coveralls
# which coveralls
# coveralls debug
# coveralls --service=github
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# COVERALLS_FLAG_NAME: ${{ matrix.test-name }}
# COVERALLS_PARALLEL: true
# # https://coveralls-python.readthedocs.io/en/latest/usage/configuration.html#github-actions-support
# coveralls:
# name: Report unit test coverage to coveralls
# needs: test-matrix
# runs-on: ubuntu-latest
# container: python:3-slim
# steps:
# - name: Gather coverage and report to Coveralls
# run: |
# echo "Finally!"
# pip3 install --upgrade coveralls
# # debug mode: output prepared json and reported files list to stdout
# # https://coveralls-python.readthedocs.io/en/latest/troubleshooting.html
# # coveralls debug
# coveralls --service=github --finish
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}