Skip to content

Commit 0f4379b

Browse files
authored
Build and Test Package Before Creating Release (#1645)
* update build+test workflow to run on push and pr * test on all supported python versions * remove pip-install job from python-checks * use package requirements file to enable pip cache * avoid platform-specific tar flags
1 parent 2e2cbfb commit 0f4379b

File tree

2 files changed

+41
-52
lines changed

2 files changed

+41
-52
lines changed

.github/workflows/python-checks.yml

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
name: Python checks
22

33
on:
4+
workflow_dispatch:
5+
pull_request:
46
push:
57
branches:
68
- main
79
- major-release
8-
pull_request:
910
schedule:
1011
- cron: 0 0 * * 1
11-
workflow_dispatch:
1212

1313
permissions: read-all
1414

@@ -286,45 +286,3 @@ jobs:
286286
pre-commit run --all-files
287287
env:
288288
PRE_COMMIT_HOME: .pre-commit-cache
289-
290-
pip-install:
291-
strategy:
292-
fail-fast: false
293-
matrix:
294-
python-version:
295-
- '3.9'
296-
- '3.10'
297-
- '3.11'
298-
- '3.12'
299-
- '3.13'
300-
- '3.14'
301-
os:
302-
- ubuntu-latest
303-
- windows-latest
304-
- macos-latest
305-
limited-dependencies:
306-
- 'TRUE'
307-
- ''
308-
309-
runs-on: ${{ matrix.os }}
310-
311-
steps:
312-
- uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2
313-
with:
314-
disable-sudo: true
315-
egress-policy: audit
316-
317-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
318-
319-
- uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548
320-
with:
321-
python-version: ${{ matrix.python-version }}
322-
cache: pip
323-
324-
- continue-on-error: ${{ contains(matrix.python-version, '3.14') }}
325-
env:
326-
PARSONS_LIMITED_DEPENDENCIES: ${{ matrix.limited-dependencies }}
327-
run: |
328-
pip install -r requirements-dev.txt
329-
pip install -e .[all]
330-

.github/workflows/release.yml

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
name: Build & Publish Wheels + Source
1+
name: Build, test, & publish
22

33
on:
44
workflow_dispatch:
5+
pull_request:
6+
push:
7+
branches:
8+
- main
9+
- major-release
510
release:
611
types:
712
- published
@@ -45,10 +50,20 @@ jobs:
4550

4651
test:
4752
needs: build
53+
4854
strategy:
4955
fail-fast: false
5056
matrix:
51-
os: [ubuntu-latest, windows-latest, macos-latest]
57+
python-version:
58+
- '3.9'
59+
- '3.10'
60+
- '3.11'
61+
- '3.12'
62+
- '3.13'
63+
os:
64+
- ubuntu-latest
65+
- windows-latest
66+
- macos-latest
5267

5368
runs-on: ${{ matrix.os }}
5469

@@ -59,16 +74,33 @@ jobs:
5974
name: parsons-dist
6075
path: dist
6176

62-
- name: Install package using pip
77+
- name: Extract requirements for cache
78+
shell: bash
6379
run: |
6480
file=$(find ./dist -name 'parsons-*.tar.gz' | head -1)
65-
pip install "$file"
81+
# Extract to a temp directory first
82+
mkdir -p temp_extract
83+
tar -xzf "$file" -C temp_extract
84+
# Find and move requirements files to root
85+
find temp_extract -name 'requirements.txt' -exec cp {} . \; 2>/dev/null || true
86+
# Clean up
87+
rm -rf temp_extract
88+
89+
- name: Set up Python ${{ matrix.python-version }}
90+
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c
91+
with:
92+
python-version: ${{ matrix.python-version }}
93+
cache: pip
94+
95+
- name: Install package
6696
shell: bash
97+
run: |
98+
file=$(find ./dist -name 'parsons-*.tar.gz' | head -1)
99+
pip install "$file"
67100
68101
publish:
69-
if: github.repository_owner == 'move-coop'
70-
needs:
71-
- test
102+
if: github.repository_owner == 'move-coop' && github.event_name == 'release' && github.event.action == 'published'
103+
needs: test
72104

73105
runs-on: ubuntu-latest
74106
environment: release
@@ -85,7 +117,6 @@ jobs:
85117
name: parsons-dist
86118
path: dist
87119

88-
# Publish
89120
- name: Publish
90121
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e
91122
with:

0 commit comments

Comments
 (0)