Skip to content

fix: harden release workflows and widget snippets #22900

fix: harden release workflows and widget snippets

fix: harden release workflows and widget snippets #22900

Workflow file for this run

name: CI
on:
# main and develop branches
push:
branches:
- main
- develop
# build on PR creation/updates
pull_request:
types: [opened, synchronize]
env:
NODE_VERSION: lts/jod
REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
REACT_APP_PINATA_API_KEY: ${{ secrets.REACT_APP_PINATA_API_KEY }}
REACT_APP_PINATA_SECRET_API_KEY: ${{ secrets.REACT_APP_PINATA_SECRET_API_KEY }}
REACT_APP_GOOGLE_ANALYTICS_ID: ${{ secrets.REACT_APP_GOOGLE_ANALYTICS_ID }}
REACT_APP_BLOCKNATIVE_API_KEY: ${{ secrets.REACT_APP_BLOCKNATIVE_API_KEY }}
REACT_APP_BFF_BASE_URL: ${{ secrets.BFF_BASE_URL }}
REACT_APP_BALANCES_WATCHER_BASE_URL: ${{ secrets.BALANCES_WATCHER_BASE_URL }}
REACT_APP_CMS_BASE_URL: ${{ secrets.CMS_BASE_URL }}
NEXT_PUBLIC_CMS_BASE_URL: ${{ secrets.CMS_BASE_URL }}
PACKAGE_READ_AUTH_TOKEN: ${{ secrets.PACKAGE_READ_AUTH_TOKEN }}
NX_DISABLE_REMOTE_CACHE: true
jobs:
setup:
name: Setup
if: ${{ !startsWith(github.head_ref, 'cf-preview/pr-') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Cache generated files
id: cache-generated-files
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
apps/cowswap-frontend/src/locales
key: ${{ runner.os }}-generatedFiles-${{ hashFiles('**/pnpm-lock.yaml') }}
test:
name: Test
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Load generated files
id: cache-generated-files
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
apps/cowswap-frontend/src/locales
key: ${{ runner.os }}-generatedFiles-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Unit Test
run: pnpm run test
# - name: Coveralls
# uses: coverallsapp/github-action@v1.1.2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
lint:
name: Lint
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Load generated files
id: cache-generated-files
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
apps/cowswap-frontend/src/locales
key: ${{ runner.os }}-generatedFiles-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Run eslint
run: pnpm run lint
agent-harness:
name: Agent Harness
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Run AGENTS harness checks
run: pnpm run agents:check
typecheck:
name: Typecheck
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Load generated files
id: cache-generated-files
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: |
apps/cowswap-frontend/src/locales
key: ${{ runner.os }}-generatedFiles-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Run typecheck
run: pnpm run typecheck
integration-tests:
name: Cypress
if: ${{ !startsWith(github.head_ref, 'cf-preview/pr-') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Increase watchers
run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- name: Install pnpm
uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm run install:ci
- name: Install Cypress binary
working-directory: apps/cowswap-frontend-e2e
run: npx cypress install
- name: Start server in the background
run: pnpm run preview &
# Actually run tests, building repo
- name: Cypress run
id: cypress-run
uses: cypress-io/github-action@b7a7441d775af8f8b9d19945c10dd689a51dba68 # v7.2.0
with:
wait-on: http://[::1]:3000
wait-on-timeout: 600
install: false
working-directory: apps/cowswap-frontend-e2e
env:
CYPRESS_INTEGRATION_TEST_PRIVATE_KEY: ${{ secrets.CYPRESS_INTEGRATION_TEST_PRIVATE_KEY }}
CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY: ${{ secrets.CYPRESS_INTEGRATION_TESTS_ALCHEMY_KEY }}
CYPRESS_INTEGRATION_TESTS_INFURA_KEY: ${{ secrets.CYPRESS_INTEGRATION_TESTS_INFURA_KEY }}
# - uses: actions/upload-artifact@v3
# if: always()
# with:
# name: cypress-videos
# path: |
# cypress-custom/videos
# cypress-custom/screenshots
# Open tmate ssh connection on failure for debugging
# Uncomment when needed and push upstream
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# if: ${{ failure() }}
notify-failure:
name: Notify Slack on Failure
needs: [setup, test, lint, typecheck, agent-harness, integration-tests]
runs-on: ubuntu-latest
if: failure() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop')
steps:
- name: Notify Failure
run: |
failed_jobs=()
[ "$TEST_RESULT" = "failure" ] && failed_jobs+=("Test")
[ "$LINT_RESULT" = "failure" ] && failed_jobs+=("Lint")
[ "$TYPECHECK_RESULT" = "failure" ] && failed_jobs+=("Typecheck")
[ "$AGENT_HARNESS_RESULT" = "failure" ] && failed_jobs+=("Agent Harness")
[ "$INTEGRATION_TESTS_RESULT" = "failure" ] && failed_jobs+=("Cypress")
if [ ${#failed_jobs[@]} -eq 0 ]; then
failure_summary="CI"
else
failure_summary=$(IFS=', '; echo "${failed_jobs[*]}")
fi
curl -X POST -H "Content-type: application/json" --data "{\"text\": \"❌ ${failure_summary} failed on \`$REF_NAME\`. <$SERVER_URL/$REPOSITORY/actions/runs/$RUN_ID|See run $RUN_ID on GH>.\"}" "$SLACK_WEBHOOK_URL"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
REF_NAME: ${{ github.ref_name }}
SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
RUN_ID: ${{ github.run_id }}
TEST_RESULT: ${{ needs.test.result }}
LINT_RESULT: ${{ needs.lint.result }}
TYPECHECK_RESULT: ${{ needs.typecheck.result }}
AGENT_HARNESS_RESULT: ${{ needs.agent-harness.result }}
INTEGRATION_TESTS_RESULT: ${{ needs.integration-tests.result }}