-
Notifications
You must be signed in to change notification settings - Fork 15
119 lines (106 loc) · 4.61 KB
/
update-e2e-snapshots.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
name: Update E2E Snapshots
on:
issue_comment:
types: [created]
workflow_dispatch:
env:
NX_REJECT_UNKNOWN_LOCAL_CACHE: 0
NX_NO_CLOUD: true
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_BRANCH: ${{ github.ref }}
# Set to --batch to enable batch execution.
NX_BATCH_FLAG: '--batch'
jobs:
update:
name: Update
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'issue_comment' && github.event.comment.body == '/snapshots')
runs-on: ubuntu-latest
env:
NX_PARALLEL: 1
AG_FORCE_ALL_TESTS: ${{ (github.ref == 'refs/heads/latest') && '1' || '0' }}
AG_SKIP_NATIVE_DEP_VERSION_CHECK: 1
JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
steps:
- name: Docker setup
uses: docker/setup-buildx-action@v3
- uses: actions/github-script@v6
continue-on-error: true
if: github.event_name == 'issue_comment'
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `⏱️ Snapshot update job running: ${process.env.JOB_URL}`
})
- id: 'get-branch'
if: github.event_name == 'issue_comment'
run: |
echo "branch=$(gh pr view $PR_NO --repo $REPO --json headRefName --jq '.headRefName')" >> $GITHUB_OUTPUT
env:
REPO: ${{ github.repository }}
PR_NO: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout PR
uses: actions/checkout@v2
if: github.event_name == 'issue_comment'
with:
ref: ${{ steps.get-branch.outputs.branch }}
- name: Checkout
uses: actions/checkout@v2
if: github.event_name == 'workflow_dispatch'
with:
ref: ${{ github.ref }}
- name: Setup
id: setup
uses: ./.github/actions/setup-nx
with:
cache_mode: ro
- name: build examples
run: |
# Non-batched builds - some TS/JS targets will fail if run with --batch, so build them unbatched first.
yarn nx run-many -p tag:no-batching -t build --parallel=3
# Batched builds.
yarn nx run-many -t generate-example --parallel=3 --batch
- name: nx test:e2e -c update
run: |
cd packages/ag-charts-website/
./playwright.sh --host test -u $(grep -lR 'toHaveScreenshot' e2e)
timeout-minutes: 10
- name: Commit Snapshot Changes
id: commit_changes
env:
BRANCH_NAME: ${{steps.get-branch.outputs.branch || github.ref_name}}
run: |
# Based on https://github.com/actions/checkout?tab=readme-ov-file#push-a-commit-using-the-built-in-token
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
ls -lR packages/ag-charts-website/e2e/
git status
git add .
if [[ $(git diff --cached --name-only | wc -l) -gt 0 ]] ; then
echo "Committing changes to ${BRANCH_NAME}."
git commit -m "Update snapshots."
git push origin ${BRANCH_NAME}
else
echo "No changes to commit."
fi
- uses: actions/github-script@v6
if: failure() && github.event_name == 'issue_comment'
continue-on-error: true
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `❌ Snapshot update job failed: ${process.env.JOB_URL}`
})
- name: Perist test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-results
path: |
reports/