| 1 |
--- |
| 2 |
name: CI |
| 3 |
|
| 4 |
# yamllint disable-line rule:truthy |
| 5 |
on: |
| 6 |
push: |
| 7 |
branches: |
| 8 |
- main |
| 9 |
pull_request: |
| 10 |
workflow_dispatch: |
| 11 |
|
| 12 |
jobs: |
| 13 |
pre-commit: |
| 14 |
name: pre-commit |
| 15 |
runs-on: ubuntu-latest |
| 16 |
env: |
| 17 |
PRE_COMMIT_HOME: /tmp/pre-commit-cache |
| 18 |
steps: |
| 19 |
- name: โคต๏ธ Check out code from GitHub |
| 20 |
uses: actions/checkout@v4 |
| 21 |
- name: ๐ Set up uv |
| 22 |
uses: astral-sh/setup-uv@v5 |
| 23 |
with: |
| 24 |
enable-cache: true |
| 25 |
- name: ๐ Set up Python |
| 26 |
run: uv python install |
| 27 |
- name: ๐ Set pre-commit cache |
| 28 |
uses: actions/cache@v4 |
| 29 |
with: |
| 30 |
path: ${{ env.PRE_COMMIT_HOME }} |
| 31 |
key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml','.python-version') }} |
| 32 |
- name: ๐ Run pre-commit |
| 33 |
env: |
| 34 |
# Skipping branch check and pytest as pytest is run in a separate job |
| 35 |
SKIP: no-commit-to-branch,pytest |
| 36 |
run: uv run --frozen pre-commit run -a |
| 37 |
|
| 38 |
pytest: |
| 39 |
name: pytest |
| 40 |
runs-on: ubuntu-latest |
| 41 |
strategy: |
| 42 |
fail-fast: false |
| 43 |
matrix: |
| 44 |
python: ["3.13", "3.14"] |
| 45 |
env: |
| 46 |
# Force uv to use the matrix interpreter rather than the version |
| 47 |
# pinned in .python-version. |
| 48 |
UV_PYTHON: ${{ matrix.python }} |
| 49 |
steps: |
| 50 |
- name: โคต๏ธ Check out code from GitHub |
| 51 |
uses: actions/checkout@v4 |
| 52 |
- name: ๐ Set up uv |
| 53 |
uses: astral-sh/setup-uv@v5 |
| 54 |
with: |
| 55 |
enable-cache: true |
| 56 |
- name: ๐ Set up Python ${{ matrix.python }} |
| 57 |
run: uv python install ${{ matrix.python }} |
| 58 |
- name: ๐ Install dependencies |
| 59 |
run: uv sync --frozen --dev |
| 60 |
- name: ๐ Run pytest |
| 61 |
run: uv run pytest tests |
| 62 |
- name: โฌ๏ธ Upload coverage artifact |
| 63 |
uses: actions/upload-artifact@v4 |
| 64 |
with: |
| 65 |
include-hidden-files: true |
| 66 |
name: coverage-${{ matrix.python }} |
| 67 |
path: .coverage |
| 68 |
|
| 69 |
coverage: |
| 70 |
runs-on: ubuntu-latest |
| 71 |
needs: pytest |
| 72 |
steps: |
| 73 |
- name: โคต๏ธ Check out code from GitHub |
| 74 |
uses: actions/checkout@v4 |
| 75 |
with: |
| 76 |
fetch-depth: 0 |
| 77 |
- name: โฌ๏ธ Download coverage data |
| 78 |
uses: actions/download-artifact@v4 |
| 79 |
- name: ๐ Set up uv |
| 80 |
uses: astral-sh/setup-uv@v5 |
| 81 |
with: |
| 82 |
enable-cache: true |
| 83 |
- name: ๐ Set up Python |
| 84 |
run: uv python install |
| 85 |
- name: ๐ Install dependencies |
| 86 |
run: uv sync --frozen --dev |
| 87 |
- name: ๐ Process coverage results |
| 88 |
run: | |
| 89 |
uv run --frozen coverage combine coverage*/.coverage* |
| 90 |
uv run --frozen coverage xml -i |
| 91 |
- name: โฌ๏ธ Upload coverage report |
| 92 |
uses: codecov/codecov-action@v5 |
| 93 |
with: |
| 94 |
fail_ci_if_error: false |
| 95 |
|
| 96 |
build: |
| 97 |
name: build |
| 98 |
runs-on: ubuntu-latest |
| 99 |
steps: |
| 100 |
- name: โคต๏ธ Check out code from GitHub |
| 101 |
uses: actions/checkout@v4 |
| 102 |
- name: ๐ Set up uv |
| 103 |
uses: astral-sh/setup-uv@v5 |
| 104 |
with: |
| 105 |
enable-cache: true |
| 106 |
- name: ๐ Set up Python |
| 107 |
run: uv python install |
| 108 |
- name: ๐ Build sdist and wheel |
| 109 |
run: uv build |
| 110 |
- name: ๐งช Install built wheel and import package |
| 111 |
run: | |
| 112 |
uv venv /tmp/install-test |
| 113 |
uv pip install --python /tmp/install-test/bin/python dist/*.whl |
| 114 |
/tmp/install-test/bin/python -c "import iotawattpy; print(iotawattpy.__file__)" |
| 115 |
- name: โฌ๏ธ Upload build artifacts |
| 116 |
uses: actions/upload-artifact@v4 |
| 117 |
with: |
| 118 |
name: dist |
| 119 |
path: dist/ |