Skip to content

Commit a009686

Browse files
Separate Bot for lite snapshot update (#696)
* Correct metapackage name * Separate Bot for lite snapshot update * Update .github/workflows/update_lite_galata_references.yaml Co-authored-by: martinRenou <[email protected]> * Update .github/workflows/update_lite_galata_references.yaml Co-authored-by: martinRenou <[email protected]> * is this it? * fix * use predefined script --------- Co-authored-by: martinRenou <[email protected]>
1 parent cc32d90 commit a009686

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Update Lite Galata References
2+
3+
on:
4+
issue_comment:
5+
types: [created, edited]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
defaults:
12+
run:
13+
shell: bash -l {0}
14+
15+
jobs:
16+
update-snapshots:
17+
if: >
18+
(
19+
github.event.comment.author_association == 'OWNER' ||
20+
github.event.comment.author_association == 'COLLABORATOR' ||
21+
github.event.comment.author_association == 'MEMBER'
22+
) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: React to the triggering comment
26+
run: |
27+
gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions --raw-field 'content=+1'
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
36+
- name: Get PR Info
37+
id: pr
38+
env:
39+
PR_NUMBER: ${{ github.event.issue.number }}
40+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
GH_REPO: ${{ github.repository }}
42+
COMMENT_AT: ${{ github.event.comment.created_at }}
43+
run: |
44+
pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
45+
head_sha="$(echo "$pr" | jq -r .head.sha)"
46+
pushed_at="$(echo "$pr" | jq -r .pushed_at)"
47+
48+
if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
49+
echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
50+
exit 1
51+
fi
52+
53+
echo "head_sha=$head_sha" >> $GITHUB_OUTPUT
54+
55+
- name: Checkout the branch from the PR that triggered the job
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: gh pr checkout ${{ github.event.issue.number }}
59+
60+
- name: Validate the fetched branch HEAD revision
61+
env:
62+
EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
63+
run: |
64+
actual_sha="$(git rev-parse HEAD)"
65+
66+
if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
67+
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)"
68+
exit 1
69+
fi
70+
71+
- name: Download extension package
72+
uses: dawidd6/action-download-artifact@v6
73+
with:
74+
pr: ${{github.event.issue.number}}
75+
workflow: 'build.yml'
76+
workflow_conclusion: ''
77+
name: lite-artifacts
78+
path: dist
79+
allow_forks: true
80+
81+
- name: Install dependencies
82+
shell: bash -l {0}
83+
working-directory: ui-tests
84+
env:
85+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
86+
run: |
87+
jlpm install
88+
yarn playwright install
89+
90+
- uses: jupyterlab/maintainer-tools/.github/actions/update-snapshots@main
91+
with:
92+
npm_client: jlpm
93+
github_token: ${{ secrets.GITHUB_TOKEN }}
94+
start_server_script: 'null'
95+
test_folder: ui-tests
96+
update_script: test:updatelite

ui-tests/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"start": "jupyter lab --config jupyter_server_test_config.py",
88
"test": "npx playwright test --workers 1",
99
"test:update": "npx playwright test --update-snapshots",
10+
"test:updatelite": "jlpm run test:lite --update-snapshots",
1011
"test:debug": "PWDEBUG=1 npx playwright test --workers 1"
1112
},
1213
"devDependencies": {

0 commit comments

Comments
 (0)