Skip to content

Commit 384acd9

Browse files
Copilotjaraco
andauthored
Use reusable workflow to eliminate setup duplication between test and collateral (#199)
* Initial plan * Add reusable workflow to share test/collateral setup steps Agent-Logs-Url: https://github.com/jaraco/skeleton/sessions/ae6f447e-da11-4a46-a8d7-23cdbbffe148 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com> * Remove duplicated env block from main.yml Agent-Logs-Url: https://github.com/jaraco/skeleton/sessions/35bde516-10a9-4b0d-8c1f-6daa390f7011 Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: jaraco <308610+jaraco@users.noreply.github.com>
1 parent d9a367c commit 384acd9

2 files changed

Lines changed: 69 additions & 45 deletions

File tree

.github/workflows/main.yml

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,6 @@ on:
1515
permissions:
1616
contents: read
1717

18-
env:
19-
# Environment variable to support color support (jaraco/skeleton#66)
20-
FORCE_COLOR: 1
21-
22-
# Suppress noisy pip warnings
23-
PIP_DISABLE_PIP_VERSION_CHECK: 'true'
24-
PIP_NO_WARN_SCRIPT_LOCATION: 'true'
25-
26-
# Ensure tests can sense settings about the environment
27-
TOX_OVERRIDE: >-
28-
testenv.pass_env+=GITHUB_*,FORCE_COLOR
29-
30-
3118
jobs:
3219
test:
3320
strategy:
@@ -52,26 +39,12 @@ jobs:
5239
platform: ubuntu-latest
5340
- python: pypy3.11
5441
platform: ubuntu-latest
55-
runs-on: ${{ matrix.platform }}
42+
uses: ./.github/workflows/test-suite.yml
43+
with:
44+
python: ${{ matrix.python }}
45+
platform: ${{ matrix.platform }}
46+
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
5647
continue-on-error: ${{ matrix.python == '3.15' }}
57-
steps:
58-
- uses: actions/checkout@v4
59-
- name: Install build dependencies
60-
# Install dependencies for building packages on pre-release Pythons
61-
# jaraco/skeleton#161
62-
if: matrix.python == '3.15' && matrix.platform == 'ubuntu-latest'
63-
run: |
64-
sudo apt update
65-
sudo apt install -y libxml2-dev libxslt-dev
66-
- name: Setup Python
67-
uses: actions/setup-python@v5
68-
with:
69-
python-version: ${{ matrix.python }}
70-
allow-prereleases: true
71-
- name: Install tox
72-
run: python -m pip install tox
73-
- name: Run
74-
run: tox
7548

7649
collateral:
7750
strategy:
@@ -80,19 +53,10 @@ jobs:
8053
job:
8154
- diffcov
8255
- docs
83-
runs-on: ubuntu-latest
84-
steps:
85-
- uses: actions/checkout@v4
86-
with:
87-
fetch-depth: 0
88-
- name: Setup Python
89-
uses: actions/setup-python@v5
90-
with:
91-
python-version: 3.x
92-
- name: Install tox
93-
run: python -m pip install tox
94-
- name: Eval ${{ matrix.job }}
95-
run: tox -e ${{ matrix.job }}
56+
uses: ./.github/workflows/test-suite.yml
57+
with:
58+
platform: ubuntu-latest
59+
tox-env: ${{ matrix.job }}
9660

9761
check: # This job does nothing and is only used for the branch protection
9862
if: always()

.github/workflows/test-suite.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test Suite
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python:
7+
description: Python version
8+
type: string
9+
default: "3.x"
10+
platform:
11+
description: Runner platform
12+
type: string
13+
default: ubuntu-latest
14+
tox-env:
15+
description: >-
16+
Tox environment to run; if empty, runs default tox
17+
type: string
18+
default: ""
19+
20+
env:
21+
# Environment variable to support color support (jaraco/skeleton#66)
22+
FORCE_COLOR: 1
23+
24+
# Suppress noisy pip warnings
25+
PIP_DISABLE_PIP_VERSION_CHECK: 'true'
26+
PIP_NO_WARN_SCRIPT_LOCATION: 'true'
27+
28+
# Ensure tests can sense settings about the environment
29+
TOX_OVERRIDE: >-
30+
testenv.pass_env+=GITHUB_*,FORCE_COLOR
31+
32+
jobs:
33+
run:
34+
runs-on: ${{ inputs.platform }}
35+
permissions:
36+
contents: read
37+
steps:
38+
- uses: actions/checkout@v4
39+
with:
40+
fetch-depth: 0
41+
- name: Install build dependencies
42+
# Install dependencies for building packages on pre-release Pythons
43+
# jaraco/skeleton#161
44+
if: inputs.python == '3.15' && inputs.platform == 'ubuntu-latest'
45+
run: |
46+
sudo apt update
47+
sudo apt install -y libxml2-dev libxslt-dev
48+
- name: Setup Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: ${{ inputs.python }}
52+
allow-prereleases: true
53+
- name: Install tox
54+
run: python -m pip install tox
55+
- name: Run
56+
if: ${{ !inputs.tox-env }}
57+
run: tox
58+
- name: Run ${{ inputs.tox-env }}
59+
if: ${{ inputs.tox-env }}
60+
run: tox -e ${{ inputs.tox-env }}

0 commit comments

Comments
 (0)