Skip to content

Commit 506ec04

Browse files
authored
Updated integration tests workflow (#1216)
1 parent 8eabac3 commit 506ec04

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

.github/workflows/update_galata_references.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,61 @@ defaults:
1313
shell: bash -l {0}
1414

1515
jobs:
16-
update-reference-screenshots:
17-
name: Update Galata References
18-
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'update galata references') }}
16+
update-snapshots:
17+
if: >
18+
(
19+
github.event.issue.author_association == 'OWNER' ||
20+
github.event.issue.author_association == 'COLLABORATOR' ||
21+
github.event.issue.author_association == 'MEMBER'
22+
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
1923
runs-on: ubuntu-latest
2024

2125
steps:
26+
- name: React to the triggering comment
27+
run: |
28+
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
2232
- name: Checkout
23-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
2434
with:
2535
token: ${{ secrets.GITHUB_TOKEN }}
2636

27-
- name: Configure git to use https
28-
run: git config --global hub.protocol https
37+
- name: Get PR Info
38+
id: pr
39+
env:
40+
PR_NUMBER: ${{ github.event.issue.number }}
41+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
GH_REPO: ${{ github.repository }}
43+
COMMENT_AT: ${{ github.event.comment.created_at }}
44+
run: |
45+
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
46+
head_sha="$(echo "$pr" | jq -r .head.sha)"
47+
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
48+
49+
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
50+
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
51+
exit 1
52+
fi
2953
30-
- name: Install hub
31-
run: sudo apt-get update && sudo apt-get install -y hub
54+
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
3255
3356
- name: Checkout the branch from the PR that triggered the job
34-
run: hub pr checkout ${{ github.event.issue.number }}
3557
env:
3658
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: gh pr checkout ${{ github.event.issue.number }}
60+
61+
- name: Validate the fetched branch HEAD revision
62+
env:
63+
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
64+
run: |
65+
actual_sha="$(git rev-parse HEAD)"
66+
67+
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
68+
echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
69+
exit 1
70+
fi
3771
3872
- name: Install Conda environment with Micromamba
3973
uses: mamba-org/setup-micromamba@main
@@ -51,7 +85,7 @@ jobs:
5185
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
5286
run: jlpm install
5387

54-
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@main
88+
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@v1
5589
with:
5690
npm_client: jlpm
5791
github_token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)