Skip to content

CI

CI #4

Workflow file for this run

# Test and deploy
name: CI
on:
push:
branches:
- all
tags:
- "v*"
workflow_dispatch:
env:
OS: "linux"
PYTHON_VERSION: "3.10"
REQUIREMENTS_FILE: "requirements-all-linux-py3.10.txt"
jobs:
check:
name: "CI with ubuntu, py3.10, pip"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Install and upgrade"
run: |
python -m pip install --upgrade pip
python -m pip install black~=23.0 ruff
python -m pip install mypy
- name: "Format with black"
run: black --check --diff "."
- name: "Lint with ruff"
run: ruff --format=github "."
- name: "Type check with mypy"
run: mypy
# these libraries enable testing on Qt on linux
- uses: tlambert03/setup-qt-libs@v1
- uses: coactions/setup-xvfb@v1
- name: "Install napari-locan and dependencies"
run: |
python -m pip install .[test]
python -m pip install pip-tools
- name: "Run tests"
run: coverage run -m pytest --junitxml=./test-results-${{ env.PYTHON_VERSION }}.xml
- name: "Prepare coverage reports"
run: coverage xml
- name: "Check coverage"
run: coverage report --fail-under=90
- name: "Upload coverage to CodeCov"
if: ${{ github.ref == 'refs/heads/main' }}
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
files: coverage.xml
flags: unittests
name: "CodeCov report"
verbose: true
- name: "Freeze requirements"
run: pip-compile pyproject.toml --extra test --output-file ${{ env.REQUIREMENTS_FILE }}
- name: "Upload requirements file"
uses: actions/upload-artifact@v3
with:
name: ${{ env.REQUIREMENTS_FILE }}
path: ${{ env.REQUIREMENTS_FILE }}
deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
# github secrets
needs: [check]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python -m build .
twine upload dist/*