2023-03-24 15:42:33 +00:00
|
|
|
name: PR Validations
|
2023-01-20 10:21:22 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2023-03-24 15:42:33 +00:00
|
|
|
- name: Check node version
|
|
|
|
id: node-version
|
|
|
|
run: |
|
|
|
|
npmVersion=$(cat .nvmrc | head -n 1)
|
|
|
|
echo ::set-output name=npmVersion::${npmVersion}
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
2023-03-24 15:42:33 +00:00
|
|
|
with:
|
|
|
|
node-version: ${{ steps.node-version.outputs.npmVersion }}
|
2023-01-20 10:21:22 +00:00
|
|
|
|
|
|
|
# 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: |
|
2023-03-24 15:42:33 +00:00
|
|
|
nx_version=$(cat package.json | grep '"nx"' | cut -d ':' -f 2 | tr -d '",[:space:]')
|
|
|
|
rm package.json yarn.lock
|
|
|
|
yarn add nx@$nx_version
|
2023-01-20 10:21:22 +00:00
|
|
|
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-03-24 15:42:33 +00:00
|
|
|
projects_e2e=""
|
|
|
|
if [[ $affected == *"governance"* ]]; then projects_e2e+='"governance-e2e" '; fi
|
|
|
|
if [[ $affected == *"trading"* ]]; then projects_e2e+='"trading-e2e" '; fi
|
|
|
|
if [[ $affected == *"explorer"* ]]; then projects_e2e+='"explorer-e2e" '; fi
|
|
|
|
if [[ -z "$projects_e2e" ]]; then projects_e2e+='"governance-e2e" "trading-e2e" "explorer-e2e" '; fi
|
|
|
|
projects_e2e=${projects_e2e%?}
|
|
|
|
projects_e2e=[${projects_e2e// /,}]
|
|
|
|
echo PROJECTS_E2E=$projects_e2e >> $GITHUB_ENV
|
|
|
|
echo PROJECTS=$(echo $projects_e2e | sed 's|-e2e||g') >> $GITHUB_ENV
|
2023-01-20 10:21:22 +00:00
|
|
|
|
|
|
|
outputs:
|
|
|
|
projects: ${{ env.PROJECTS }}
|
2023-03-24 15:42:33 +00:00
|
|
|
projects-e2e: ${{ env.PROJECTS_E2E }}
|
2023-01-20 10:21:22 +00:00
|
|
|
|
2023-03-24 15:42:33 +00:00
|
|
|
run-cypress:
|
2023-01-20 10:21:22 +00:00
|
|
|
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:
|
2023-03-24 15:42:33 +00:00
|
|
|
projects: ${{ needs.pr.outputs.projects-e2e }}
|
2023-01-20 10:21:22 +00:00
|
|
|
tags: '@smoke @regression'
|
|
|
|
|
2023-03-24 15:42:33 +00:00
|
|
|
run-docker-build:
|
|
|
|
needs: pr
|
|
|
|
if: ${{ needs.pr.outputs.projects != '[]' }}
|
|
|
|
uses: ./.github/workflows/publish-docker-containers.yml
|
|
|
|
secrets: inherit
|
|
|
|
with:
|
|
|
|
projects: ${{ needs.pr.outputs.projects }}
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
# Report single result at the end, to avoid mess with required checks in PR
|
|
|
|
result:
|
|
|
|
if: ${{ always() }}
|
2023-03-24 15:42:33 +00:00
|
|
|
needs: run-cypress
|
2023-01-20 10:21:22 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
name: Cypress result
|
|
|
|
steps:
|
|
|
|
- run: |
|
2023-03-24 15:42:33 +00:00
|
|
|
result="${{ needs.run-cypress.result }}"
|
2023-01-20 10:21:22 +00:00
|
|
|
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|