Skip to content

Commit

Permalink
Setup reusable poetry workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
drmikehenry committed May 6, 2024
1 parent 4a2c63c commit e7a8775
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 67 deletions.
43 changes: 43 additions & 0 deletions .github/actions/setup-poetry-nox/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: setup-poetry-nox
description: Setup Python, Poetry, and Nox

inputs:
python-version:
description: Python version
required: false
default: "3.11"
poetry-version:
description: Poetry version
required: false
default: "1.8.2"
poetry-plugin-export-version:
description: poetry-plugin-export version
required: false
default: "1.7.1"

runs:
using: "composite"
steps:
- name: Install poetry
run: pipx install "poetry==${{ inputs.poetry-version }}"
shell: bash

- name: Install poetry-plugin-export
run: pipx inject poetry
"poetry-plugin-export==${{ inputs.poetry-plugin-export-version }}"
shell: bash

- name: Disable poetry warning about poetry-plugin-export
run: poetry config warnings.export false
shell: bash

- name: Set up Python "${{ inputs.python-version }}"
uses: actions/setup-python@v5
with:
python-version: "${{ inputs.python-version }}"
# https://github.com/actions/setup-python#caching-packages-dependencies
cache: poetry

- name: Install Nox
run: poetry install --only nox
shell: bash
24 changes: 2 additions & 22 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,17 @@ name: build

on: [push]

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.8.2"
POETRY_PLUGIN_EXPORT_VERSION: "1.7.1"

jobs:
build-executable:
strategy:
matrix:
os: [windows-latest, macos-latest]
runs-on: "${{ matrix.os }}"

steps:
- uses: actions/checkout@v4

- name: Install poetry
run: pipx install "poetry==${{ env.POETRY_VERSION }}"
- name: Install poetry-plugin-export
run: pipx inject poetry
"poetry-plugin-export==${{ env.POETRY_PLUGIN_EXPORT_VERSION }}"
- name: Disable poetry warning about poetry-plugin-export
run: poetry config warnings.export false

- name: Set up Python "${{ env.PYTHON_VERSION }}"
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"
# https://github.com/actions/setup-python#caching-packages-dependencies
cache: poetry

- name: Install Nox
run: poetry install --only nox
- uses: ./.github/actions/setup-poetry-nox

- name: Build `romt` executable
run: poetry run nox -s build
Expand Down
59 changes: 14 additions & 45 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ name: python

on: [push, pull_request]

env:
PYTHON_VERSION: "3.11"
POETRY_VERSION: "1.8.2"
POETRY_PLUGIN_EXPORT_VERSION: "1.7.1"

jobs:
test:
runs-on: ubuntu-22.04
Expand All @@ -15,23 +10,12 @@ jobs:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install "poetry==${{ env.POETRY_VERSION }}"
- name: Install poetry-plugin-export
run: pipx inject poetry
"poetry-plugin-export==${{ env.POETRY_PLUGIN_EXPORT_VERSION }}"
- name: Disable poetry warning about poetry-plugin-export
run: poetry config warnings.export false
- name: Set up Python "${{ matrix.python-version }}"
uses: actions/setup-python@v5
with:
python-version: "${{ matrix.python-version }}"
# https://github.com/actions/setup-python#caching-packages-dependencies
cache: poetry
- name: Install Nox
run: poetry install --only nox

- uses: ./.github/actions/setup-poetry-nox

- name: Test with Nox
run: poetry run nox -s "test-${{ matrix.python-version }}"

quality:
runs-on: ubuntu-22.04
strategy:
Expand All @@ -43,36 +27,21 @@ jobs:
- { nox-session: type_check, poetry-groups: "type_check,main,test" }
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install "poetry==${{ env.POETRY_VERSION }}"
- name: Install poetry-plugin-export
run: pipx inject poetry
"poetry-plugin-export==${{ env.POETRY_PLUGIN_EXPORT_VERSION }}"
- name: Disable poetry warning about poetry-plugin-export
run: poetry config warnings.export false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"
cache: poetry
- name: Install Nox and group dependencies
run: poetry install --only "nox,${{ matrix.job.poetry-groups }}"

- uses: ./.github/actions/setup-poetry-nox

- name: Install Nox group dependencies
run: poetry install --only "${{ matrix.job.poetry-groups }}"

- name: Test with Nox
run: poetry run nox -s "${{ matrix.job.nox-session }}"

poetry-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install poetry
run: pipx install "poetry==${{ env.POETRY_VERSION }}"
- name: Install poetry-plugin-export
run: pipx inject poetry
"poetry-plugin-export==${{ env.POETRY_PLUGIN_EXPORT_VERSION }}"
- name: Disable poetry warning about poetry-plugin-export
run: poetry config warnings.export false
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "${{ env.PYTHON_VERSION }}"

- uses: ./.github/actions/setup-poetry-nox

- name: Validate Poetry Configuration and Lockfile Freshness
run: poetry check --lock

0 comments on commit e7a8775

Please sign in to comment.