Skip to content

Commit

Permalink
Updating workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
tomarnepedersen committed Jan 8, 2025
1 parent 1c2a277 commit 92a355f
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 192 deletions.
27 changes: 12 additions & 15 deletions .github/workflows/_build_and_publish_documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,18 @@ jobs:
- name: Checkout active branch
uses: actions/checkout@v4
with:
fetch-depth: 1
lfs: true
- name: Install Python
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- uses: actions/download-artifact@v4
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
name: requirements-files
- name: Install dependencies
run: |
pip install -r requirements-docs.txt
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --upgrade
- name: Print debugging information
run: |
echo "github.ref:" ${{github.ref}}
Expand All @@ -39,17 +38,15 @@ jobs:
git branch
git branch -a
git remote -v
python -V
pip list --not-required
pip list
uv run python -V
uv pip list
# Build documentation
- uses: sphinx-doc/github-problem-matcher@master
- name: Build documentation
run: |
cd docs
sphinx-apidoc -f -e -M -o . ../src/trafficgen
make html
uv run make html
- name: Clone and cleanup gh-pages branch
run: |
Expand Down
49 changes: 12 additions & 37 deletions .github/workflows/_build_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,21 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
lfs: true
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- name: Install build and twine
run: pip install build twine
- name: Run build
run: python -m build
python-version-file: "pyproject.toml"
- name: Build source distribution and wheel
run: uv build
- name: Run twine check
run: twine check --strict dist/*
run: uvx twine check --strict dist/*
- uses: actions/upload-artifact@v4
with:
path: ./dist/*.tar.gz

# build_wheels:
# name: Build wheels for ${{ matrix.platform }}
# needs:
# - black
# - ruff
# - pyright
# - test
# runs-on: ${{ matrix.platform }}
# strategy:
# matrix:
# platform: [ubuntu-latest, macos-latest, windows-latest]
# steps:
# - uses: actions/checkout@v4
# with:
# fetch-depth: 1
# lfs: true
# - uses: actions/setup-python@v5
# with:
# python-version: '3.11'
# cache: 'pip' # cache pip dependencies
# - name: Install cibuildwheel
# run: python -m pip install cibuildwheel==2.16
# - name: Build wheels
# run: python -m cibuildwheel --output-dir wheels
# - uses: actions/upload-artifact@v4
# with:
# path: ./wheels/*.whl
path: |
dist/*.tar.gz
dist/*.whl
97 changes: 60 additions & 37 deletions .github/workflows/_code_quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,78 @@ name: Code Quality
on: workflow_call

jobs:
black:
name: black
ruff_format:
runs-on: ubuntu-latest
name: ruff format
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
options: '--check --diff'
src: '.'
jupyter: true
version: '==23.12'
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --upgrade
- name: Run ruff format
run: uv run ruff format --diff

ruff:
ruff_check:
runs-on: ubuntu-latest
name: ruff
name: ruff check
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- uses: actions/download-artifact@v4
with:
name: requirements-files
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Install ruff
run: pip install ruff==0.1.8
- name: Run ruff
run: ruff .
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --upgrade
- name: Run ruff check
run: uv run ruff check --diff

pyright:
runs-on: ubuntu-latest
name: pyright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip' # cache pip dependencies
- uses: actions/download-artifact@v4
with:
name: requirements-files
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pytest
- name: Install pyright
run: pip install pyright==1.1.338
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --upgrade
- name: Run pyright
run: pyright .
run: uv run pyright

mypy:
runs-on: ubuntu-latest
name: mypy
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: "pyproject.toml"
- name: Install the project
run: uv sync --upgrade
- name: Run mypy
run: uv run mypy
8 changes: 7 additions & 1 deletion .github/workflows/_merge_into_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ jobs:
with:
type: now
target_branch: release
github_token: ${{ secrets.RELEASE_TOKEN }}
# @TODO: A dedicated RELEASE_TOKEN should be created in the repo settings
# and used for this task when in production.
# It is set here to the default GITHUB_TOKEN only
# for demonstration purposes, enabling the workflow in the repo template
# to run without additional configuration.
# github_token: ${{ secrets.RELEASE_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
34 changes: 0 additions & 34 deletions .github/workflows/_requirements_files.yml

This file was deleted.

24 changes: 12 additions & 12 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@ on: workflow_call

jobs:
test:
name: Test on ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}}
name: Test on ${{matrix.python.version}}-${{matrix.platform.runner}}
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
toxenv: linux
- runner: windows-latest
toxenv: windows
# - runner: macos-latest
python:
- version: '3.9'
toxenv: 'py39'
- version: '3.10'
toxenv: 'py310'
- version: '3.11'
toxenv: 'py311'
- version: '3.12'
toxenv: 'py312'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Python ${{ matrix.python.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
cache: 'pip' # cache pip dependencies
- name: Install tox
run: python -m pip install tox
- name: Install the project
run: uv sync -p ${{ matrix.python.version }} -U --no-dev
- name: Run pytest
run: tox -e ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}}
run: >
uv run --with pytest --with pytest-cov
pytest --cov
28 changes: 16 additions & 12 deletions .github/workflows/_test_future.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
name: Unit Tests (py312)
# Test also with Python 3.12 (experimental; workflow will not fail on error.)
name: Unit Tests (py313)
# Test also with Python 3.13 (experimental; workflow will not fail on error.)

on: workflow_call

jobs:
test312:
name: Test on ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}} (experimental)
test313:
name: Test on ${{matrix.python.version}}-${{matrix.platform.runner}} (experimental)
continue-on-error: true
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-latest
toxenv: linux
- runner: windows-latest
toxenv: windows
python:
- version: '3.13.0a2'
toxenv: 'py313'
- version: '3.13.0-alpha - 3.13.0'
uvpy: '3.13'
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v2
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install Python ${{ matrix.python.version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python.version }}
cache: 'pip' # cache pip dependencies
- name: Install tox
run: python -m pip install tox
- name: Install the project
run: uv sync -p ${{ matrix.python.uvpy }} -U --no-dev
- name: Run pytest
run: tox -e ${{matrix.python.toxenv}}-${{matrix.platform.toxenv}}
run: >
uv run --with pytest --with pytest-cov
pytest --cov
6 changes: 0 additions & 6 deletions .github/workflows/nightly_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@ on:
- cron: '30 5 * * *'

jobs:
requirements_files:
uses: ./.github/workflows/_requirements_files.yml
code_quality:
needs: requirements_files
uses: ./.github/workflows/_code_quality.yml
test:
needs: requirements_files
uses: ./.github/workflows/_test.yml
test_future:
needs: requirements_files
uses: ./.github/workflows/_test_future.yml
build_package:
needs:
- code_quality
- test
uses: ./.github/workflows/_build_package.yml
build_and_publish_documentation:
Expand Down
Loading

0 comments on commit 92a355f

Please sign in to comment.