From f0ddb096b864039f65ffcbcc63173b7cd09d5ff2 Mon Sep 17 00:00:00 2001 From: anassohail99 Date: Fri, 20 Oct 2023 14:51:47 +0500 Subject: [PATCH] feat: setup github actions --- .github/CODEOWNERS | 1 - .github/ISSUE_TEMPLATE/bug-report.md | 22 -- .github/ISSUE_TEMPLATE/config.yml | 8 - .github/ISSUE_TEMPLATE/feature-request.md | 19 -- .github/actions/report/action.yml | 48 --- .github/actions/setup/action.yml | 49 --- .github/dependabot.yml | 12 - .github/pull_request_template.md | 52 ---- .github/workflows/1-main-to-staging.yml | 73 ----- .github/workflows/2-deploy-to-staging.yml | 64 ---- .github/workflows/3-staging-to-prod.yml | 42 --- .github/workflows/4-deploy-to-prod.yml | 111 ------- .github/workflows/check-pr-title.yaml | 17 -- .github/workflows/crowdin.yaml | 26 -- .github/workflows/deploy.yml | 38 +++ .../notify-slack-on-release-merge.yml | 91 ------ .github/workflows/test.yml | 278 ------------------ 17 files changed, 38 insertions(+), 913 deletions(-) delete mode 100644 .github/CODEOWNERS delete mode 100644 .github/ISSUE_TEMPLATE/bug-report.md delete mode 100644 .github/ISSUE_TEMPLATE/config.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature-request.md delete mode 100644 .github/actions/report/action.yml delete mode 100644 .github/actions/setup/action.yml delete mode 100644 .github/dependabot.yml delete mode 100644 .github/pull_request_template.md delete mode 100644 .github/workflows/1-main-to-staging.yml delete mode 100644 .github/workflows/2-deploy-to-staging.yml delete mode 100644 .github/workflows/3-staging-to-prod.yml delete mode 100644 .github/workflows/4-deploy-to-prod.yml delete mode 100644 .github/workflows/check-pr-title.yaml delete mode 100644 .github/workflows/crowdin.yaml create mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/notify-slack-on-release-merge.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index 33ffedf4eea..00000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1 +0,0 @@ -* @uniswap/web-reviewers diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md deleted file mode 100644 index f4b5bf03ef3..00000000000 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -name: Bug Report -about: Describe an issue in the Uniswap Interface -title: '' -labels: bug -assignees: '' ---- - -**Bug Description** -A clear and concise description of the bug. - -**Steps to Reproduce** - -1. Go to ... -2. Click on ... - ... - -**Expected Behavior** -A clear and concise description of what you expected to happen. - -**Additional Context** -Add any other context about the problem here (screenshots, whether the bug only occurs only in certain mobile/desktop/browser environments, etc.) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index 69e1a068c5a..00000000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,8 +0,0 @@ -blank_issues_enabled: true -contact_links: - - name: Support - url: https://discord.gg/FCfyBSbCU5 - about: Please ask and answer questions here - - name: List a token - url: https://github.com/Uniswap/default-token-list#adding-a-token - about: Any requests to add a token to Uniswap should go here diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md deleted file mode 100644 index d6eda87030a..00000000000 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -name: Feature Request -about: Suggest an idea for improving the UX of the Uniswap Interface -title: '' -labels: 'improvement' -assignees: '' ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/actions/report/action.yml b/.github/actions/report/action.yml deleted file mode 100644 index 6c7f7600fe5..00000000000 --- a/.github/actions/report/action.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Report -description: Report test failures via Slack -inputs: - name: - description: The name of the failing test - required: true - SLACK_WEBHOOK_URL: - description: The webhook URL to send the report to - required: true - -runs: - using: composite - steps: - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - with: - payload: | - { - "text": "${{ inputs.name }} failing on `${{ github.ref_name }}`", - "blocks": [ - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*${{ inputs.name }} failing on `${{ github.ref_name }}`:* " - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "_This is blocking pull requests and branch promotions._\n_Please prioritize fixing the build._" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - # The !oncall bot requires its own message: - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - with: - payload: | - { - "text": "!oncall web" - } - env: - SLACK_WEBHOOK_URL: ${{ inputs.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml deleted file mode 100644 index adadd41060f..00000000000 --- a/.github/actions/setup/action.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Setup -description: checkout repo, setup node, and install node_modules - -runs: - using: composite - steps: - - uses: actions/checkout@v3 - - - uses: actions/setup-node@v3 - with: - node-version: 18 - registry-url: https://registry.npmjs.org - # cache is intentionally omitted, as it is faster with yarn v1 to cache node_modules. - - - uses: actions/cache@v3 - id: install-cache - with: - # node_modules/.cache is intentionally omitted, as this is used for build tool caches. - path: | - node_modules - !node_modules/.cache - key: ${{ runner.os }}-install-${{ hashFiles('yarn.lock') }} - - if: steps.install-cache.outputs.cache-hit != 'true' - run: yarn install --frozen-lockfile --ignore-scripts - shell: bash - - # Run patch-package to apply patches to dependencies. - - run: yarn patch-package - shell: bash - - # Contracts are compiled from source. If source hasn't changed, the contracts do not need to be re-compiled. - - uses: actions/cache@v3 - id: contracts-cache - with: - path: | - src/abis/types - src/types/v3 - key: ${{ runner.os }}-contracts-${{ hashFiles('src/abis/**/*.json', 'node_modules/@uniswap/**/artifacts/contracts/**/*.json') }} - - if: steps.contracts-cache.outputs.cache-hit != 'true' - run: yarn contracts - shell: bash - - # These operations cannot be cached, so they are run concurrently - # - ajv: Validators compile quickly, so caching can be omitted. - # - graphql: GraphQL is generated from schema and client-side graphql queries. The schema is always fetched and - # changes to client-side queries are hard to detect, so it is always re-generated. - # - i18n: Messages are extracted from source and compiled. No caching extractor is available (out-of-the-box). - - run: yarn concurrently --max-processes=100% npm:ajv npm:graphql npm:i18n - shell: bash diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 698c8a00496..00000000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: - - package-ecosystem: npm - # Files stored in repository root - directory: '/' - schedule: - interval: 'daily' - allow: - - dependency-name: '@uniswap/default-token-list' - - dependency-name: '@uniswap/token-lists' - reviewers: - - 'Uniswap/dependabot-reviewers' diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md deleted file mode 100644 index 18cf5e48abf..00000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,52 +0,0 @@ - - -## Description - - - - - -_Linear ticket:_ -_Slack thread:_ -_Relevant docs:_ - - - -## Screen capture - -### Before -| Mobile | Desktop | -| ------------ | ------------ | -| paste_before | paste_before | - - -### After -| Mobile | Desktop | -| ------------ | ----------- | -| paste_after | paste_after | - - -## Test plan - - -### Reproducing the error - - -1. - -### QA (ie manual testing) - - -- [ ] N/A - - -#### Devices - - - -### Automated testing - - - -- [ ] Unit test -- [ ] Integration/E2E test diff --git a/.github/workflows/1-main-to-staging.yml b/.github/workflows/1-main-to-staging.yml deleted file mode 100644 index 27ce771780b..00000000000 --- a/.github/workflows/1-main-to-staging.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: 1 | Push main -> staging - -# This CI job is responsible for pushing the current contents of the `main` branch to the -# `releases/staging` branch, which will in turn kick off a deploy to the staging environment. - -on: - workflow_dispatch: - -# https://stackoverflow.com/questions/57921401/push-to-origin-from-github-action -jobs: - push-staging: - name: 'Push to staging branch' - runs-on: ubuntu-latest - environment: - name: push/staging - steps: - - name: Check test status - uses: actions/github-script@v6.4.1 - with: - script: | - const statuses = await github.rest.repos.listCommitStatusesForRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.sha - }) - const status = statuses.data.find(status => status.context === 'Test / promotion')?.state || 'missing' - core.info('Status: ' + status) - if (status !== 'success') { - core.setFailed('"Test / promotion" must be successful before pushing') - } - - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - with: - token: ${{ secrets.RELEASE_SERVICE_ACCESS_TOKEN }} - ref: main - - # The source file must exist for the corresponding translation messages to be downloaded. - - run: touch src/locales/en-US.po - - name: Download translations - uses: crowdin/github-action@3133cc916c35590475cf6705f482fb653d8e36e9 - with: - upload_sources: false - download_translations: true - project_id: 458284 - token: ${{ secrets.CROWDIN_PERSONAL_TOKEN_SECRET }} - source: 'src/locales/en-US.po' - translation: 'src/locales/%locale%.po' - localization_branch_name: main - create_pull_request: false - push_translations: false - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Git config - run: | - git config user.name 'UL Service Account' - git config user.email 'hello-happy-puppy@users.noreply.github.com' - - - name: Add translations - run: | - rm src/locales/en-US.po - git add -f src/locales/*.po - git commit -m 'ci(t9n): download translations from crowdin' - - - name: Add CODEOWNERS - run: | - echo '* @uniswap/web-admins' > CODEOWNERS - git add CODEOWNERS - git commit -m 'ci: add global CODEOWNERS' - - - name: Git push - run: | - git push origin main:releases/staging --force diff --git a/.github/workflows/2-deploy-to-staging.yml b/.github/workflows/2-deploy-to-staging.yml deleted file mode 100644 index 0371eb1d509..00000000000 --- a/.github/workflows/2-deploy-to-staging.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: 2 | Deploy staging -on: - push: - branches: - - 'releases/staging' - -jobs: - deploy-to-staging: - runs-on: ubuntu-latest - environment: - name: deploy/staging - steps: - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - continue-on-error: true - with: - payload: | - { - "text": "Deploy _started_ for ${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - run: yarn build - env: - REACT_APP_STAGING: 1 - - - name: Update Cloudflare Pages deployment - id: pages-deployment - uses: cloudflare/pages-action@364c7ca09a4b57837c5967871d64a2c31adb8c0d - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: interface-staging - directory: build - githubToken: ${{ secrets.GITHUB_TOKEN }} - # Cloudflare uses `main` as the default production branch, so we push using the `main` branch so that it can be aliased by a custom domain. - branch: main - - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - continue-on-error: true - if: always() - with: - payload: | - { - "text": "Deploy *${{ steps.pages-deployment.outcome }}* for ${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - - name: Upload source maps to Sentry - uses: getsentry/action-release@bd5f874fcda966ba48139b0140fb3ec0cb3aabdd - continue-on-error: true - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - with: - environment: staging - sourcemaps: './build/static/js' - url_prefix: '~/static/js' diff --git a/.github/workflows/3-staging-to-prod.yml b/.github/workflows/3-staging-to-prod.yml deleted file mode 100644 index 104b35f79ae..00000000000 --- a/.github/workflows/3-staging-to-prod.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: 3 | Push staging -> prod - -# This CI job is responsible for force pushing the content of releases/staging to releases/prod. It -# is restricted to web-reviewers through virtue of the GitHub environment protection rules for the -# prod environment. - -on: - workflow_dispatch: - -jobs: - push-prod: - name: 'Push to prod branch' - runs-on: ubuntu-latest - environment: - name: push/prod - steps: - - name: Check test status - uses: actions/github-script@v6.4.1 - with: - script: | - const statuses = await github.rest.repos.listCommitStatusesForRef({ - owner: context.repo.owner, - repo: context.repo.repo, - ref: context.sha - }) - const status = statuses.data.find(status => status.context === 'Test / promotion')?.state || 'missing' - core.info('Status: ' + status) - if (status !== 'success') { - core.setFailed('"Test / promotion" must be successful before pushing') - } - - - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab - with: - token: ${{ secrets.RELEASE_SERVICE_ACCESS_TOKEN }} - ref: releases/staging - - name: Git config - run: | - git config user.name "UL Service Account" - git config user.email "hello-happy-puppy@users.noreply.github.com" - - name: Git push - run: | - git push origin releases/staging:releases/prod --force diff --git a/.github/workflows/4-deploy-to-prod.yml b/.github/workflows/4-deploy-to-prod.yml deleted file mode 100644 index a03b52e2b0d..00000000000 --- a/.github/workflows/4-deploy-to-prod.yml +++ /dev/null @@ -1,111 +0,0 @@ -name: 4 | Deploy prod -on: - push: - branches: - - 'releases/prod' - -jobs: - deploy-to-prod: - runs-on: ubuntu-latest - environment: - name: deploy/prod - steps: - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - continue-on-error: true - with: - payload: | - { - "text": "Deploy _started_ for ${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - run: yarn build - - - name: Bump and tag - id: github-tag-action - uses: mathieudutour/github-tag-action@d745f2e74aaf1ee82e747b181f7a0967978abee0 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - release_branches: releases/prod - default_bump: patch - - - name: Pin to IPFS - id: pinata - uses: anantaramdas/ipfs-pinata-deploy-action@39bbda1ce1fe24c69c6f57861b8038278d53688d - with: - pin-name: Uniswap ${{ steps.github-tag-action.outputs.new_tag }} - path: './build' - pinata-api-key: ${{ secrets.PINATA_API_KEY }} - pinata-secret-api-key: ${{ secrets.PINATA_API_SECRET_KEY }} - - - name: Convert CIDv0 to CIDv1 - id: convert-cidv0 - uses: uniswap/convert-cidv0-cidv1@v1.0.0 - with: - cidv0: ${{ steps.pinata.outputs.hash }} - - - name: Publish release - uses: actions/create-release@v1.1.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag_name: ${{ steps.github-tag-action.outputs.new_tag }} - release_name: Release ${{ steps.github-tag-action.outputs.new_tag }} - body: | - IPFS hash of the deployment: - - CIDv0: `${{ steps.pinata.outputs.hash }}` - - CIDv1: `${{ steps.convert-cidv0.outputs.cidv1 }}` - - The latest release is always mirrored at [app.uniswap.org](https://app.uniswap.org). - - You can also access the Uniswap Interface from an IPFS gateway. - **BEWARE**: The Uniswap interface uses [`localStorage`](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) to remember your settings, such as which tokens you have imported. - **You should always use an IPFS gateway that enforces origin separation**, or our hosted deployment of the latest release at [app.uniswap.org](https://app.uniswap.org). - Your Uniswap settings are never remembered across different URLs. - - IPFS gateways: - - https://${{ steps.convert-cidv0.outputs.cidv1 }}.ipfs.dweb.link/ - - https://${{ steps.convert-cidv0.outputs.cidv1 }}.ipfs.cf-ipfs.com/ - - [ipfs://${{ steps.pinata.outputs.hash }}/](ipfs://${{ steps.pinata.outputs.hash }}/) - - ${{ steps.github-tag-action.outputs.changelog }} - - - name: Update Cloudflare Pages deployment - uses: cloudflare/pages-action@364c7ca09a4b57837c5967871d64a2c31adb8c0d - id: pages-deployment - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} - directory: build - githubToken: ${{ secrets.GITHUB_TOKEN }} - # Cloudflare uses `main` as the default production branch, so we push using the `main` branch so that it can be aliased by a custom domain. - branch: main - - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - continue-on-error: true - if: always() - with: - payload: | - { - "text": "Deploy *${{ steps.pages-deployment.outcome }}* for ${{ github.ref_name }}" - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK - - - name: Upload source maps to Sentry - uses: getsentry/action-release@4744f6a65149f441c5f396d5b0877307c0db52c7 - continue-on-error: true - env: - SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} - SENTRY_ORG: ${{ secrets.SENTRY_ORG }} - SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} - with: - environment: production - sourcemaps: './build/static/js' - url_prefix: '~/static/js' diff --git a/.github/workflows/check-pr-title.yaml b/.github/workflows/check-pr-title.yaml deleted file mode 100644 index f2907eca4f0..00000000000 --- a/.github/workflows/check-pr-title.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Check PR Title - -on: - pull_request_target: - types: - - opened - - edited - - synchronize - -jobs: - # Ensures that the PR title adheres to [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). - conventional-commit: - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v3.4.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/crowdin.yaml b/.github/workflows/crowdin.yaml deleted file mode 100644 index a2051b7d2df..00000000000 --- a/.github/workflows/crowdin.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Crowdin Upload - -on: - push: - branches: - - main - -jobs: - upload-sources: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - run: yarn i18n:extract - - - name: Upload Crowdin sources - uses: crowdin/github-action@3133cc916c35590475cf6705f482fb653d8e36e9 - with: - upload_sources: true - download_translations: false - project_id: 458284 - token: ${{ secrets.CROWDIN_PERSONAL_TOKEN_SECRET }} - source: 'src/locales/en-US.po' - translation: 'src/locales/%locale%.po' - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000000..556b2b3fbf1 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,38 @@ +name: Deploy to S3 + +on: + push: + branches: + - s3-integration + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Build React App + run: | + nvm install 18 && nvm use 18 + yarn install + yarn run build + + - name: Deploy to S3 + uses: jakejarvis/s3-sync-action@master + with: + args: --acl public-read --follow-symlinks --delete + env: + AWS_S3_BUCKET: dex-51 + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_REGION: ${{ secrets.AWS_DEFAULT_REGION }} # or your AWS region + SOURCE_DIR: 'build' + + # Add this step if you want to invalidate CloudFront cache after each deploy. + # - name: Invalidate CloudFront Distribution + # run: | + # aws cloudfront create-invalidation --distribution-id https://d219h6gvglr9x6.cloudfront.net --paths "/*" + # env: + # AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + # AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/.github/workflows/notify-slack-on-release-merge.yml b/.github/workflows/notify-slack-on-release-merge.yml deleted file mode 100644 index 51fc5c75640..00000000000 --- a/.github/workflows/notify-slack-on-release-merge.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Slack notification on pushes to releases/* - -# This CI job will push notifications to Slack whenever code is merged into any releases/* branch -# -# The steps of the command line kung-fu shown below are as follows: -# First we take the JSON-formatted Github context -# echo $GITHUB_CONTEXT \ -# Then we parse out the specific fields we want for our messages using jq and format it into tab-separated values -# | jq '.event.commits[] | [.url, .id[0:7], .author.username, .timestamp, .message] | @tsv' \ -# We need to do some cleaning on this output - specifically removing quotes and replacing newlines with something easier to split -# | sed 's/"//g' | sed 's/\\t/;/g' | sed 's/\\n/;/g' | sed 's/\\//g' \ -# We then use awk to format the TSV into a Slack message -# | awk -F';' '{print "• <"$1"|"$2"> (, "$4") - "$5}' \ -# We need to deal with some escaping issues with newlines so that we don't break the Slack message format -# | sed 's/$/\\n/g' | tr -d '\n' \ -# Finally we have to truncate the message to 3,000 characters max, otherwise Slack will reject it -# | awk '{print substr($0,0,3000);}' \ -# Then shove the bytes into a file to store them in their exact format -# > /tmp/parsed_github_context - -on: - push: - branches: - - 'releases/*' - -jobs: - notify-slack: - runs-on: ubuntu-latest - environment: - name: notify/releases - steps: - - name: Parse event to slug - id: parse-slug - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - # Formats the contents of the GitHub event into slugs: one line per commit, formatted for Slack. - # Explanation for each line is in the comments above. - run: | - echo $GITHUB_CONTEXT \ - | jq '.event.commits[] | [.url, .id[0:7], .author.username, .timestamp, .message] | @tsv' \ - | sed 's/"//g' | sed 's/\\t/;/g' | sed 's/\\n/;/g' | sed 's/\\//g' \ - | awk -F';' '{print "• <"$1"|"$2"> (, "$4") - "$5}' \ - | sed 's/$/\\n/g' | tr -d '\n' \ - | awk '{print substr($0,0,3000);}' \ - > /tmp/parsed_github_context - echo "SLACK_COMMITS=$(cat /tmp/parsed_github_context)" >> "$GITHUB_OUTPUT" - - uses: slackapi/slack-github-action@007b2c3c751a190b6f0f040e47ed024deaa72844 - with: - payload: | - { - "text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}", - "blocks": [ - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Code merged to branch:*\n" - } - }, - { - "type": "divider" - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "*Actor*: \n*Force pushed*: ${{ github.event.forced || false }}\n" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "${{ steps.parse-slug.outputs.SLACK_COMMITS || 'New branch created' }}" - } - }, - { - "type": "section", - "text": { - "type": "mrkdwn", - "text": "<${{ github.event.compare}}|View Diff>" - } - } - ] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 1f1f2aad384..00000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,278 +0,0 @@ -name: Test - -# Many build steps have their own caches, so each job has its own cache to improve subsequent build times. -# Build tools are configured to cache to node_modules/.cache, so they are cached independently of node_modules. -# Caches are saved every run (by keying on github.run_id), and the most recent available cache is loaded. -# See https://jongleberry.medium.com/speed-up-your-ci-and-dx-with-node-modules-cache-ac8df82b7bb0. - -on: - push: - branches: - - main - - releases/staging - pull_request: - workflow_dispatch: - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-eslint-${{ github.run_id }} - restore-keys: ${{ runner.os }}-eslint- - - run: yarn lint - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Lint - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - typecheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-tsc-${{ github.run_id }} - restore-keys: ${{ runner.os }}-tsc- - - run: yarn typecheck - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Typecheck - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - deps-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - run: yarn yarn-deduplicate --strategy=highest --list --fail - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Dependency checks - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - unit-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-jest-${{ github.run_id }} - restore-keys: ${{ runner.os }}-jest- - - run: yarn test --coverage --maxWorkers=100% - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false - flags: unit-tests - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Unit tests - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.swc - key: ${{ runner.os }}-swc-${{ github.run_id }} - restore-keys: ${{ runner.os }}-swc- - - run: yarn build - - uses: actions/upload-artifact@v3 - with: - name: build - path: build - if-no-files-found: error - - cypress-typecheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-cypress-tsc-${{ github.run_id }} - restore-keys: ${{ runner.os }}-cypress-tsc- - - run: yarn typecheck:cypress - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Cypress typecheck - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - # Allows for parallel re-runs of cypress tests without re-building. - cypress-rerun: - runs-on: ubuntu-latest - steps: - - run: exit 0 - - cypress-test-matrix: - needs: [build, cypress-rerun] - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - containers: [1, 2, 3, 4] - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: /root/.cache/Cypress - key: ${{ runner.os }}-cypress-${{ hashFiles('**/node_modules/cypress/package.json') }} - - run: | - yarn cypress install - yarn cypress info - - - uses: actions/download-artifact@v3 - with: - name: build - path: build - - - uses: actions/cache/restore@v3 - with: - path: cache - key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }} - restore-keys: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}- - - - uses: cypress-io/github-action@v4 - with: - install: false - record: true - parallel: true - start: yarn serve - wait-on: 'http://localhost:3000' - browser: electron - group: e2e - spec: ${{ github.ref_name == 'releases/staging' && 'cypress/{e2e,staging}/**/*.test.ts' || 'cypress/e2e/**/*.test.ts' }} - env: - CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COMMIT_INFO_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }} - COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title || github.event.head_commit.message }} - COMMIT_INFO_AUTHOR: ${{ github.event.sender.login || github.event.head_commit.author.login }} - # Cypress requires an email for filtering by author, but GitHub does not expose one. - # GitHub's public profile email can be deterministically produced from user id/login. - COMMIT_INFO_EMAIL: ${{ github.event.sender.id || github.event.head_commit.author.id }}+${{ github.event.sender.login || github.event.head_commit.author.login }}@users.noreply.github.com - COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha || github.event.head_commit.sha }} - COMMIT_INFO_TIMESTAMP: ${{ github.event.pull_request.updated_at || github.event.head_commit.timestamp }} - CYPRESS_PULL_REQUEST_ID: ${{ github.event.pull_request.number }} - CYPRESS_PULL_REQUEST_URL: ${{ github.event.pull_request.html_url }} - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Cypress tests - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - - uses: actions/upload-artifact@v3 - with: - name: hardhat-cache - path: cache - - hardhat-cache: - needs: [cypress-test-matrix] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - with: - name: hardhat-cache - path: cache - - uses: actions/cache/save@v3 - with: - path: cache - key: ${{ runner.os }}-hardhat-${{ hashFiles('hardhat.config.js') }}-${{ github.run_id }} - - cloud-typecheck: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-cloud-tsc-${{ github.run_id }} - restore-keys: ${{ runner.os }}-cloud-tsc- - - run: yarn typecheck:cloud - - if: failure() && github.ref_name == 'main' - uses: ./.github/actions/report - with: - name: Cloud typecheck - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_TEST_REPORTER_WEBHOOK }} - - cloud-tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: ./.github/actions/setup - - uses: actions/cache@v3 - with: - path: node_modules/.cache - key: ${{ runner.os }}-cloud-jest-${{ github.run_id }} - restore-keys: ${{ runner.os }}-cloud-jest- - # Ignore start:cloud output so it doesn't flood the test output. - # Only use 1 worker for testing, as the other is used to run start:cloud (the proxy server under test). - - run: yarn start-server-and-test 'yarn start:cloud >/dev/null' 3000 'yarn test:cloud --coverage --maxWorkers=1' - - uses: codecov/codecov-action@v3 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: false - flags: cloud-tests - - pre: - if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }} - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v6.4.1 - with: - script: | - github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, - state: 'pending', - context: 'Test / promotion', - description: 'Running tests...', - target_url: 'https://github.com/Uniswap/interface/actions/runs/' + context.runId - }) - - post: - if: ${{ github.ref_name == 'main' || github.ref_name == 'releases/staging' }} - needs: [pre, lint, typecheck, deps-tests, unit-tests, cypress-test-matrix, cloud-tests] - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v6.4.1 - with: - script: | - github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, - state: ${{ env.STATUS }} ? 'success' : 'failure', - context: 'Test / promotion', - description: ${{ env.STATUS }} ? 'All tests passed' : 'One or more tests failed and are blocking promotion', - target_url: 'https://github.com/Uniswap/interface/actions/runs/' + context.runId - }) - env: - STATUS: | - ${{ needs.lint.result == 'success' }} && - ${{ needs.typecheck.result == 'success' }} && - ${{ needs.deps-tests.result == 'success' }} && - ${{ needs.unit-tests.result == 'success' }} && - ${{ needs.cypress-test-matrix.result == 'success' }} && - ${{ needs.cloud-tests.result == 'success' }}