Skip to content

Commit

Permalink
feat(ci): Migrate VRT CircleCI jobs to GH Actions (#5092)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Dottenpixel authored Nov 8, 2022
1 parent ab6b6e7 commit 4955397
Show file tree
Hide file tree
Showing 9 changed files with 307 additions and 252 deletions.
175 changes: 0 additions & 175 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -522,67 +522,6 @@ jobs:
gh api ${STATUS_URL} -f state=success -f environment_url=${SITE_URL} -H "Accept: application/vnd.github.ant-man-preview+json"
done
vrt-init:
executor: slds-executor
resource_class: small

steps:
- checkout
- run: mkdir -p workspace
- gh/install
- get-pr-number

- persist_to_workspace:
root: workspace
paths:
- gh-pr-num.txt

vrt-desktop:
executor: slds-executor
resource_class: large

steps:
- prepare-vrt

# run Applitools tests!
- run:
name: Applitools
command: 'VRT_MODE=<< pipeline.parameters.vrt_mode >> npx eyes-storybook' # -u https://${REVIEW_APP_NAME}.herokuapp.com
no_output_timeout: 20m

vrt-mobile:
executor: slds-executor
resource_class: large

steps:
- prepare-vrt

# run Applitools tests!
- run:
name: Applitools (mobile)
command: 'STORYBOOK_STORIES_TYPE=mobile npx eyes-storybook --conf applitools.mobile.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
no_output_timeout: 20m

vrt-legacy:
executor: slds-executor
resource_class: large

steps:
- prepare-vrt

# run Applitools tests!
- run:
name: Applitools (legacy)
command: 'STORYBOOK_SLDS_VERSION=legacy npx eyes-storybook --conf applitools.legacy.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
no_output_timeout: 20m

vrt-close:
executor: slds-executor
resource_class: small

steps:
- vrt-close-batch

workflows:
version: 2
CI:
Expand Down Expand Up @@ -635,117 +574,3 @@ workflows:
only: /^v\d+\.\d+\.\d+.*/
branches:
ignore: /.*/

CI_scheduled:
triggers:
- schedule:
cron: "0 0 * * *"
filters:
branches:
only:
# filtering only for this integration branch, for now
- 236-spring-22
jobs:
- vrt-init:
context: ux-eng-keys
filters:
tags:
only: /.*/
- vrt-desktop:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-mobile:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-legacy:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-close:
context: ux-eng-keys
requires:
- vrt-desktop
- vrt-mobile
- vrt-legacy

# This runs when a PR is labeled: vrt:chrome-ready
CI_VRT_chrome:
when:
and:
- << pipeline.parameters.run_labeled_workflow >>
- equal: [ chrome, << pipeline.parameters.vrt_mode >>]
jobs:
- vrt-init:
context: ux-eng-keys
filters:
tags:
only: /.*/
- vrt-desktop:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-close:
context: ux-eng-keys
requires:
- vrt-desktop

# This runs when a PR is labeled: vrt:full-ready
CI_VRT_full:
when:
and:
- << pipeline.parameters.run_labeled_workflow >>
- equal: [ full, << pipeline.parameters.vrt_mode >>]
jobs:
- vrt-init:
context: ux-eng-keys
filters:
tags:
only: /.*/
- vrt-desktop:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-mobile:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-legacy:
context: ux-eng-keys
# do not run for main version branches
filters:
branches:
ignore: /^\d{3}-(summer|spring|winter)-\d{2}$/
requires:
- vrt-init
- vrt-close:
context: ux-eng-keys
requires:
- vrt-desktop
- vrt-mobile
- vrt-legacy
26 changes: 0 additions & 26 deletions .github/workflows/on-pr-labeled.yml

This file was deleted.

179 changes: 179 additions & 0 deletions .github/workflows/vrt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
name: Trigger VRT from Label

on:
pull_request:
types: [labeled]

env:
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}
APPLITOOLS_BATCH_ID: ${{ github.sha }}
APPLITOOLS_BATCH_NAME: PR ${{ github.event.pull_request.number }} (${{ github.actor }})
APPLITOOLS_DONT_CLOSE_BATCHES: true
APPLITOOLS_BATCH_NOTIFY: true
APPLITOOLS_REPO_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
REVIEW_APP_NAME: slds-storybook-pr-${{ github.event.pull_request.number }}

jobs:
vrt-init:
if: ${{ github.event.label.name == 'vrt:chrome-ready' || github.event.label.name == 'vrt:full-ready'}}
runs-on: ubuntu-latest

steps:
- name: Set VRT Mode parameter
run: |
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
- name: Print context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
- run: printenv | sort

- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'npm'

vrt-desktop:
needs: vrt-init
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'npm'

- name: Add Applitools eyes-storybook module
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
- run: npm ci
- name: Prepare Storybook
run: npm run storybook:prepare
# Hack to create TTY for GitHub Actions runners
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
shell: 'script -q -e -c "bash {0}"'

- run: printenv | sort

- name: Set VRT Mode parameter
run: |
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
- name: Applitools
run: 'VRT_MODE=${{ env.VRT_MODE }} npx eyes-storybook'
timeout-minutes: 20

vrt-legacy:
if: ${{ github.event.label.name == 'vrt:full-ready'}}
needs: vrt-init
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'npm'

- name: Add Applitools eyes-storybook module
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
- run: npm ci

- name: Prepare Storybook
run: npm run storybook:prepare
# Hack to create TTY for GitHub Actions runners
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
shell: 'script -q -e -c "bash {0}"'

- run: printenv | sort

- name: Set VRT Mode parameter
run: |
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
- name: Applitools
run: 'STORYBOOK_SLDS_VERSION=legacy npx eyes-storybook --conf applitools.legacy.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
timeout-minutes: 20

vrt-mobile:
if: ${{ github.event.label.name == 'vrt:full-ready'}}
needs: vrt-init
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
cache: 'npm'

- name: Add Applitools eyes-storybook module
run: npm i @applitools/eyes-storybook@latest --save-dev --package-lock-only
- run: npm ci

- name: Prepare Storybook
run: npm run storybook:prepare
# Hack to create TTY for GitHub Actions runners
# https://github.com/gfx/example-github-actions-with-tty#hack-to-create-tty-for-github-actions-runners
shell: 'script -q -e -c "bash {0}"'

- run: printenv | sort

- name: Set VRT Mode parameter
run: |
echo "VRT_MODE=$(echo ${{ github.event.label.name }} | sed 's/\(.*\):\(.*\)-\(.*\)/\2/')" >> $GITHUB_ENV
- name: Applitools
run: 'STORYBOOK_SLDS_VERSION=mobile npx eyes-storybook --conf applitools.mobile.config.js' # -u https://${REVIEW_APP_NAME}.herokuapp.com
timeout-minutes: 20

vrt-wrap:
needs: [vrt-desktop, vrt-legacy, vrt-mobile]
if: always() && !cancelled() && !contains(needs.*.result, 'failure')
runs-on: ubuntu-latest
env:
APPLITOOLS_API_KEY: ${{ secrets.APPLITOOLS_API_KEY }}

steps:
- name: Get Applitools Latest Batch
id: applitools_batch
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

- name: Show Applitools Latest Batch
# single quotes are needed around the JSON string here to preserve the double quotes around the props and values
run: echo '${{ steps.applitools_batch.outputs.batches }}'

- uses: tibdex/github-app-token@v1
id: get_installation_token
with:
app_id: 244972
private_key: ${{ secrets.DSE_CI_APP_KEY }}

- name: Dump GitHub context event
id: github_context_event_step
run: echo '${{ toJSON(github.event) }}'

- name: Show GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"

- uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
cache: 'npm'

- name: Install OctoKit
run: npm i @octokit/core @octokit/auth-app @octokit/rest

- name: Do the check
env:
THE_SHA: ${{ github.event.pull_request.head.sha }}
OCTOKIT_PAT: ${{ steps.get_installation_token.outputs.token }}
GH_APP_ID: 244972
GH_APP_INSTALLATION_ID: 29956208
GH_APP_PRIVATE_KEY: ${{ secrets.DSE_CI_APP_KEY }}
GH_APP_CLIENT_ID: Iv1.6aaf118377862b49
GH_APP_CLIENT_SECRET: ${{ secrets.DSE_CI_CLIENT_SECRET }}
# single quotes are needed around the JSON string here so that is can be parsed by the node script
run: batchesData='${{ steps.applitools_batch.outputs.batches }}' node scripts/ci/pr-checks
Loading

0 comments on commit 4955397

Please sign in to comment.