2023-04-03 13:53:50 +00:00
|
|
|
name: CI/CD
|
2023-01-20 10:21:22 +00:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
2023-04-03 13:53:50 +00:00
|
|
|
- release/*
|
2023-04-12 07:38:26 +00:00
|
|
|
- develop
|
2023-01-20 10:21:22 +00:00
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- opened
|
2023-04-14 09:47:41 +00:00
|
|
|
- ready_for_review
|
2023-01-20 10:21:22 +00:00
|
|
|
- reopened
|
2023-04-14 09:47:41 +00:00
|
|
|
- edited
|
2023-01-20 10:21:22 +00:00
|
|
|
- synchronize
|
|
|
|
jobs:
|
2023-04-14 09:47:41 +00:00
|
|
|
node-modules:
|
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
name: 'Cache yarn modules'
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Cache node modules
|
|
|
|
id: cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
2023-04-20 11:56:33 +00:00
|
|
|
# comment out "restore-keys" if you need to rebuild yarn from 0
|
2023-04-14 09:47:41 +00:00
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-cache-node-modules-
|
|
|
|
|
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
with:
|
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
|
|
|
cache: yarn
|
|
|
|
|
|
|
|
- name: yarn install
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: yarn install --pure-lockfile
|
|
|
|
|
|
|
|
lint-pr-title:
|
|
|
|
needs: node-modules
|
2023-04-14 13:00:20 +00:00
|
|
|
if: ${{ github.event_name == 'pull_request' }}
|
2023-04-14 09:47:41 +00:00
|
|
|
name: Verify PR title
|
|
|
|
uses: ./.github/workflows/lint-pr.yml
|
|
|
|
secrets: inherit
|
|
|
|
|
2023-04-03 13:53:50 +00:00
|
|
|
lint-test-build:
|
2023-04-20 11:56:33 +00:00
|
|
|
timeout-minutes: 35
|
2023-04-14 09:47:41 +00:00
|
|
|
needs: node-modules
|
2023-04-03 13:53:50 +00:00
|
|
|
runs-on: ubuntu-22.04
|
|
|
|
name: '(CI) lint + unit test + build'
|
2023-01-20 10:21:22 +00:00
|
|
|
steps:
|
2023-03-31 15:01:19 +00:00
|
|
|
- name: Checkout
|
2023-01-20 10:21:22 +00:00
|
|
|
uses: actions/checkout@v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Setup node
|
|
|
|
uses: actions/setup-node@v3
|
2023-03-24 15:42:33 +00:00
|
|
|
with:
|
2023-04-03 13:53:50 +00:00
|
|
|
node-version-file: '.nvmrc'
|
|
|
|
# https://stackoverflow.com/questions/61010294/how-to-cache-yarn-packages-in-github-actions
|
|
|
|
cache: yarn
|
|
|
|
|
2023-04-14 09:47:41 +00:00
|
|
|
- name: Cache node modules
|
|
|
|
uses: actions/cache@v3
|
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: ${{ runner.os }}-cache-node-modules-${{ hashFiles('yarn.lock') }}
|
2023-01-20 10:21:22 +00:00
|
|
|
|
|
|
|
- name: Derive appropriate SHAs for base and head for `nx affected` commands
|
2023-03-29 13:20:49 +00:00
|
|
|
uses: nrwl/nx-set-shas@v3
|
2023-01-20 10:21:22 +00:00
|
|
|
with:
|
2023-03-29 13:20:49 +00:00
|
|
|
main-branch-name: develop
|
2023-01-20 10:21:22 +00:00
|
|
|
|
2023-04-03 13:53:50 +00:00
|
|
|
- name: Check formatting
|
|
|
|
run: yarn nx format:check
|
2023-03-29 13:20:49 +00:00
|
|
|
|
2023-04-03 13:53:50 +00:00
|
|
|
- name: Lint affected
|
|
|
|
run: yarn nx affected:lint --max-warnings=0
|
|
|
|
|
|
|
|
- name: Build affected spec
|
|
|
|
run: yarn nx affected --target=build-spec
|
2023-03-29 13:20:49 +00:00
|
|
|
|
2023-04-03 13:53:50 +00:00
|
|
|
- name: Test affected
|
|
|
|
run: yarn nx affected:test
|
|
|
|
|
|
|
|
- name: Build affected
|
2023-04-17 09:24:53 +00:00
|
|
|
run: yarn nx affected:build || (yarn install && yarn nx affected:build)
|
2023-04-03 13:53:50 +00:00
|
|
|
|
|
|
|
# See affected apps
|
2023-03-31 15:01:19 +00:00
|
|
|
- name: See affected apps
|
|
|
|
run: |
|
2023-04-03 13:53:50 +00:00
|
|
|
echo ">>>> debug"
|
|
|
|
echo "NX Version: $nx_version"
|
|
|
|
echo "NX_BASE: ${{ env.NX_BASE }}"
|
|
|
|
echo "NX_HEAD: ${{ env.NX_HEAD }}"
|
|
|
|
echo ">>>> eof debug"
|
|
|
|
|
|
|
|
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-29 13:20:49 +00:00
|
|
|
|
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-04-03 13:53:50 +00:00
|
|
|
cypress:
|
|
|
|
needs: lint-test-build
|
|
|
|
name: '(CI) cypress'
|
|
|
|
if: ${{ needs.lint-test-build.outputs.projects != '[]' }}
|
2023-01-20 10:21:22 +00:00
|
|
|
uses: ./.github/workflows/cypress-run.yml
|
|
|
|
secrets: inherit
|
|
|
|
with:
|
2023-04-03 13:53:50 +00:00
|
|
|
projects: ${{ needs.lint-test-build.outputs.projects-e2e }}
|
2023-01-20 10:21:22 +00:00
|
|
|
tags: '@smoke @regression'
|
|
|
|
|
2023-04-03 13:53:50 +00:00
|
|
|
publish-dist:
|
|
|
|
needs: lint-test-build
|
|
|
|
name: '(CD) publish dist'
|
|
|
|
if: ${{ needs.lint-test-build.outputs.projects != '[]' }}
|
|
|
|
uses: ./.github/workflows/publish-dist.yml
|
2023-03-24 15:42:33 +00:00
|
|
|
secrets: inherit
|
|
|
|
with:
|
2023-04-03 13:53:50 +00:00
|
|
|
projects: ${{ needs.lint-test-build.outputs.projects }}
|
2023-03-24 15:42:33 +00:00
|
|
|
|
2023-04-14 09:47:41 +00:00
|
|
|
dist-check:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: publish-dist
|
|
|
|
if: ${{ github.event_name == 'pull_request' }}
|
|
|
|
name: '(CD) comment preview links'
|
|
|
|
steps:
|
|
|
|
- name: Find Comment
|
|
|
|
uses: peter-evans/find-comment@v2
|
|
|
|
id: fc
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body-includes: Previews
|
|
|
|
|
|
|
|
- name: Inject slug/short variables
|
|
|
|
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
|
|
|
uses: rlespinasse/github-slug-action@v4
|
|
|
|
with:
|
|
|
|
prefix: CI_
|
|
|
|
|
|
|
|
- name: Create comment
|
|
|
|
if: ${{ steps.fc.outputs.comment-id == 0 }}
|
|
|
|
uses: peter-evans/create-or-update-comment@v3
|
|
|
|
with:
|
|
|
|
issue-number: ${{ github.event.pull_request.number }}
|
|
|
|
body: |
|
|
|
|
Previews
|
|
|
|
- explorer https://explorer.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
|
|
|
- trading https://trading.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
|
|
|
- governance https://governance.${{ env.CI_GITHUB_REF_NAME }}.vega.rocks
|
|
|
|
|
|
|
|
cypress-check:
|
|
|
|
name: '(CI) cypress - check'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: cypress
|
|
|
|
steps:
|
|
|
|
- run: echo Done!
|
|
|
|
|
2023-01-20 10:21:22 +00:00
|
|
|
# Report single result at the end, to avoid mess with required checks in PR
|
2023-04-03 13:53:50 +00:00
|
|
|
cypress-result:
|
2023-01-20 10:21:22 +00:00
|
|
|
if: ${{ always() }}
|
2023-04-03 13:53:50 +00:00
|
|
|
needs: cypress
|
|
|
|
runs-on: ubuntu-22.04
|
2023-01-20 10:21:22 +00:00
|
|
|
steps:
|
|
|
|
- run: |
|
2023-04-03 13:53:50 +00:00
|
|
|
result="${{ needs.cypress.result }}"
|
2023-01-20 10:21:22 +00:00
|
|
|
if [[ $result == "success" || $result == "skipped" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|