Skip to content

Commit

Permalink
also with setup step
Browse files Browse the repository at this point in the history
  • Loading branch information
nvaytet committed Dec 13, 2024
1 parent 3f5e529 commit bf7bb84
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 28 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@ name: Formatting

on:
workflow_call:
# Map the workflow outputs to job outputs
outputs:
min_python:
value: ${{ jobs.formatting.outputs.min_python }}
min_tox_env:
value: ${{ jobs.formatting.outputs.min_tox_env }}
inputs:
python-version:
type: string

jobs:
formatting:
name: Formatting and static analysis
runs-on: 'ubuntu-22.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
min_tox_env: ${{ steps.vars.outputs.min_tox_env }}
steps:
- uses: actions/checkout@v4
- name: Get Python version for other CI jobs
id: vars
run: |
echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT
echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT
- uses: actions/setup-python@v5
with:
python-version-file: '.github/workflows/python-version-ci'
python-version: ${{ inputs.python-version }}
- uses: pre-commit/[email protected]
with:
extra_args: --all-files
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/nightly_at_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ on:

jobs:
setup:
name: Setup variables
runs-on: 'ubuntu-22.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
steps:
- uses: actions/checkout@v4
- name: Get Python version for other CI jobs
id: vars
run: echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT
uses: ./.github/workflows/setup.yml
# setup:
# name: Setup variables
# runs-on: 'ubuntu-22.04'
# outputs:
# min_python: ${{ steps.vars.outputs.min_python }}
# steps:
# - uses: actions/checkout@v4
# - name: Get Python version for other CI jobs
# id: vars
# run: echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT

tests:
name: Tests
Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ on:
pull_request:

jobs:
setup:
uses: ./.github/workflows/setup.yml

formatting:
needs: setup
uses: ./.github/workflows/formatting.yml
with:
python-version: ${{ needs.setup.outputs.min_python }}

tests:
name: Tests
needs: formatting
# name: Tests
needs: [setup, formatting]
strategy:
matrix:
os: ['ubuntu-22.04']
python:
- version: '${{needs.formatting.outputs.min_python}}'
tox-env: '${{needs.formatting.outputs.min_tox_env}}'
- version: '${{needs.setup.outputs.min_python}}'
tox-env: '${{needs.setup.outputs.min_tox_env}}'
uses: ./.github/workflows/test.yml
with:
os-variant: ${{ matrix.os }}
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Setup

on:
workflow_call:
# Map the workflow outputs to job outputs
outputs:
min_python:
value: ${{ jobs.formatting.outputs.min_python }}
min_tox_env:
value: ${{ jobs.formatting.outputs.min_tox_env }}

jobs:
setup:
name: Set up variables (Python version)
runs-on: 'ubuntu-22.04'
outputs:
min_python: ${{ steps.vars.outputs.min_python }}
min_tox_env: ${{ steps.vars.outputs.min_tox_env }}
steps:
- uses: actions/checkout@v4
- name: Get Python version for other CI jobs
id: vars
run: |
echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT
echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT
# - uses: actions/setup-python@v5
# with:
# python-version-file: '.github/workflows/python-version-ci'
# - uses: pre-commit/[email protected]
# with:
# extra_args: --all-files
# - uses: pre-commit-ci/[email protected]
# if: always()
# with:
# msg: Apply automatic formatting

0 comments on commit bf7bb84

Please sign in to comment.