From c235782a94f0575573874d6abb171d2329b7c661 Mon Sep 17 00:00:00 2001 From: Stef Pletinck Date: Wed, 12 Mar 2025 15:05:08 +0100 Subject: [PATCH] Update workflows Includes CI checks, and automated PyPi trusted publishing --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++ .github/workflows/pypi.yml | 23 ++++++++++++++ .github/workflows/sphinx-documentation.yml | 4 +-- 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bf16884 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +# Basic CI setup: Lint with ruff, run tests with pytest +name: Test + +on: + pull_request: + push: + branches: + - main + +jobs: + # Do not lint for now, as the code is not yet compliant + #lint: + # name: Lint + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v4 + # - uses: astral-sh/setup-uv@v3 + # - name: Ruff lint + # run: uv run ruff check . + # - name: Ruff format + # run: uv run ruff format --diff . + # # This isn't a general Python lint, this style is just used in this repository + # - name: Prettier format + # run: npx prettier --prose-wrap always --check "**/*.md" + + test: + name: Run tests + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v3 + - run: uv run pytest diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..7e9c781 --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,23 @@ +name: Release + +on: + push: + tags: + # Publish on any tag starting with a `v`, e.g. v1.2.3 + - '*' + +jobs: + pypi: + name: Publish to PyPI + runs-on: ubuntu-latest + # Environment and permissions trusted publishing. + environment: + # Create this environment in the GitHub repository under Settings -> Environments + name: release + permissions: + id-token: write + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v3 + - run: uv build + - run: uv publish --trusted-publishing always diff --git a/.github/workflows/sphinx-documentation.yml b/.github/workflows/sphinx-documentation.yml index 5b09d1b..e370424 100644 --- a/.github/workflows/sphinx-documentation.yml +++ b/.github/workflows/sphinx-documentation.yml @@ -13,10 +13,10 @@ jobs: name: Sphinx documentation to GitHub pages steps: - uses: actions/checkout@v4 - - name: Installing the library + - name: Building HTML + uses: astral-sh/setup-uvv5 shell: bash -l {0} run: | - curl -LsSf https://astral.sh/uv/install.sh | sh uv run sphinx-build -M html docs/source/ docs/build/ - name: Deploy uses: peaceiris/actions-gh-pages@v4