Skip to content

Updated workflow and project #3

Updated workflow and project

Updated workflow and project #3

Workflow file for this run

name: CI
on:
push:
branches: ["**"]
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
package:
name: Build & inspect our package
runs-on: ubuntu-latest
env:
# Avoid local version identifiers in built packages
SETUPTOOLS_SCM_NO_LOCAL: "1"
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
test:
needs: [package]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9","3.10","3.11","3.12","3.13"]
name: Test on Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package + dev deps
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint (ruff)
run: |
ruff --version
ruff check can_waveshare tests --output-format=github || true
- name: Run tests
run: pytest -q
- name: Verify entry point is discoverable
run: |
python - <<'PY'
import importlib.metadata as md, can
eps = md.entry_points().select(group='can.interface')
names = {ep.name for ep in eps}
assert 'waveshare' in names, names
cls = [ep for ep in eps if ep.name == 'waveshare'][0].load()
assert issubclass(cls, can.BusABC), cls
print("Entry point present and loadable:", cls)
PY
- name: Build sdist & wheel
run: |
python -m pip install --upgrade build
python -m build
- name: Check install from wheel
run: |
pip install --force-reinstall --no-deps dist/*.whl
python - <<'PY'
import importlib.metadata as md, can
eps = md.entry_points().select(group='can.interface')
assert any(ep.name=='waveshare' for ep in eps), eps
print("Installed wheel exposes entry point OK.")
PY
test-pypi-upload:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: [test]
runs-on: ubuntu-latest
name: Upload to Test PyPI
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package + build deps
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
python -m pip install --upgrade build twine
- name: Build sdist & wheel
run: |
python -m build
- name: Publish release to PyPI
continue-on-error: true
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/