CI #66
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: | |
- main | |
- dev | |
paths: | |
- "**/*.py" | |
- ".github/workflows/**" | |
- "pyproject.toml" | |
- "uv.lock" | |
pull_request: | |
paths: | |
- "**/*.py" | |
- ".github/workflows/**" | |
- "pyproject.toml" | |
- "uv.lock" | |
schedule: | |
- cron: "0 0 * * *" | |
env: | |
DEFAULT_PYTHON_VERSION: 3.13 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
prepare: | |
name: Preparation | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up UV and Python | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Install the project | |
run: uv sync --all-groups | |
ruff-format: | |
name: Ruff Format | |
needs: prepare | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up UV and Python | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Install the project | |
run: uv sync --all-groups | |
- name: Run Ruff Format | |
run: uv run pre-commit run --hook-stage manual ruff-format --all-files --show-diff-on-failure | |
ruff-check: | |
name: Ruff Check | |
needs: prepare | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up UV and Python | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Install the project | |
run: uv sync --all-groups | |
- name: Run Ruff Check | |
run: uv run pre-commit run --hook-stage manual ruff-check --all-files --show-diff-on-failure | |
unit-tests: | |
name: Unit Tests | |
needs: | |
- ruff-format | |
- ruff-check | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Set up UV and Python | |
uses: astral-sh/setup-uv@v6 | |
with: | |
python-version: ${{ env.DEFAULT_PYTHON_VERSION }} | |
enable-cache: true | |
cache-dependency-glob: "uv.lock" | |
- name: Install the project | |
run: uv sync --all-groups | |
- name: Run unit tests | |
run: | | |
uv run pytest --cov=asusrouter --cov-report=xml:unit-tests-cov-${{ env.DEFAULT_PYTHON_VERSION }}.xml | |
- name: Upload coverage to artifacts | |
uses: actions/[email protected] | |
with: | |
name: unit-tests-cov-${{ env.DEFAULT_PYTHON_VERSION }} | |
path: unit-tests-cov-${{ env.DEFAULT_PYTHON_VERSION }}.xml | |
codecov: | |
name: Codecov | |
needs: [unit-tests] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
checks: write | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Download unit-tests coverage from artifacts | |
uses: actions/download-artifact@v5 | |
with: | |
name: unit-tests-cov-${{ env.DEFAULT_PYTHON_VERSION }} | |
path: . | |
- name: Upload coverage to Codecov | |
uses: codecov/[email protected] | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
fail_ci_if_error: true | |
files: unit-tests-cov-${{ env.DEFAULT_PYTHON_VERSION }}.xml |