2021-02-09 16:28:01 +01:00
|
|
|
name: Cypress Component
|
|
|
|
|
|
|
|
on:
|
|
|
|
- pull_request
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
cypress-component:
|
|
|
|
name: Cypress component tests
|
|
|
|
runs-on: ubuntu-18.04
|
2021-03-30 17:17:58 +02:00
|
|
|
if: ${{ github.actor != 'posthog-contributions-bot[bot]' }}
|
2021-03-30 16:12:48 +02:00
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v1
|
|
|
|
- uses: actions/setup-node@v1
|
|
|
|
with:
|
|
|
|
node-version: 14
|
2021-05-25 18:25:37 +02:00
|
|
|
- uses: actions/cache@v2
|
|
|
|
id: cypress-node-modules-cache
|
2021-02-09 16:28:01 +01:00
|
|
|
with:
|
2021-05-25 18:25:37 +02:00
|
|
|
path: |
|
2021-05-26 22:32:15 +02:00
|
|
|
**/node_modules
|
2021-05-25 18:25:37 +02:00
|
|
|
key: ${{ runner.os }}-cypress-node-modules-${{ hashFiles('**/yarn.lock') }}
|
2021-02-09 16:28:01 +01:00
|
|
|
restore-keys: |
|
2021-05-25 18:25:37 +02:00
|
|
|
${{ runner.os }}-cypress-node-modules
|
2021-02-09 16:28:01 +01:00
|
|
|
- name: Yarn install deps
|
2021-05-25 18:25:37 +02:00
|
|
|
if: steps.cypress-node-modules-cache.outputs.cache-hit != 'true'
|
2021-02-09 16:28:01 +01:00
|
|
|
run: |
|
2021-04-06 18:21:21 +02:00
|
|
|
yarn install --frozen-lockfile
|
2021-05-25 18:25:37 +02:00
|
|
|
- uses: actions/cache@v2
|
|
|
|
id: cypress-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.cache/Cypress
|
2021-05-26 22:32:15 +02:00
|
|
|
**/node_modules/cypress
|
|
|
|
**/node_modules/cypress-terminal-report
|
|
|
|
**/node_modules/@cypress
|
2021-05-25 18:25:37 +02:00
|
|
|
key: ${{ runner.os }}-cypress-6.7.0
|
|
|
|
- name: Install cypress
|
|
|
|
if: steps.cypress-cache.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
yarn add cypress@6.7.0 cypress-terminal-report@2.1.0 @cypress/react@4.16.4 @cypress/webpack-preprocessor@5.7.0
|
2021-02-09 16:28:01 +01:00
|
|
|
- uses: actions/cache@v1
|
|
|
|
name: Setup Yarn build cache
|
|
|
|
id: yarn-build-cache
|
|
|
|
with:
|
|
|
|
path: frontend/dist
|
|
|
|
key: ${{ runner.os }}-yarn-build-${{ hashFiles('frontend/src/') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-yarn-build-
|
|
|
|
- name: Yarn build
|
2021-05-25 18:25:37 +02:00
|
|
|
if: steps.yarn-build-cache.outputs.cache-hit != 'true'
|
2021-02-09 16:28:01 +01:00
|
|
|
run: |
|
|
|
|
yarn build
|
2021-05-25 18:25:37 +02:00
|
|
|
|
2021-02-09 16:28:01 +01:00
|
|
|
- name: Cypress run
|
|
|
|
uses: cypress-io/github-action@v2
|
|
|
|
with:
|
|
|
|
config-file: cypress.json
|
|
|
|
record: true
|
|
|
|
parallel: true
|
|
|
|
group: 'PostHog Component'
|
2021-05-25 18:25:37 +02:00
|
|
|
# We're already installing cypress above
|
|
|
|
# We have to install it separately otherwise the tests fail.
|
|
|
|
install: false
|
|
|
|
# We already install cypress separately, we don't need to install it again here
|
|
|
|
install-command: echo "no"
|
2021-02-09 16:28:01 +01:00
|
|
|
env:
|
|
|
|
# pass the Dashboard record key as an environment variable
|
|
|
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
|
|
# Recommended: pass the GitHub token lets this action correctly
|
|
|
|
# determine the unique run id necessary to re-run the checks
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Archive test screenshots
|
|
|
|
uses: actions/upload-artifact@v1
|
|
|
|
with:
|
|
|
|
name: screenshots
|
|
|
|
path: cypress/screenshots
|
|
|
|
if: ${{ failure() }}
|