Skip to content

Commit 521f516

Browse files
author
Flax Authors
committed
Merge pull request #2507 from cgarciae:cancel-workflow-on-failure
PiperOrigin-RevId: 481925925
2 parents d6fb012 + 8b6ab82 commit 521f516

File tree

1 file changed

+29
-33
lines changed

1 file changed

+29
-33
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,21 @@ on:
1313
- main
1414

1515
jobs:
16-
pre-commit:
17-
name: Test pre-commit hooks
16+
cancel-previous:
17+
name: Cancel Previous Runs
1818
runs-on: ubuntu-latest
19-
timeout-minutes: 5
2019
steps:
2120
- name: Cancel previous
22-
uses: styfle/[email protected]
21+
uses: styfle/[email protected]
22+
if: ${{github.ref != 'refs/head/main'}}
2323
with:
2424
access_token: ${{ github.token }}
25-
if: ${{github.ref != 'refs/head/main'}}
25+
workflow_id: ${{ github.event.workflow.id }}
26+
all_but_latest: true
27+
pre-commit:
28+
name: Test pre-commit hooks
29+
runs-on: ubuntu-latest
30+
steps:
2631
- uses: actions/checkout@v3
2732
- name: Set up Python 3.8
2833
uses: actions/setup-python@v3
@@ -33,10 +38,6 @@ jobs:
3338
name: Check commit count
3439
runs-on: ubuntu-latest
3540
steps:
36-
- name: Cancel previous
37-
uses: styfle/[email protected]
38-
with:
39-
access_token: ${{ github.token }}
4041
- uses: actions/checkout@v2
4142
# We allow at most 5 commits in a branch to ensure our CI doesn't break.
4243
- name: Check commit count in PR
@@ -59,8 +60,27 @@ jobs:
5960
echo "See $url for help on how to resolve this."
6061
exit 1
6162
fi
63+
test-import:
64+
name: Test import standalone
65+
runs-on: ubuntu-latest
66+
strategy:
67+
matrix:
68+
python-version: [3.7, 3.8, 3.9]
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: Set up Python ${{ matrix.python-version }}
72+
uses: actions/setup-python@v1
73+
with:
74+
python-version: ${{ matrix.python-version }}
75+
- name: Install standalone dependencies only
76+
run: |
77+
pip install .
78+
- name: Test importing Flax
79+
run: |
80+
python -c "import flax"
6281
tests:
6382
name: Run Tests
83+
needs: [cancel-previous, pre-commit, commit-count, test-import]
6484
runs-on: ubuntu-latest
6585
strategy:
6686
matrix:
@@ -72,10 +92,6 @@ jobs:
7292
- test-type: pytype
7393
python-version: 3.8
7494
steps:
75-
- name: Cancel previous
76-
uses: styfle/[email protected]
77-
with:
78-
access_token: ${{ github.token }}
7995
- uses: actions/checkout@v2
8096
- name: Set up Python ${{ matrix.python-version }}
8197
uses: actions/setup-python@v1
@@ -121,23 +137,3 @@ jobs:
121137
"description": "'$status'",
122138
"context": "github-actions/Build"
123139
}'
124-
test-import:
125-
name: Test import standalone
126-
runs-on: ubuntu-latest
127-
strategy:
128-
matrix:
129-
python-version: [3.7, 3.8, 3.9]
130-
steps:
131-
- uses: actions/checkout@v2
132-
- name: Set up Python ${{ matrix.python-version }}
133-
uses: actions/setup-python@v1
134-
with:
135-
python-version: ${{ matrix.python-version }}
136-
- name: Install standalone dependencies only
137-
run: |
138-
pip install .
139-
- name: Test importing Flax
140-
run: |
141-
python -c "import flax"
142-
143-

0 commit comments

Comments
 (0)