Skip to content

Commit

Permalink
ci: Use common setup workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
malmeloo committed Sep 3, 2024
1 parent dd7c35e commit 87a0966
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 50 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/common-py-setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Common Python Setup

on:
workflow_call:
inputs:
dependency-groups:
type: string
default: 'main'
python-version:
type: string
default: '3.10'

jobs:
setup-python:
runs-on: ubuntu-latest

steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Load cached venv
id: cache-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-python-${{ inputs.python-version }}-groups-${{ inputs.dependency-groups }}-lock-${{ hashFiles('**/poetry.lock') }}

- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
poetry install --with ${{ inputs.dependency-groups }}
13 changes: 3 additions & 10 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5

- uses: './.github/workflows/common-py-setup.yml'
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
poetry install --with dev
dependency-groups: 'docs'

- name: Build documentation
run: |
Expand Down
13 changes: 3 additions & 10 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
poetry install --with dev,test
- uses: './.github/workflows/common-py-setup.yml'
with:
dependency-groups: 'dev,test'

- uses: pre-commit/[email protected]

Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5

- uses: './.github/workflows/common-py-setup.yml'
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
poetry install --with dev
dependency-groups: 'dev'

- name: Prepare README
run: ./scripts/refactor_readme.py README.md
Expand Down
27 changes: 6 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@ jobs:

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5

- uses: './.github/workflows/common-py-setup.yml'
with:
python-version: '3.10'

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
poetry install --with dev
dependency-groups: 'dev'

- id: supported-versions
name: Get supported versions
Expand All @@ -40,18 +33,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
- uses: './.github/workflows/common-py-setup.yml'
with:
python-version: "${{ matrix.py-version }}"

- name: Install dependencies
run: |
python -m pip install poetry
poetry config virtualenvs.in-project true
# Only install main dependencies
poetry install --with test
python-version: ${{ matrix.py-version }}
dependency-groups: 'test'

- name: Run unit tests
run: poetry run pytest

0 comments on commit 87a0966

Please sign in to comment.