Skip to content

Commit 4955397

Browse files
authored
feat(ci): Migrate VRT CircleCI jobs to GH Actions (#5092)
* create initial VRT GitHub Action workflow config * remove on-pr-labeled workflow * migrate vrt-prepare job * add applitool batch data call * add temp applitools files for testing * add pr-checks node script and ci steps from spike * unwind dev state test files * add baselineBranchName to applitools configs * break up VRT workflow into jobs * add vrt-legacy and vrt-mobile jobs * add Applitools env to context * remove VRT CircleCI workflows from config * add branchName to applitools configs * add parentBranchName to applitools configs * update release notes
1 parent ab6b6e7 commit 4955397

File tree

9 files changed

+307
-252
lines changed

9 files changed

+307
-252
lines changed

.circleci/config.yml

Lines changed: 0 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -522,67 +522,6 @@ jobs:
522522
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
523523
done
524524
525-
vrt-init:
526-
executor: slds-executor
527-
resource_class: small
528-
529-
steps:
530-
- checkout
531-
- run: mkdir -p workspace
532-
- gh/install
533-
- get-pr-number
534-
535-
- persist_to_workspace:
536-
root: workspace
537-
paths:
538-
- gh-pr-num.txt
539-
540-
vrt-desktop:
541-
executor: slds-executor
542-
resource_class: large
543-
544-
steps:
545-
- prepare-vrt
546-
547-
# run Applitools tests!
548-
- run:
549-
name: Applitools
550-
command: 'VRT_MODE=<< pipeline.parameters.vrt_mode >> npx eyes-storybook' # -u https://${REVIEW_APP_NAME}.herokuapp.com
551-
no_output_timeout: 20m
552-
553-
vrt-mobile:
554-
executor: slds-executor
555-
resource_class: large
556-
557-
steps:
558-
- prepare-vrt
559-
560-
# run Applitools tests!
561-
- run:
562-
name: Applitools (mobile)
563-
command: 'STORYBOOK_STORIES_TYPE=mobile npx eyes-storybook --conf applitools.mobile.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
564-
no_output_timeout: 20m
565-
566-
vrt-legacy:
567-
executor: slds-executor
568-
resource_class: large
569-
570-
steps:
571-
- prepare-vrt
572-
573-
# run Applitools tests!
574-
- run:
575-
name: Applitools (legacy)
576-
command: 'STORYBOOK_SLDS_VERSION=legacy npx eyes-storybook --conf applitools.legacy.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
577-
no_output_timeout: 20m
578-
579-
vrt-close:
580-
executor: slds-executor
581-
resource_class: small
582-
583-
steps:
584-
- vrt-close-batch
585-
586525
workflows:
587526
version: 2
588527
CI:
@@ -635,117 +574,3 @@ workflows:
635574
only: /^v\d+\.\d+\.\d+.*/
636575
branches:
637576
ignore: /.*/
638-
639-
CI_scheduled:
640-
triggers:
641-
- schedule:
642-
cron: "0 0 * * *"
643-
filters:
644-
branches:
645-
only:
646-
# filtering only for this integration branch, for now
647-
- 236-spring-22
648-
jobs:
649-
- vrt-init:
650-
context: ux-eng-keys
651-
filters:
652-
tags:
653-
only: /.*/
654-
- vrt-desktop:
655-
context: ux-eng-keys
656-
# do not run for main version branches
657-
filters:
658-
branches:
659-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
660-
requires:
661-
- vrt-init
662-
- vrt-mobile:
663-
context: ux-eng-keys
664-
# do not run for main version branches
665-
filters:
666-
branches:
667-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
668-
requires:
669-
- vrt-init
670-
- vrt-legacy:
671-
context: ux-eng-keys
672-
# do not run for main version branches
673-
filters:
674-
branches:
675-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
676-
requires:
677-
- vrt-init
678-
- vrt-close:
679-
context: ux-eng-keys
680-
requires:
681-
- vrt-desktop
682-
- vrt-mobile
683-
- vrt-legacy
684-
685-
# This runs when a PR is labeled: vrt:chrome-ready
686-
CI_VRT_chrome:
687-
when:
688-
and:
689-
- << pipeline.parameters.run_labeled_workflow >>
690-
- equal: [ chrome, << pipeline.parameters.vrt_mode >>]
691-
jobs:
692-
- vrt-init:
693-
context: ux-eng-keys
694-
filters:
695-
tags:
696-
only: /.*/
697-
- vrt-desktop:
698-
context: ux-eng-keys
699-
# do not run for main version branches
700-
filters:
701-
branches:
702-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
703-
requires:
704-
- vrt-init
705-
- vrt-close:
706-
context: ux-eng-keys
707-
requires:
708-
- vrt-desktop
709-
710-
# This runs when a PR is labeled: vrt:full-ready
711-
CI_VRT_full:
712-
when:
713-
and:
714-
- << pipeline.parameters.run_labeled_workflow >>
715-
- equal: [ full, << pipeline.parameters.vrt_mode >>]
716-
jobs:
717-
- vrt-init:
718-
context: ux-eng-keys
719-
filters:
720-
tags:
721-
only: /.*/
722-
- vrt-desktop:
723-
context: ux-eng-keys
724-
# do not run for main version branches
725-
filters:
726-
branches:
727-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
728-
requires:
729-
- vrt-init
730-
- vrt-mobile:
731-
context: ux-eng-keys
732-
# do not run for main version branches
733-
filters:
734-
branches:
735-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
736-
requires:
737-
- vrt-init
738-
- vrt-legacy:
739-
context: ux-eng-keys
740-
# do not run for main version branches
741-
filters:
742-
branches:
743-
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
744-
requires:
745-
- vrt-init
746-
- vrt-close:
747-
context: ux-eng-keys
748-
requires:
749-
- vrt-desktop
750-
- vrt-mobile
751-
- vrt-legacy

.github/workflows/on-pr-labeled.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/vrt.yml

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
name: Trigger VRT from Label
2+
3+
on:
4+
pull_request:
5+
types: [labeled]
6+
7+
env:
8+
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
9+
APPLITOOLS_BATCH_ID: ${{ github.sha }}
10+
APPLITOOLS_BATCH_NAME: PR ${{ github.event.pull_request.number }} (${{ github.actor }})
11+
APPLITOOLS_DONT_CLOSE_BATCHES: true
12+
APPLITOOLS_BATCH_NOTIFY: true
13+
APPLITOOLS_REPO_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
14+
REVIEW_APP_NAME: slds-storybook-pr-${{ github.event.pull_request.number }}
15+
16+
jobs:
17+
vrt-init:
18+
if: ${{ github.event.label.name == 'vrt:chrome-ready' || github.event.label.name == 'vrt:full-ready'}}
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Set VRT Mode parameter
23+
run: |
24+
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
25+
26+
- name: Print context
27+
env:
28+
GITHUB_CONTEXT: ${{ toJson(github) }}
29+
run: |
30+
echo "$GITHUB_CONTEXT"
31+
- run: printenv | sort
32+
33+
- uses: actions/checkout@v2
34+
- uses: actions/setup-node@v3
35+
with:
36+
cache: 'npm'
37+
38+
vrt-desktop:
39+
needs: vrt-init
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- uses: actions/checkout@v2
44+
- uses: actions/setup-node@v3
45+
with:
46+
cache: 'npm'
47+
48+
- name: Add Applitools eyes-storybook module
49+
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
50+
- run: npm ci
51+
- name: Prepare Storybook
52+
run: npm run storybook:prepare
53+
# Hack to create TTY for GitHub Actions runners
54+
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
55+
shell: 'script -q -e -c "bash {0}"'
56+
57+
- run: printenv | sort
58+
59+
- name: Set VRT Mode parameter
60+
run: |
61+
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
62+
63+
- name: Applitools
64+
run: 'VRT_MODE=${{ env.VRT_MODE }} npx eyes-storybook'
65+
timeout-minutes: 20
66+
67+
vrt-legacy:
68+
if: ${{ github.event.label.name == 'vrt:full-ready'}}
69+
needs: vrt-init
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- uses: actions/checkout@v2
74+
- uses: actions/setup-node@v3
75+
with:
76+
cache: 'npm'
77+
78+
- name: Add Applitools eyes-storybook module
79+
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
80+
- run: npm ci
81+
82+
- name: Prepare Storybook
83+
run: npm run storybook:prepare
84+
# Hack to create TTY for GitHub Actions runners
85+
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
86+
shell: 'script -q -e -c "bash {0}"'
87+
88+
- run: printenv | sort
89+
90+
- name: Set VRT Mode parameter
91+
run: |
92+
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
93+
94+
- name: Applitools
95+
run: 'STORYBOOK_SLDS_VERSION=legacy npx eyes-storybook --conf applitools.legacy.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
96+
timeout-minutes: 20
97+
98+
vrt-mobile:
99+
if: ${{ github.event.label.name == 'vrt:full-ready'}}
100+
needs: vrt-init
101+
runs-on: ubuntu-latest
102+
103+
steps:
104+
- uses: actions/checkout@v2
105+
- uses: actions/setup-node@v3
106+
with:
107+
cache: 'npm'
108+
109+
- name: Add Applitools eyes-storybook module
110+
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
111+
- run: npm ci
112+
113+
- name: Prepare Storybook
114+
run: npm run storybook:prepare
115+
# Hack to create TTY for GitHub Actions runners
116+
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
117+
shell: 'script -q -e -c "bash {0}"'
118+
119+
- run: printenv | sort
120+
121+
- name: Set VRT Mode parameter
122+
run: |
123+
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
124+
125+
- name: Applitools
126+
run: 'STORYBOOK_SLDS_VERSION=mobile npx eyes-storybook --conf applitools.mobile.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
127+
timeout-minutes: 20
128+
129+
vrt-wrap:
130+
needs: [vrt-desktop, vrt-legacy, vrt-mobile]
131+
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
132+
runs-on: ubuntu-latest
133+
env:
134+
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
135+
136+
steps:
137+
- name: Get Applitools Latest Batch
138+
id: applitools_batch
139+
run: echo "batches=$(curl -H "X-Eyes-Api-Key:${{ secrets.APPLITOOLS_API_KEY }}" -X GET "https://salesforceuxeyesapi.applitools.com/api/v1/batches" | jq -rc '.batches[0]')" >> $GITHUB_OUTPUT
140+
141+
- name: Show Applitools Latest Batch
142+
# single quotes are needed around the JSON string here to preserve the double quotes around the props and values
143+
run: echo '${{ steps.applitools_batch.outputs.batches }}'
144+
145+
- uses: tibdex/github-app-token@v1
146+
id: get_installation_token
147+
with:
148+
app_id: 244972
149+
private_key: ${{ secrets.DSE_CI_APP_KEY }}
150+
151+
- name: Dump GitHub context event
152+
id: github_context_event_step
153+
run: echo '${{ toJSON(github.event) }}'
154+
155+
- name: Show GitHub context
156+
env:
157+
GITHUB_CONTEXT: ${{ toJson(github) }}
158+
run: echo "$GITHUB_CONTEXT"
159+
160+
- uses: actions/checkout@v2
161+
162+
- uses: actions/setup-node@v3
163+
with:
164+
cache: 'npm'
165+
166+
- name: Install OctoKit
167+
run: npm i @octokit/core @octokit/auth-app @octokit/rest
168+
169+
- name: Do the check
170+
env:
171+
THE_SHA: ${{ github.event.pull_request.head.sha }}
172+
OCTOKIT_PAT: ${{ steps.get_installation_token.outputs.token }}
173+
GH_APP_ID: 244972
174+
GH_APP_INSTALLATION_ID: 29956208
175+
GH_APP_PRIVATE_KEY: ${{ secrets.DSE_CI_APP_KEY }}
176+
GH_APP_CLIENT_ID: Iv1.6aaf118377862b49
177+
GH_APP_CLIENT_SECRET: ${{ secrets.DSE_CI_CLIENT_SECRET }}
178+
# single quotes are needed around the JSON string here so that is can be parsed by the node script
179+
run: batchesData='${{ steps.applitools_batch.outputs.batches }}' node scripts/ci/pr-checks

0 commit comments

Comments
 (0)