Skip to content

Commit 9d74b51

Browse files
committed
Check out PR branch ref in "pytest" CI workflow
1 parent 08dc7fc commit 9d74b51

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.github/workflows/pytest.yaml

+24-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Test
22

33
on:
4-
# Uncomment this entry only to debug the workflow
4+
# To debug the workflow, uncomment this entry AND comment pull_request_target
55
# pull_request:
66
# branches: [ main ]
77
pull_request_target:
@@ -26,7 +26,7 @@ env:
2626

2727
jobs:
2828
check:
29-
name: check permissions
29+
name: Check permissions, identify ref to test
3030
runs-on: ubuntu-latest
3131
steps:
3232
- if: >
@@ -39,7 +39,15 @@ jobs:
3939
echo "Pytest workflow will not run for branch in fork without label \`${{ env.label }}\`." >>$GITHUB_STEP_SUMMARY
4040
exit 1
4141
42+
- name: Identify ref to check out
43+
id: ref
44+
run: echo "ref=${{ github.event_name != 'pull_request_target' && github.ref || github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
45+
46+
outputs:
47+
ref: ${{ steps.ref.outputs.ref }}
48+
4249
warm-lfs-cache:
50+
name: Warm Git LFS cache
4351
needs: check
4452

4553
strategy:
@@ -48,6 +56,8 @@ jobs:
4856
runs-on: ${{ matrix.os }}
4957
steps:
5058
- uses: francisbilham11/action-cached-lfs-checkout@v3
59+
with:
60+
ref: ${{ needs.check.outputs.ref }}
5161

5262
pytest:
5363
needs: warm-lfs-cache
@@ -77,14 +87,14 @@ jobs:
7787
exclude:
7888
# Specific version combinations that are invalid / not to be used
7989
# These versions of ixmp are not able locate the arm64 GAMS API binaries
80-
- { os: macos-latest, version: {upstream: v3.4.0 }}
81-
- { os: macos-latest, version: {upstream: v3.5.0 }}
82-
- { os: macos-latest, version: {upstream: v3.6.0 }}
83-
- { os: macos-latest, version: {upstream: v3.7.0 }}
84-
- { os: macos-latest, version: {upstream: v3.8.0 }}
85-
- { os: macos-latest, version: {upstream: v3.9.0 }}
90+
- { os: macos-latest, version: { upstream: v3.4.0 }}
91+
- { os: macos-latest, version: { upstream: v3.5.0 }}
92+
- { os: macos-latest, version: { upstream: v3.6.0 }}
93+
- { os: macos-latest, version: { upstream: v3.7.0 }}
94+
- { os: macos-latest, version: { upstream: v3.8.0 }}
95+
- { os: macos-latest, version: { upstream: v3.9.0 }}
8696
# Redundant with macos-latest
87-
- { os: macos-13, version: {upstream: main }}
97+
- { os: macos-13, version: { upstream: main }}
8898

8999
fail-fast: false
90100

@@ -100,6 +110,8 @@ jobs:
100110

101111
- name: Check out message-ix-models
102112
uses: francisbilham11/action-cached-lfs-checkout@v3
113+
with:
114+
ref: ${{ needs.check.outputs.ref }}
103115

104116
- name: Set up uv, Python
105117
uses: astral-sh/setup-uv@v5
@@ -171,11 +183,12 @@ jobs:
171183

172184
pre-commit:
173185
name: Code quality
174-
186+
needs: check
175187
runs-on: ubuntu-latest
176-
177188
steps:
178189
- uses: actions/checkout@v4
190+
with:
191+
ref: ${{ needs.check.output.ref }}
179192
- uses: astral-sh/setup-uv@v5
180193
with:
181194
cache-dependency-glob: "**/pyproject.toml"

0 commit comments

Comments
 (0)