2023-04-03 13:53:50 +00:00
|
|
|
name: (CI) Cypress Run
|
2022-11-04 13:13:54 +00:00
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
2023-01-20 10:21:22 +00:00
|
|
|
projects:
|
2022-11-08 15:58:46 +00:00
|
|
|
required: true
|
|
|
|
type: string
|
2022-11-08 10:33:22 +00:00
|
|
|
skip-cache:
|
|
|
|
required: false
|
2023-01-20 10:21:22 +00:00
|
|
|
type: boolean
|
2022-11-04 13:13:54 +00:00
|
|
|
tags:
|
|
|
|
required: false
|
|
|
|
type: string
|
|
|
|
|
|
|
|
jobs:
|
2023-09-28 09:25:44 +00:00
|
|
|
runner-choice:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
runner: ${{ steps.step.outputs.runner }}
|
|
|
|
steps:
|
|
|
|
- name: Check branch
|
|
|
|
id: step
|
|
|
|
run: |
|
2023-10-03 09:44:12 +00:00
|
|
|
if [ '${{ github.base_ref }}' == 'main' ]; then
|
2023-09-28 09:25:44 +00:00
|
|
|
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
2023-10-03 09:44:12 +00:00
|
|
|
elif [[ '${{ github.base_ref }}' == 'develop' && '${{ github.ref_name }}' == 'main' ]]; then
|
2023-09-29 15:36:18 +00:00
|
|
|
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
2023-10-03 09:44:12 +00:00
|
|
|
elif [[ '${{ github.event_name }}' == 'push' && ${{ contains(github.ref_name, 'release/mainnet') }} ]]; then
|
2023-09-29 15:00:20 +00:00
|
|
|
echo "runner=mainnet-compatible-runner" >> $GITHUB_OUTPUT
|
2023-09-28 09:25:44 +00:00
|
|
|
else
|
|
|
|
echo "runner=self-hosted-runner" >> $GITHUB_OUTPUT
|
|
|
|
fi
|
|
|
|
|
2023-09-29 15:00:20 +00:00
|
|
|
- name: Print runner
|
|
|
|
run: echo ${{ steps.step.outputs.runner }}
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
e2e:
|
|
|
|
strategy:
|
2023-01-24 12:25:29 +00:00
|
|
|
fail-fast: false
|
2023-01-20 10:21:22 +00:00
|
|
|
matrix:
|
|
|
|
project: ${{ fromJSON(inputs.projects) }}
|
2023-03-24 15:42:33 +00:00
|
|
|
name: ${{ matrix.project }}
|
2023-09-28 09:25:44 +00:00
|
|
|
needs: runner-choice
|
|
|
|
runs-on: ${{ needs.runner-choice.outputs.runner }}
|
2023-08-16 15:53:24 +00:00
|
|
|
timeout-minutes: 120
|
2022-11-04 13:13:54 +00:00
|
|
|
steps:
|
2023-01-20 10:21:22 +00:00
|
|
|
# Checks if skip cache was requested
|
|
|
|
- name: Set skip-nx-cache flag
|
|
|
|
if: ${{ inputs.skip-cache == true }}
|
2023-01-24 15:59:53 +00:00
|
|
|
run: echo "SKIP_CACHE=--skip-nx-cache" >> $GITHUB_ENV
|
2022-12-09 14:20:03 +00:00
|
|
|
|
2022-11-04 13:13:54 +00:00
|
|
|
# Checkout front ends
|
|
|
|
- name: Checkout frontend mono repo
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
path: './frontend-monorepo'
|
2023-06-27 09:18:13 +00:00
|
|
|
ref: ${{ github.event.pull_request.head.sha || github.sha }}
|
2022-11-04 13:13:54 +00:00
|
|
|
|
|
|
|
# Restore node_modules from cache if possible
|
|
|
|
- name: Restore node_modules from cache
|
2023-09-06 20:35:49 +00:00
|
|
|
id: cache-node-modules
|
2022-11-04 13:13:54 +00:00
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
frontend-monorepo/node_modules
|
|
|
|
/home/runner/.cache/Cypress
|
2023-01-17 16:01:01 +00:00
|
|
|
key: node_modules_cypress-${{ hashFiles('frontend-monorepo/yarn.lock', 'frontend-monorepo/package.json') }}
|
2022-11-04 13:13:54 +00:00
|
|
|
|
|
|
|
# Install frontend dependencies
|
|
|
|
- name: Install root dependencies
|
2023-09-06 20:35:49 +00:00
|
|
|
if: steps.cache-node-modules.outputs.cache-hit != 'true'
|
2022-11-04 13:13:54 +00:00
|
|
|
run: yarn install --frozen-lockfile
|
|
|
|
working-directory: frontend-monorepo
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
# Make sure that all Cypress binaries are installed properly
|
|
|
|
- name: Install cypress bins
|
|
|
|
run: yarn cypress install
|
|
|
|
working-directory: frontend-monorepo
|
|
|
|
|
2022-11-04 13:13:54 +00:00
|
|
|
######
|
2023-01-20 10:21:22 +00:00
|
|
|
## Setup Vegacapsule and Vega wallet
|
2022-11-04 13:13:54 +00:00
|
|
|
######
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
- name: Run Vegacapsule network and Vega wallet
|
2022-12-05 16:51:53 +00:00
|
|
|
id: setup-vega
|
2023-01-20 10:21:22 +00:00
|
|
|
uses: ./frontend-monorepo/.github/actions/run-vegacapsule
|
2023-10-02 14:12:24 +00:00
|
|
|
timeout-minutes: 10
|
2022-11-04 13:13:54 +00:00
|
|
|
|
|
|
|
######
|
|
|
|
## Run some tests
|
|
|
|
######
|
|
|
|
|
|
|
|
- name: Run Cypress tests
|
2023-09-06 20:35:49 +00:00
|
|
|
run: yarn nx run ${{ matrix.project }}:e2e ${{ env.SKIP_CACHE }} --browser chrome --env.grepTags="${{ inputs.tags }}"
|
2022-11-04 13:13:54 +00:00
|
|
|
working-directory: frontend-monorepo
|
|
|
|
env:
|
|
|
|
CYPRESS_SLACK_WEBHOOK: ${{ secrets.CYPRESS_SLACK_WEBHOOK }}
|
2022-12-05 16:51:53 +00:00
|
|
|
CYPRESS_VEGA_WALLET_API_TOKEN: ${{ steps.setup-vega.outputs.token }}
|
2022-11-04 13:13:54 +00:00
|
|
|
|
|
|
|
######
|
|
|
|
## Upload logs
|
|
|
|
######
|
|
|
|
|
2022-12-22 11:12:54 +00:00
|
|
|
# Artifact path is not valid: /ganache-1/capsule-logscolletor.stderr-2022-12-22T10:20:30Z.log. Contains the following character: Colon :
|
|
|
|
- name: Rename files to allow archive
|
|
|
|
if: ${{ always() }}
|
|
|
|
run: |
|
|
|
|
while read -r file; do
|
|
|
|
mv "${file}" "$(echo ${file} | sed 's|:|-|g')"
|
|
|
|
done< <(find /home/runner/.vegacapsule/testnet/logs -type f)
|
|
|
|
|
2023-02-15 09:11:01 +00:00
|
|
|
- name: Print logs files
|
|
|
|
if: ${{ always() }}
|
|
|
|
run: ls -alsh /home/runner/.vegacapsule/testnet/logs/
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2023-03-10 14:37:49 +00:00
|
|
|
if: ${{ failure() }}
|
2022-11-04 13:13:54 +00:00
|
|
|
with:
|
2023-04-24 13:28:42 +00:00
|
|
|
name: logs-${{ matrix.project }}
|
|
|
|
path: /home/runner/.vegacapsule/testnet/logs
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
if: ${{ failure() }}
|
|
|
|
with:
|
|
|
|
name: test-report-${{ matrix.project }}
|
2023-05-17 15:21:10 +00:00
|
|
|
path: frontend-monorepo/apps/${{ matrix.project }}/cypress/reports
|