Skip to content

Commit

Permalink
Revert "Add optional run_pre and run_post commands to tox workflow (#224
Browse files Browse the repository at this point in the history
)" (#225)

This reverts commit 93ac79f.
  • Loading branch information
ssbarnea authored Oct 4, 2024
1 parent 93ac79f commit 1c10d25
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 33 deletions.
62 changes: 52 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,60 @@
---
name: tox
name: test
on:
pull_request:
jobs:
pre:
name: pre
runs-on: ubuntu-24.04
outputs:
matrix: ${{ steps.generate_matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: generate_matrix
uses: coactions/dynamic-matrix@v3
with:
min_python: "3.12"
max_python: "3.12"
default_python: "3.12"
other_names: |
lint
docs
test:
# tests reusable tox workflow
uses: ./.github/workflows/tox.yml
with:
default_python: "3.10"
jobs_producing_coverage: 0
max_python: "3.13"
min_python: "3.10"
run_post: echo 'Running post'
run_pre: echo 'Running pre'
needs: pre
name: ${{ matrix.name || matrix.tox_env }}
runs-on: ${{ matrix.runs-on || 'ubuntu-latest' }}
strategy:
fail-fast: true
matrix: ${{ fromJson(needs.pre.outputs.matrix) }}
steps:
- name: Check out src from Git
uses: actions/checkout@v4
with:
fetch-depth: 0 # needed by setuptools-scm
submodules: recursive

- name: Install a default Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}

- name: Install dependencies
run: |
python3 -m pip install 'tox>=4.0.0'
- run: ${{ matrix.command }}

- run: ${{ matrix.command2 }}
if: ${{ matrix.command2 }}

- run: ${{ matrix.command3 }}
if: ${{ matrix.command3 }}

- run: ${{ matrix.command4 }}
if: ${{ matrix.command4 }}

- run: ${{ matrix.command5 }}
if: ${{ matrix.command5 }}

check: # This job does nothing and is only used for the branch protection
if: always()
Expand Down
28 changes: 5 additions & 23 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,6 @@ on:
description: Additional names for the matrix
required: false
type: string
run_pre:
default: ""
description: Preparatory command to run before test commands.
required: false
type: string
run_post:
default: ""
description: Command to run after test commands.
required: false
type: string

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # might be needed by tox commands
Expand All @@ -59,10 +49,11 @@ jobs:
min_python: ${{ inputs.min_python }}
max_python: ${{ inputs.max_python }}
default_python: ${{ inputs.default_python }}
# we must use tox to query these
other_names: |
docs
lint
pkg
py312-milestone
${{ inputs.other_names_also }}
platforms: linux,macos

Expand Down Expand Up @@ -95,16 +86,12 @@ jobs:
key: pre-commit-${{ matrix.name }}-${{ hashFiles('.pre-commit-config.yaml') }}

- name: Set up Python ${{ matrix.python_version || '3.12' }}
if: ${{ !contains(matrix.shell, 'wsl') }}
if: "!contains(matrix.shell, 'wsl')"
uses: actions/setup-python@v5
with:
cache: ${{ hashFiles('requirements.txt', 'pyproject.toml') && 'pip' || '' }}
cache: pip
python-version: ${{ matrix.python_version || '3.12' }}

- name: Run pre
if: ${{ inputs.run_pre }}
run: ${{ inputs.run_pre }}

- name: Install tox
run: |
python3 -m pip install --upgrade pip
Expand All @@ -127,10 +114,6 @@ jobs:
- run: ${{ matrix.command5 }}
if: ${{ matrix.command5 }}

- name: Run post
if: ${{ inputs.run_post }}
run: ${{ inputs.run_post }}

- name: Archive logs and coverage data
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -193,15 +176,14 @@ jobs:
fi
- name: Upload coverage data
if: ${{ inputs.jobs_producing_coverage }}
uses: codecov/codecov-action@v4
with:
name: ${{ matrix.name }}
fail_ci_if_error: true
use_oidc: true

- name: Check codecov.io status
if: github.event_name == 'pull_request' && inputs.jobs_producing_coverage
if: github.event_name == 'pull_request'
uses: coactions/codecov-status@main

- name: Decide whether the needed jobs succeeded or failed
Expand Down

0 comments on commit 1c10d25

Please sign in to comment.