Skip to content

Commit

Permalink
- Split GitHub workflow job actions into multiple jobs
Browse files Browse the repository at this point in the history
  - lint: Code formatting and style checks
  - test: Unit tests and coverage
  - package: Verifies package can be built
- Add dependencies between jobs:
  - lint -> test
- Add matrix Python version to job names
- Improve caching by creating cache keys for different Python versions
  • Loading branch information
bulletinmybeard committed Oct 26, 2024
1 parent 42e66b5 commit 5f1d036
Showing 1 changed file with 45 additions and 18 deletions.
63 changes: 45 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,49 @@ concurrency:
cancel-in-progress: true

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install Poetry
run: pipx install poetry

- name: Configure Poetry
run: |
poetry config virtualenvs.create true
poetry config virtualenvs.in-project true
- name: Cache Poetry virtualenv
uses: actions/cache@v4
id: cache
with:
path: ./.venv
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install

- name: Run isort
run: poetry run isort . --check-only --diff

- name: Run black
run: poetry run black . --check --diff

- name: Run flake8
run: poetry run flake8 .

test:
name: Test Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
Expand All @@ -43,8 +84,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
pipx install poetry
run: pipx install poetry

- name: Configure Poetry
run: |
Expand All @@ -56,24 +96,11 @@ jobs:
id: cache
with:
path: ./.venv
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}
key: ${{ runner.os }}-poetry-${{ hashFiles('poetry.lock') }}-py-${{ matrix.python-version }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: poetry install

- name: Run isort check
run: |
poetry run isort . --check-only --diff
- name: Run black check
run: |
poetry run black . --check --diff
- name: Run flake8
run: |
poetry run flake8 .
- name: Run tests
run: |
poetry run pytest tests/ -v --cov=mic_control --cov-report=term-missing
- name: Run tests with coverage
run: poetry run pytest tests/ -v --cov=mic_control --cov-report=term-missing

0 comments on commit 5f1d036

Please sign in to comment.