From 17395ace6f65c0a5bf42f2772dee5ba4455377cf Mon Sep 17 00:00:00 2001 From: zkcarter Date: Fri, 12 Apr 2024 11:56:24 +0800 Subject: [PATCH] refactor github workflow --- .github/workflows/ci.yaml | 29 +++++ .github/workflows/e2e.yml | 164 ---------------------------- .github/workflows/feature.yml | 55 ---------- .github/workflows/lint-pr-title.yml | 19 ---- .github/workflows/production.yml | 56 ---------- .github/workflows/release.yml | 88 --------------- .github/workflows/version.yml | 54 --------- 7 files changed, 29 insertions(+), 436 deletions(-) create mode 100644 .github/workflows/ci.yaml delete mode 100644 .github/workflows/e2e.yml delete mode 100644 .github/workflows/feature.yml delete mode 100644 .github/workflows/lint-pr-title.yml delete mode 100644 .github/workflows/production.yml delete mode 100644 .github/workflows/release.yml delete mode 100644 .github/workflows/version.yml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..7f70a886 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,29 @@ +name: CI +on: [push] + +jobs: + build: + name: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: 18.x + + - name: Run npm install + run: npm ci + + - name: Run Build Command + run: | + if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then + npm run generate:node:nexus + elif [[ ${{ github.ref }} == 'refs/heads/preview' ]]; then + npm run generate:node:nexus + elif [[ ${{ github.ref }} == 'refs/heads/dev' ]]; then + npm run generate:node:nexus-sepolia + else + echo "No specific build command for this branch." + fi diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml deleted file mode 100644 index ca2f9afd..00000000 --- a/.github/workflows/e2e.yml +++ /dev/null @@ -1,164 +0,0 @@ -name: Testing Portal using e2e -on: - workflow_call: - secrets: - ALLURE_TOKEN: - description: 'A token passed from the caller workflow' - required: true - inputs: - environmentTags: - type: string - default: '' - required: false - targetUrl: - type: string - default: 'https://staging-portal.zksync.dev/' - required: true - network: - type: string - default: 'Goerli' - required: true - publish_to_allure: #Here we define the variable that can be overwritten by caller workflow - type: boolean - description: "Publish test results to allure" - default: true - required: false - -env: - ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - ALLURE_SEARCH_REQUEST: '[{"id":"name","type":"string","value":"#${{ github.run_number }}"}]' - ALLURE_BASIC_TAGS: "${{ github.head_ref }}, #${{ github.run_number }}, ${{ github.event.pull_request.title }}" - ALLURE_PROJECT_ID: ${{ vars.ALLURE_PROJECT_ID }} - ALLURE_ENDPOINT: ${{ vars.ALLURE_ENDPOINT }} - - E2E_WALLET_SECRET_PK: ${{ secrets.E2E_WALLET_SECRET_PK }} - E2E_WALLET_SALT_IV: ${{ secrets.E2E_WALLET_SALT_IV }} - E2E_WALLET_PASSWORD_MM: ${{ secrets.E2E_WALLET_PASSWORD_MM }} - - E2E_WALLET_1_MAIN: ${{ vars.E2E_WALLET_1_MAIN }} - E2E_WALLET_2_SECOND: ${{ vars.E2E_WALLET_2_SECOND }} - E2E_WALLET_0_EMPTY: ${{ vars.E2E_WALLET_0_EMPTY }} - - E2E_WALLET_1_MAIN_PUB_KEY: ${{ vars.E2E_WALLET_1_MAIN_PUB_KEY }} - E2E_WALLET_2_SECOND_PUB_KEY: ${{ vars.E2E_WALLET_2_SECOND_PUB_KEY }} - E2E_WALLET_0_EMPTY_PUB_KEY: ${{ vars.E2E_WALLET_0_EMPTY_PUB_KEY }} - - -jobs: - e2e: - runs-on: [ matterlabs-ci-runner ] - strategy: - fail-fast: false - max-parallel: 20 - matrix: - command: ["xvfb-run --auto-servernum --server-args '-screen 0 1920x1080x24' npx cucumber-js --tags "] - tags: [ - "@artifacts and @bridge", - "@artifacts and @contactsPage", - "@artifacts and @depositPage", - "@artifacts and @transferPage", - "@artifacts and @header", - "@artifacts and @menuItems", - "@artifacts and @upperNavigationMenu", - "@artifacts and @contactsPage", - "@artifacts and @withdraw", - "@navigation and not @emptyWallet", - "@redirection and @resetAllowance", - "@artifacts and @various", - "@artifacts and @transactionsItems", - "@transactions and @deposit and @blockchain", - "@transactions and @deposit and @noblockchain", - "@transactions and @deposit and @emptyWallet", - "@transactions and @deposit and @resetAllowance", - "@transactions and @withdraw", - "@various and @emptyWallet", - "@actions and @contacts" - ] - - name: '${{ matrix.tags }}' - - container: - image: mcr.microsoft.com/playwright:v1.35.1-focal - options: --user root - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Create metamask extension folder - run: | - mkdir -p ./tests/e2e/src/support/extension - chown -R root ./ - chmod 777 -R ./tests/e2e/src/support/extension - - - name: Install Dependencies - run: | - npm i --no-audit - - - name: Install Metamask extension - run: | - echo "cd to tests/e2e/ dir" - cd tests/e2e/ - echo "Postinstall" - npm run postinstall - - - name: Download allurectl - run: | - wget https://github.com/allure-framework/allurectl/releases/latest/download/allurectl_linux_386 -O ./allurectl - - - name: Change permission for allurectl - run: | - chmod +x ./allurectl - - - name: Launch tests - id: launch - env: - CI: 'true' - TARGET_ENV: ${{ inputs.targetUrl }} - DAPP_NETWORK: ${{ inputs.network }} - run: | - echo "Run tests" - cd tests/e2e/ - ${{ matrix.command }}'${{ matrix.tags }} ${{ inputs.environmentTags }}' - - - name: Reset tags quotes - if: always() - run: | - echo "MATRIX_TAG_WITHOUT_QUOTES=$(echo ${{ matrix.tags }} | sed -e 's/@//g' )" >> $GITHUB_ENV - - - name: Create launch ID - if: always() - env: - ALLURE_LAUNCH_NAME: "#${{ github.run_number }} ${{ env.MATRIX_TAG_WITHOUT_QUOTES }}" - ALLURE_LAUNCH_TAGS: "${{ env.ALLURE_BASIC_TAGS }}, ${{ env.MATRIX_TAG_WITHOUT_QUOTES }}" - run: | - echo "ALLURE_LAUNCH_ID=$(./allurectl launch create --launch-name '${{ env.ALLURE_LAUNCH_NAME }}' --no-header --format ID | tail -n1)" >> $GITHUB_ENV - - - name: Upload tests to the Allure proj - if: always() && inputs.publish_to_allure == true # <-- no brackets, 'true' does not work here: https://github.com/actions/runner/issues/1483#issuecomment-1090972149 - run: | - ./allurectl upload tests/e2e/allure-results --launch-id ${{ env.ALLURE_LAUNCH_ID }} - ./allurectl launch close ${{ env.ALLURE_LAUNCH_ID }} - - - - if: failure() - name: Save artifacts - uses: actions/upload-artifact@v2 - with: - name: portal_e2e_${{ github.run_number }}_artifacts - path: tests/e2e/artifacts/* - - publish: - name: Publish Allure link to GIT - runs-on: ubuntu-latest - needs: e2e - if: always() - steps: - - name: Prepare a link - run: | - echo "BASE64_SEARCH_REQUEST=$(echo '${{ env.ALLURE_SEARCH_REQUEST }}' | base64)" >> $GITHUB_ENV - - - name: Publish Allure link to GIT Summary - run: | - LINK="${{ vars.ALLURE_ENDPOINT }}project/${{ vars.ALLURE_PROJECT_ID }}/launches?search=${{ env.BASE64_SEARCH_REQUEST }}" - echo "Allure [e2e tests]($LINK) :rocket: in git run #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/feature.yml b/.github/workflows/feature.yml deleted file mode 100644 index 20a5c9fb..00000000 --- a/.github/workflows/feature.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Deploy To Feature Branch -on: - pull_request: - -jobs: - build: - name: Build - runs-on: ubuntu-latest - outputs: - dappUrl: ${{ steps.deploy.outputs.details_url }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: | - npm ci --force - - - name: Lint - run: | - npm run lint - - - name: Setup .env - run: | - echo "WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > .env - echo "ANKR_TOKEN=${{ secrets.ANKR_TOKEN }}" >> .env - echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env - echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env - echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - - - name: Build - run: | - npm run generate - - - name: Reorganize Files - run: | - mkdir -p dist - mv dist/_nuxt dist/_nuxt - - - name: Deploy - uses: matter-labs/action-hosting-deploy@main - id: deploy - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING_ZKSYNC_DAPP_WALLET_V2 }}" - projectId: staging-zksync-dapp-wallet-v2 - expires: 7d diff --git a/.github/workflows/lint-pr-title.yml b/.github/workflows/lint-pr-title.yml deleted file mode 100644 index 396ca8d9..00000000 --- a/.github/workflows/lint-pr-title.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: "Lint PR" - -on: - pull_request: - types: - - opened - - edited - - synchronize - -jobs: - label: - name: Validate PR title - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v4 - with: - subjectPattern: ^(?![A-Z]).+$ - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml deleted file mode 100644 index 83770ce0..00000000 --- a/.github/workflows/production.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Deploy Package to Production -"on": - workflow_dispatch: - inputs: - version: - type: string - description: "A release version to deploy, e.g. v1.0.0" - required: true - default: "v1.0.0" - -jobs: - build_and_deploy: - name: Build and Deploy - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - fetch-tags: true - ref: refs/tags/${{ github.event.inputs.version }} - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: | - npm ci --force - - - name: Setup .env - run: | - echo "WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > .env - echo "ANKR_TOKEN=${{ secrets.ANKR_TOKEN }}" >> .env - echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env - echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env - echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - - - name: Build - run: | - npm run generate - - - name: Reorganize Files - run: | - mkdir -p dist - mv dist/_nuxt dist/_nuxt - - - name: Deploy to Production - uses: matter-labs/action-hosting-deploy@main - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DAPP_WALLET_V2 }}" - projectId: zksync-dapp-wallet-v2 - channelID: live diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 33f7c7c7..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: Publish Release -"on": - push: - branches: - - main - - '[0-9]+.*' - -jobs: - publish: - name: Publish - runs-on: ubuntu-latest - outputs: - releaseVersion: ${{ steps.release.outputs.releaseVersion }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: | - npm ci --force - - - name: Lint - run: | - npm run lint - - - name: Release - id: release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - VITE_FIREBASE_PROJECT_ID=zksync-dapp-wallet-v2 \ - npx semantic-release || true - - - staging: - name: Deploy to Staging - runs-on: ubuntu-latest - needs: publish - if: ${{ github.ref == 'refs/heads/main' && needs.publish.outputs.releaseVersion != '' }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: | - npm ci --force - - - name: Setup .env - run: | - echo "WALLET_CONNECT_PROJECT_ID=${{ secrets.WALLET_CONNECT_PROJECT_ID }}" > .env - echo "ANKR_TOKEN=${{ secrets.ANKR_TOKEN }}" >> .env - echo "SCREENING_API_URL=${{ secrets.SCREENING_API_URL }}" >> .env - echo "DATAPLANE_URL=${{ secrets.DATAPLANE_URL }}" >> .env - echo "RUDDER_KEY=${{ secrets.RUDDER_KEY }}" >> .env - - - name: Build - run: | - npm run generate - - - name: Reorganize Files - run: | - mkdir -p dist - mv dist/_nuxt dist/_nuxt - - - name: Deploy - uses: matter-labs/action-hosting-deploy@main - id: deploy - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_STAGING_ZKSYNC_DAPP_WALLET_V2 }}" - projectId: staging-zksync-dapp-wallet-v2 - channelID: live diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml deleted file mode 100644 index 280a43e9..00000000 --- a/.github/workflows/version.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Deploy Package to Preview -"on": - workflow_dispatch: - inputs: - version: - type: string - description: "A release version to deploy, e.g. v1.0.0" - required: true - default: "v1.0.0" - -jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest - outputs: - dappUrl: ${{ steps.deploy.outputs.details_url }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Download Dist package - uses: dsaltares/fetch-gh-release-asset@master - with: - version: "tags/${{ github.event.inputs.version }}" - file: "dist.zip" - target: "dist.zip" - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Unzip Dist package - run: | - unzip dist.zip - - - name: Deploy - id: deploy - uses: matter-labs/action-hosting-deploy@main - with: - repoToken: "${{ secrets.GITHUB_TOKEN }}" - firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DAPP_WALLET_V2 }}" - expires: 7d - projectId: zksync-dapp-wallet-v2 - channelID: ${{ github.event.inputs.version }} - - e2e: - needs: deploy - uses: ./.github/workflows/e2e.yml - name: E2E - secrets: inherit - with: - targetUrl: ${{ needs.deploy.outputs.dappUrl }} - network: Goerli - publish_to_allure: true - environmentTags: ""