Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions .github/actions/common-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,40 @@ inputs:
description: "Python version to setup"
required: true
default: "3.13"
poetry_version:
description: "Poetry version to setup"
required: true
default: "2.1.3"
runs:
using: "composite"
steps:
- name: Set up Python 🐍
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ inputs.python_version }}

- name: Default shell
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo shellos=bash >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "Windows" ]; then
echo shellos=powershell >> $GITHUB_ENV
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Poetry
uses: abatilo/actions-poetry@65c61eae400c65c9510a584af85138c1ae19bbc0 # v3.0.2
with:
poetry-version: 2.1.3
- name: Install poetry
run: pipx install poetry
shell: bash

# Cache your dependencies (i.e. all the stuff in your `pyproject.toml`). Note the cache
# key: if you're using multiple Python versions, or multiple OSes, you'd need to include
# them in the cache key. I'm not, so it can be simple and just depend on the poetry.lock.
- name: cache deps
id: cache-deps
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.cache/pypoetry
key: pydeps-${{ inputs.python_version }}-${{ env.shellos }}-${{ hashFiles('**/poetry.lock') }}
- name: Set up Python 🐍
id: setup-python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ inputs.python_version }}
cache: 'poetry'

# Install dependencies. `--no-root` means "install all dependencies but not the project
# itself", which is what you want to avoid caching _your_ code. The `if` statement
# ensures this only runs on a cache miss.
- name: Install dependencies
run: poetry install --no-interaction --no-root
shell: ${{ env.shellos }}
if: steps.cache-deps.outputs.cache-hit != 'true'
- name: Default shell
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
echo shellos=bash >> $GITHUB_ENV
elif [ "$RUNNER_OS" == "Windows" ]; then
echo shellos=powershell >> $GITHUB_ENV
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash

- name: Install project
run: poetry install --no-interaction
shell: ${{ env.shellos }}
# The 'setup-python' action with 'cache: poetry' installs dependencies but not the project
# itself. This step installs the project package into the created virtual environment.
- name: Install project
run: poetry install
shell: ${{ env.shellos }}
21 changes: 19 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,49 @@ jobs:
strategy:
matrix:
task: ["fmt", "lint"]
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: ./.github/actions/common-setup
with:
python_version: ${{ matrix.python-version }}

- name: check code
run: poetry run poe ${{ matrix.task }}

build:
needs: code_checks
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: ./.github/actions/common-setup
with:
python_version: ${{ matrix.python-version }}

- name: Build 🔨
run: poetry build

build_windows:
needs: code_checks
runs-on: windows-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: ./.github/actions/common-setup
with:
python_version: 3.13
python_version: ${{ matrix.python-version }}
poetry_version: 2.1.3

- name: Add entrypoint to bypass issue with relative imports in PyInstaller
run: powershell -Command 'Invoke-WebRequest https://gist.githubusercontent.com/Wenzel/e38d227d94f16e026b3aed03ea6a6661/raw/383ec56d62c58e444f6c5962ee6940a5c583d341/stub.py -OutFile stub.py'
Expand All @@ -56,6 +68,7 @@ jobs:
shell: bash

- name: Upload Windows release artefact
if: ${{ matrix.python-version == 3.13 }}
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: checksec.exe
Expand All @@ -67,10 +80,12 @@ jobs:
shell: bash

test:
needs: build
needs: ['build', 'build_windows']

strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
runs-on: ${{ matrix.os }}
defaults:
run:
Expand All @@ -82,6 +97,8 @@ jobs:
submodules: true

- uses: ./.github/actions/common-setup
with:
python_version: ${{ matrix.python-version }}

- name: Run tests
run: poetry run poe test_e2e
Expand Down
Loading