2023-01-20 10:21:22 +00:00
|
|
|
name: Cypress tests - PR
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- develop
|
|
|
|
- main
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- reopened
|
|
|
|
- synchronize
|
|
|
|
- ready_for_review
|
|
|
|
jobs:
|
|
|
|
pr:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout frontend mono repo
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
|
|
|
|
- name: Remove package.json & yarn.lock to avoid installing everything
|
|
|
|
run: rm package.json yarn.lock
|
|
|
|
|
|
|
|
- name: Install nx
|
|
|
|
run: yarn add nx
|
|
|
|
|
|
|
|
# Check SHAs
|
|
|
|
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
|
|
|
uses: nrwl/nx-set-shas@v2
|
|
|
|
with:
|
|
|
|
main-branch-name: ${{ github.base_ref || github.ref_name }}
|
|
|
|
set-environment-variables-for-job: true
|
|
|
|
|
|
|
|
# See affected apps
|
|
|
|
- name: See affected apps
|
|
|
|
run: |
|
|
|
|
affected=$(yarn nx print-affected --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} --select=projects)
|
2023-01-25 08:43:11 +00:00
|
|
|
echo -n "Affected projects: $affected"
|
2023-01-20 10:21:22 +00:00
|
|
|
projects=""
|
2023-03-01 12:35:13 +00:00
|
|
|
if [[ $affected == *"governance"* ]]; then projects+='"governance-e2e" '; fi
|
2023-01-20 10:21:22 +00:00
|
|
|
if [[ $affected == *"trading"* ]]; then projects+='"trading-e2e" '; fi
|
|
|
|
if [[ $affected == *"explorer"* ]]; then projects+='"explorer-e2e" '; fi
|
2023-03-01 12:35:13 +00:00
|
|
|
if [[ -z "$projects" ]]; then projects+='"governance-e2e" "trading-e2e" "explorer-e2e" '; fi
|
2023-01-20 10:21:22 +00:00
|
|
|
projects=${projects%?}
|
|
|
|
projects=[${projects// /,}]
|
|
|
|
echo PROJECTS=$projects >> $GITHUB_ENV
|
|
|
|
|
|
|
|
outputs:
|
|
|
|
projects: ${{ env.PROJECTS }}
|
|
|
|
|
|
|
|
run:
|
|
|
|
needs: pr
|
2023-01-24 12:25:29 +00:00
|
|
|
if: ${{ needs.pr.outputs.projects != '[]' }}
|
2023-01-20 10:21:22 +00:00
|
|
|
uses: ./.github/workflows/cypress-run.yml
|
|
|
|
secrets: inherit
|
|
|
|
with:
|
|
|
|
projects: ${{ needs.pr.outputs.projects }}
|
|
|
|
tags: '@smoke @regression'
|
|
|
|
|
|
|
|
# Report single result at the end, to avoid mess with required checks in PR
|
|
|
|
result:
|
|
|
|
if: ${{ always() }}
|
|
|
|
needs: run
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Cypress result
|
|
|
|
steps:
|
|
|
|
- run: |
|
|
|
|
result="${{ needs.run.result }}"
|
|
|
|
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|