Test and deploy PR from fork #3477
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test and deploy PR from fork | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.workflow_run.id }} | |
cancel-in-progress: true | |
on: | |
workflow_run: | |
workflows: ['Build PR From Fork'] | |
types: ['completed'] | |
jobs: | |
prepare_jobs: | |
runs-on: ubuntu-latest | |
if: | | |
github.event.workflow_run.event == 'pull_request' && | |
github.event.workflow_run.conclusion == 'success' | |
outputs: | |
pr_number: '${{ steps.get_pr_number.outputs.pr_number }}' | |
steps: | |
- name: Download PR info | |
uses: dawidd6/action-download-artifact@7847792dd435a50521b8e3bd3576dae7459d1fa8 # v2.22.0 | |
with: | |
workflow: build-fork.yml | |
run_id: '${{ github.event.workflow_run.id }}' | |
workflow_conclusion: success | |
name: pr | |
path: ./ | |
- name: Get PR number | |
shell: sh | |
id: get_pr_number | |
run: | | |
echo "::set-output name=pr_number::$(cat NUM | tr -dc '[:digit:]')" | |
- name: Link this CI run to PR | |
uses: actions/github-script@100527700e8b29ca817ac0e0dfbfc5e8ff38edda # v6.1.1 | |
with: | |
script: | | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: Number('${{ steps.get_pr_number.outputs.pr_number }}'), | |
body: '🔎 Tests and deployment are running now!\nSee progress at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
}); | |
next_js_analyze: | |
runs-on: ubuntu-latest | |
needs: ['prepare_jobs'] | |
env: | |
PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
with: | |
persist-credentials: false | |
- uses: ./.github/actions/analyze-comment | |
with: | |
PULL_REQUEST_NUMBER: '${{ env.PR_NUMBER }}' | |
cypress_smoke_v2: | |
runs-on: ubuntu-latest | |
needs: ['prepare_jobs'] | |
strategy: | |
fail-fast: false | |
matrix: | |
market: | |
- polygon | |
- avalanche | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Run tests | |
uses: ./.github/actions/cypress | |
with: | |
CYPRESS_TENDERLY_ACCOUNT: '${{ secrets.TENDERLY_ACCOUNT }}' | |
CYPRESS_TENDERLY_KEY: '${{ secrets.TENDERLY_KEY }}' | |
CYPRESS_TENDERLY_PROJECT: '${{ secrets.TENDERLY_PROJECT }}' | |
YARN_TEST_COMMAND: npx cypress-repeat run -n 2 --rerun-failed-only --config-file ./cypress/configs/v2-markets/${{ matrix.market }}-v2-smoke.config.ts | |
cypress_smoke_v3: | |
runs-on: ubuntu-latest | |
needs: ['prepare_jobs'] | |
strategy: | |
fail-fast: false | |
matrix: | |
market: | |
- polygon | |
- avalanche | |
- optimism | |
- ethereum | |
- base | |
- gho | |
- gnosis | |
- bnb | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Run tests | |
uses: ./.github/actions/cypress | |
with: | |
CYPRESS_TENDERLY_ACCOUNT: '${{ secrets.TENDERLY_ACCOUNT }}' | |
CYPRESS_TENDERLY_KEY: '${{ secrets.TENDERLY_KEY }}' | |
CYPRESS_TENDERLY_PROJECT: '${{ secrets.TENDERLY_PROJECT }}' | |
YARN_TEST_COMMAND: npx cypress-repeat run -n 2 --rerun-failed-only --config-file ./cypress/configs/v3-markets/${{ matrix.market }}-v3-smoke.config.ts | |
deploy_fork: | |
runs-on: ubuntu-latest | |
needs: | |
- prepare_jobs | |
- cypress_smoke_v2 | |
- cypress_smoke_v3 | |
env: | |
PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
with: | |
persist-credentials: false | |
- name: Download static build | |
uses: dawidd6/action-download-artifact@7847792dd435a50521b8e3bd3576dae7459d1fa8 # v2.22.0 | |
with: | |
workflow: build-fork.yml | |
run_id: ${{ github.event.workflow_run.id }} | |
workflow_conclusion: success | |
name: out | |
path: out | |
- name: pinata | |
id: pinata | |
uses: aave/pinata-action@35662944e92cf082457973f10aa42e48df179b47 | |
with: | |
PINATA_API_KEY: '${{ secrets.PINATA_API_KEY }}' | |
PINATA_SECRET_KEY: '${{ secrets.PINATA_SECRET_KEY }}' | |
PIN_ALIAS: 'pull_request_${{ env.PR_NUMBER }}' | |
BUILD_LOCATION: './out' | |
CID_VERSION: 1 | |
- name: Pin to primary IPFS server | |
id: ipfs-primary | |
uses: ./.github/actions/dev-ipfs-pin | |
with: | |
GCP_SA_KEY: '${{ secrets.GCP_SA_KEY }}' | |
GKE_CLUSTER: '${{ secrets.GKE_CLUSTER }}' | |
GKE_CLUSTER_REGION: '${{ secrets.GKE_CLUSTER_REGION }}' | |
IPFS_SERVER_PORT: '${{ secrets.IPFS_PRIMARY_SERVER_PORT }}' | |
IPFS_SERVER: '${{ secrets.IPFS_PRIMARY_SERVER }}' | |
IPFS_SERVER_KEY: '${{ secrets.IPFS_PRIMARY_SERVER_KEY }}' | |
BUILD_PATH: 'out' | |
- name: 'Comment on PR' | |
uses: actions/github-script@100527700e8b29ca817ac0e0dfbfc5e8ff38edda # v6.1.1 | |
with: | |
script: | | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: ${{ env.PR_NUMBER }}, | |
body: `- Ipfs hash: ${{ steps.pinata.outputs.hash }}\n- Ipfs preview link: ${{ steps.pinata.outputs.uri }}` | |
}); | |
cypress_full_v2: | |
runs-on: ubuntu-latest | |
needs: ['deploy_fork'] | |
strategy: | |
fail-fast: false | |
matrix: | |
market: | |
- polygon | |
- avalanche | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Run tests | |
uses: ./.github/actions/cypress | |
with: | |
CYPRESS_TENDERLY_ACCOUNT: '${{ secrets.TENDERLY_ACCOUNT }}' | |
CYPRESS_TENDERLY_KEY: '${{ secrets.TENDERLY_KEY }}' | |
CYPRESS_TENDERLY_PROJECT: '${{ secrets.TENDERLY_PROJECT }}' | |
YARN_TEST_COMMAND: npx cypress-repeat run -n 2 --rerun-failed-only --config-file ./cypress/configs/v2-markets/${{ matrix.market }}-v2-full.config.ts | |
cypress_full_v3: | |
runs-on: ubuntu-latest | |
needs: ['deploy_fork'] | |
strategy: | |
fail-fast: false | |
matrix: | |
market: | |
- polygon | |
- optimism | |
- ethereum | |
- gho | |
- base | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Run tests | |
uses: ./.github/actions/cypress | |
with: | |
CYPRESS_TENDERLY_ACCOUNT: '${{ secrets.TENDERLY_ACCOUNT }}' | |
CYPRESS_TENDERLY_KEY: '${{ secrets.TENDERLY_KEY }}' | |
CYPRESS_TENDERLY_PROJECT: '${{ secrets.TENDERLY_PROJECT }}' | |
YARN_TEST_COMMAND: npx cypress-repeat run -n 2 --rerun-failed-only --config-file ./cypress/configs/v3-markets/${{ matrix.market }}-v3-full.config.ts | |
cypress_app_functionality: | |
runs-on: ubuntu-latest | |
needs: ['deploy_fork'] | |
strategy: | |
fail-fast: false | |
matrix: | |
scoupe: | |
- settings | |
- mobile | |
- governance-stake | |
- widgets | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Run tests | |
uses: ./.github/actions/cypress | |
with: | |
CYPRESS_TENDERLY_ACCOUNT: ${{ secrets.TENDERLY_ACCOUNT }} | |
CYPRESS_TENDERLY_KEY: ${{ secrets.TENDERLY_KEY }} | |
CYPRESS_TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }} | |
YARN_TEST_COMMAND: npx cypress-repeat run -n 2 --rerun-failed-only --config-file ./cypress/configs/${{ matrix.scoupe }}.config.ts | |
notify_failure: | |
runs-on: ubuntu-latest | |
if: failure() | |
needs: | |
- prepare_jobs | |
- next_js_analyze | |
- cypress_full_v2 | |
- cypress_full_v3 | |
- cypress_app_functionality | |
env: | |
PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Comment | |
uses: ./.github/actions/fork-result-comment | |
with: | |
PULL_REQUEST_NUMBER: '${{ env.PR_NUMBER }}' | |
COMMENT_BODY: | | |
❌ CI run has failed! | |
Please see logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
- name: Label | |
uses: ./.github/actions/fork-result-label | |
continue-on-error: true | |
with: | |
SUCCESS: 'false' | |
PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }} | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
notify_success: | |
runs-on: ubuntu-latest | |
if: success() | |
needs: | |
- prepare_jobs | |
- next_js_analyze | |
- cypress_full_v2 | |
- cypress_full_v3 | |
- cypress_app_functionality | |
env: | |
PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
steps: | |
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # v3.0.2 | |
- name: Comment | |
uses: ./.github/actions/fork-result-comment | |
with: | |
PULL_REQUEST_NUMBER: '${{ env.PR_NUMBER }}' | |
COMMENT_BODY: | | |
✅ CI run has succeded! | |
You can find tests and deployment logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' | |
- name: Label | |
uses: ./.github/actions/fork-result-label | |
continue-on-error: true | |
with: | |
SUCCESS: 'true' | |
PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }} | |
TOKEN: ${{ secrets.GITHUB_TOKEN }} |