Skip to content

Code CI

Code CI #2022

Workflow file for this run

name: Code CI
on:
push:
pull_request:
schedule:
- cron: "00 4 * * *" # daily at 4AM
jobs:
lint:
# pull requests are a duplicate of a branch push if they are from within the
# same repo. Skip these
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
- name: Lint
run: pip install --user .[dev] && tox -e pre-commit
build:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: "ubuntu-latest"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # So we get history for version numbers
- name: Create Sdist and Wheel
# Set SOURCE_DATE_EPOCH from git commit for reproducible build
# https://reproducible-builds.org/
run: SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) pipx run build --sdist --wheel
- name: Upload Wheel and Sdist as artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- name: Install wheel and check cli works
run: pip install dist/*.whl && python -m ophyd --version
test:
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
prerelease: [false]
# Add one more job that runs on prereleases
include:
- python-version: "3.12"
prerelease: true
runs-on: ubuntu-latest
env:
TEST_CL: pyepics
defaults:
run:
shell: bash -leo pipefail {0}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # So we get history for version number
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade setuptools && pip install -e .[dev] && pipdeptree
- name: Install prereleases of certain dependencies.
run: |
pip install --upgrade --pre bluesky event-model
if: ${{ matrix.prerelease }}
- name: Start Docker
run: |
sudo systemctl start docker
docker version
docker compose --version
- name: Create AD data directories
run: |
mkdir -p /tmp/ophyd_AD_test/
python scripts/create_directories.py /tmp/ophyd_AD_test/data1
- name: Clone epics-services-for-ophyd
run: |
git clone https://github.com/bluesky/epics-services-for-ophyd.git ~/epics-services-for-ophyd
- name: Start docker containers
run: |
source ~/epics-services-for-ophyd/environment.sh
docker compose -f ~/epics-services-for-ophyd/compose.yaml up -d
- name: Wait for docker containers to start
run: |
sleep 20
- name: Test with pytest
run: |
source ~/epics-services-for-ophyd/environment.sh
pytest -k "${TEST_CL}"
- name: Print Docker Compose Logs
if: always()
run: |
docker compose -f ~/epics-services-for-ophyd/compose.yaml logs
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
name: ${{ matrix.python }}
files: cov.xml
release:
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
# upload to PyPI and make a release on every tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Github Release
# We pin to the SHA, not the tag, for security reasons.
# https://docs.github.com/en/actions/learn-github-actions/security-hardening-for-github-actions#using-third-party-actions
uses: softprops/action-gh-release@c95fe1489396fe8a9eb87c0abf8aa5b2ef267fda # v2.2.1 (2025-01-07)
with:
files: dist/*
generate_release_notes: true
token: ${{ secrets.RELEASE_ON_GH_TOKEN }}
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ./dist/