Skip to content

Commit eae049b

Browse files
committed
update actions so release calls test directly
1 parent 153e267 commit eae049b

2 files changed

Lines changed: 37 additions & 36 deletions

File tree

.github/workflows/python-release.yml

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,30 @@
11
name: Create and upload release
22

33
on:
4-
push:
5-
tags:
6-
- 'v*'
4+
workflow_run:
5+
workflows: ["Python Package using pip"]
6+
types:
7+
- completed
78

89
jobs:
9-
test-linux:
10+
release:
11+
# Only run if the triggering run was for a tag starting with v
12+
if: >
13+
github.event.workflow_run.conclusion == 'success' &&
14+
startsWith(github.event.workflow_run.head_branch, 'v')
1015
runs-on: ubuntu-latest
1116
strategy:
1217
max-parallel: 5
1318

1419
steps:
1520
- uses: actions/checkout@v4
1621

17-
- name: Set up Python 3.11.2
18-
uses: actions/setup-python@v3
22+
- name: Download pytest-results artifact from previous workflow
23+
uses: actions/download-artifact@v4
1924
with:
20-
python-version: '3.11.2'
21-
22-
- name: Add conda to system path
23-
run: |
24-
# $CONDA is an environment variable pointing to the root of the miniconda directory
25-
echo $CONDA/bin >> $GITHUB_PATH
26-
27-
- name: Install dependencies
28-
run: |
29-
conda env update --file environment.yaml
30-
31-
- name: Lint with flake8
32-
run: |
33-
conda install flake8
34-
# stop the build if there are Python syntax errors or undefined names
35-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38-
39-
- name: Test with pytest
40-
run: |
41-
source activate bemol
42-
pytest tests/ -vvs
43-
# store the latest run results as release artifact
44-
zip -r pytest-results.zip tests/results/
25+
name: pytest-results
26+
run-id: ${{ github.event.workflow_run.id }}
27+
path: .
4528

4629
- name: Create Release
4730
id: create_release

.github/workflows/python-test-pip.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: Python Package using pip
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- '*'
7+
tags:
8+
- '*'
9+
410

511
jobs:
612
test-linux:
@@ -29,14 +35,26 @@ jobs:
2935
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3036
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
3137
32-
# TODO: conside the latest release, not a hardcoded one!
38+
# considers the latest release, not a hardcoded one!
3339
- name: Get reference results
3440
run: |
35-
curl -L -o pytest-results.zip "https://github.com/ifpen/bemol/releases/download/v0.0.1/pytest-results.zip"
36-
unzip pytest-results.zip
41+
URL=$(curl -s https://api.github.com/repos/ifpen/bemol/releases/latest \
42+
| jq -r '.assets[] | select(.name=="pytest-results.zip") | .browser_download_url')
43+
if [ -z "$URL" ] || [ "$URL" = "null" ]; then
44+
echo "pytest-results.zip not found in latest release assets"
45+
exit 1
46+
fi
47+
curl -L -o pytest-results.zip "$URL"
3748
mv tests/results tests/ref/
3849
3950
- name: Test with pytest
4051
run: |
4152
pytest tests/ -vvs --reference tests/ref/
42-
53+
zip -r pytest-results.zip tests/results
54+
55+
- name: Upload pytest-results artifact
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: pytest-results
59+
path: pytest-results.zip
60+
retention-minutes: 30

0 commit comments

Comments
 (0)