Test and deploy PR from fork #5231
This file contains hidden or 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'] | |
| # Default least-privilege token; jobs that download cross-run artifacts, | |
| # comment, or label elevate below. | |
| permissions: | |
| contents: read | |
| jobs: | |
| prepare_jobs: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| actions: read # download artifacts from the triggering run | |
| pull-requests: write # comment the CI-started notice on the PR | |
| 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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| env: | |
| PR_NUMBER: ${{ steps.get_pr_number.outputs.pr_number }} | |
| with: | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: Number(process.env.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'] | |
| permissions: | |
| contents: read | |
| actions: read # analyze-comment downloads artifacts from the triggering run | |
| pull-requests: write # posts bundle-analysis comment | |
| env: | |
| PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| with: | |
| persist-credentials: false | |
| - uses: ./.github/actions/analyze-comment | |
| with: | |
| PULL_REQUEST_NUMBER: '${{ env.PR_NUMBER }}' | |
| cypress_smoke_v3: | |
| runs-on: ubuntu-latest | |
| needs: ['prepare_jobs'] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| market: | |
| - polygon | |
| - avalanche | |
| - optimism | |
| - ethereum | |
| - base | |
| - gnosis | |
| - bnb | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - 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 }}' | |
| 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_v3 | |
| permissions: | |
| contents: write # pinata-action leaves a commit comment on non-PR events | |
| actions: read # download the static build from the triggering run | |
| pull-requests: write # comment the IPFS preview link on the PR | |
| env: | |
| PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| 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: Upload to Infura IPFS | |
| id: infura-upload | |
| uses: aave/ipfs-action@master | |
| with: | |
| path: './out' | |
| service: infura | |
| infuraProjectId: ${{ secrets.INFURA_PROJECT_ID }} | |
| infuraProjectSecret: ${{ secrets.INFURA_PROJECT_SECRET }} | |
| - name: 'Comment on PR' | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| with: | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: Number(process.env.PR_NUMBER), | |
| body: `- Ipfs hash: ${{ steps.pinata.outputs.hash }}\n- Ipfs preview link: ${{ steps.pinata.outputs.uri }}` | |
| }); | |
| cypress_full_v3: | |
| runs-on: ubuntu-latest | |
| needs: ['deploy_fork'] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| market: | |
| - polygon | |
| - optimism | |
| - ethereum | |
| - base | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - 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 }}' | |
| 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 | |
| - governance-stake | |
| - widgets | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - 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 }} | |
| 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 | |
| permissions: | |
| contents: read | |
| pull-requests: write # update the CI-result comment | |
| issues: write # add/remove the CI Passed/Failed label | |
| if: failure() | |
| needs: | |
| - prepare_jobs | |
| - next_js_analyze | |
| - cypress_full_v3 | |
| - cypress_app_functionality | |
| env: | |
| PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - 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 | |
| permissions: | |
| contents: read | |
| pull-requests: write # update the CI-result comment | |
| issues: write # add/remove the CI Passed/Failed label | |
| if: success() | |
| needs: | |
| - prepare_jobs | |
| - next_js_analyze | |
| - cypress_full_v3 | |
| - cypress_app_functionality | |
| env: | |
| PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} | |
| steps: | |
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| - 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 }} |