Skip to content

Commit

Permalink
Use reusable workflow for running Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasecdb committed Jul 27, 2022
1 parent 7d25585 commit 9bc9f8b
Showing 1 changed file with 11 additions and 101 deletions.
112 changes: 11 additions & 101 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,104 +4,14 @@ on:
branches:
- v1.x
jobs:
create-workspace:
name: Create workspace
runs-on: ubuntu-latest
steps:
- name: Delete previous comment
uses: marocchino/sticky-pull-request-comment@v2
with:
delete: true
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install toolbelt
run: |
yarn global add vtex
echo "$(yarn global bin)" >> $GITHUB_PATH
- run: vtex
- uses: actions/checkout@v2
with:
repository: vtex/search-tests
path: search-tests
- uses: actions/checkout@v2
with:
path: ioapp
- run: yarn
working-directory: search-tests
- name: Create session
run: node ci/createSession.js --appkey=${{ secrets.APP_KEY }} --apptoken=${{ secrets.APP_TOKEN }}
working-directory: search-tests
- name: Create workspace
run: |
yes | vtex workspace use e2e${{ github.sha }}
- name: Link app
run: vtex link --no-watch
working-directory: ioapp
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
key: ${{ github.sha }}
e2e-tests:
name: E2E tests
runs-on: ubuntu-latest
needs: create-workspace
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4]
steps:
- name: Restore cache
uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Get committer email
working-directory: ioapp
run: |
echo "COMMIT_INFO_EMAIL=`git log --format='%ae' HEAD^!`" >> $GITHUB_ENV
- uses: cypress-io/github-action@v2
with:
config-file: cypress.json
working-directory: search-tests
record: true
parallel: true
env:
CYPRESS_RECORD_KEY: ${{ secrets.RECORD_KEY }}
CYPRESS_VTEX_WORKSPACE: e2e${{ github.sha }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COMMIT_INFO_BRANCH: ${{ github.head_ref }}
COMMIT_INFO_SHA: ${{ github.sha }}
COMMIT_INFO_REMOTE: ${{ github.repository }}
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
COMMIT_INFO_AUTHOR: ${{ github.event.pull_request.user.login }}
- name: Add comment
uses: marocchino/sticky-pull-request-comment@v2
if: failure()
with:
message: E2E tests failed. Go to https://dashboard.cypress.io/projects/qvjzx1 to check the recordings.
delete-workspace:
name: Delete workspace
runs-on: ubuntu-latest
if: ${{ always() }}
needs: e2e-tests
steps:
- name: Restore cache
uses: actions/cache@v2
id: restore-build
with:
path: ./*
key: ${{ github.sha }}
- name: Install toolbelt
run: |
yarn global add vtex
echo "$(yarn global bin)" >> $GITHUB_PATH
- name: Create session
run: node ci/createSession.js --appkey=${{ secrets.APP_KEY }} --apptoken=${{ secrets.APP_TOKEN }}
working-directory: search-tests
- name: Delete workspace
run: |
vtex workspace use master
yes | vtex workspace delete e2e${{ github.sha }}
Cypress:
uses: vtex/action-io-app-cypress/.github/workflows/cypress.yml@v1
with:
accounts: '["biggy"]'
tests-repository: vtex/search-tests
containers: 4
parallel: true
secrets:
app-key: ${{ secrets.APP_KEY }}
app-token: ${{ secrets.APP_TOKEN }}
record-key: ${{ secrets.RECORD_KEY }}

0 comments on commit 9bc9f8b

Please sign in to comment.