From d819b928a92797c9c382df2d297cd4168e462e09 Mon Sep 17 00:00:00 2001 From: pcheremu Date: Mon, 15 Apr 2024 13:07:32 +0200 Subject: [PATCH] test: return workflows --- .../workflows}/api-e2e.yml | 0 .../workflows}/app-deploy-feature-branch.yml | 0 .../workflows}/app-deploy-preview.yml | 0 .../workflows}/app-deploy-prod.yml | 0 .github/workflows/app-e2e.yml | 192 ++++++++++++++++++ .../workflows}/release.yml | 0 .../workflows}/validate-pr.yml | 0 packages/tmp_workflows/app-e2e.yml | 192 ------------------ 8 files changed, 192 insertions(+), 192 deletions(-) rename {packages/tmp_workflows => .github/workflows}/api-e2e.yml (100%) rename {packages/tmp_workflows => .github/workflows}/app-deploy-feature-branch.yml (100%) rename {packages/tmp_workflows => .github/workflows}/app-deploy-preview.yml (100%) rename {packages/tmp_workflows => .github/workflows}/app-deploy-prod.yml (100%) create mode 100644 .github/workflows/app-e2e.yml rename {packages/tmp_workflows => .github/workflows}/release.yml (100%) rename {packages/tmp_workflows => .github/workflows}/validate-pr.yml (100%) delete mode 100644 packages/tmp_workflows/app-e2e.yml diff --git a/packages/tmp_workflows/api-e2e.yml b/.github/workflows/api-e2e.yml similarity index 100% rename from packages/tmp_workflows/api-e2e.yml rename to .github/workflows/api-e2e.yml diff --git a/packages/tmp_workflows/app-deploy-feature-branch.yml b/.github/workflows/app-deploy-feature-branch.yml similarity index 100% rename from packages/tmp_workflows/app-deploy-feature-branch.yml rename to .github/workflows/app-deploy-feature-branch.yml diff --git a/packages/tmp_workflows/app-deploy-preview.yml b/.github/workflows/app-deploy-preview.yml similarity index 100% rename from packages/tmp_workflows/app-deploy-preview.yml rename to .github/workflows/app-deploy-preview.yml diff --git a/packages/tmp_workflows/app-deploy-prod.yml b/.github/workflows/app-deploy-prod.yml similarity index 100% rename from packages/tmp_workflows/app-deploy-prod.yml rename to .github/workflows/app-deploy-prod.yml diff --git a/.github/workflows/app-e2e.yml b/.github/workflows/app-e2e.yml new file mode 100644 index 0000000000..c5cee9956d --- /dev/null +++ b/.github/workflows/app-e2e.yml @@ -0,0 +1,192 @@ +name: BE App E2E tests + +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-scan-v2.zksync.dev/' + required: true + default_network_value_for_e2e: + type: string + default: '/?network=mainnet' + required: true + testnet_network_value_for_e2e: + type: string + default: '/?network=sepolia' + 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_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 }} + +jobs: + e2e: + runs-on: [matterlabs-ci-runner] + permissions: + contents: read + defaults: + run: + working-directory: ./packages/app + strategy: + fail-fast: false + matrix: + tags: [ + "@artifactsSet1", + "@artifactsSet2", + "@artifactsSet3", + "@artifactsSet4", + "@redirectionSet1", + "@redirectionSet2", + "@redirectionSet3", + "@copying", + "@search", + "@testnetSmokeSuite" + ] + + name: '${{ matrix.tags }}' + container: + image: mcr.microsoft.com/playwright:v1.27.0-focal + options: --user 1001 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '18' + cache: 'npm' + +# - name: Cache node modules +# id: cache-nodemodules +# uses: actions/cache@v3 +# env: +# cache-name: cache-node-modules +# # Workaround for bug https://github.com/typicode/husky/issues/991 +# HUSKY: 0 +# with: +# path: node_modules +# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} +# restore-keys: | +# ${{ runner.os }}-build-${{ env.cache-name }}- +# ${{ runner.os }}-build- +# ${{ runner.os }}- + +# - name: Install dependencies +# working-directory: ./ +# if: steps.cache-nodemodules.outputs.cache-hit != 'true' +# run: | +# npm pkg delete scripts.prepare +# npm ci +# +# - 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 +# env: +# CI: 'true' +# TARGET_ENV: ${{ inputs.targetUrl }} +# run: | +# echo "Run tests" +# if [ "${{ matrix.tags }}" = "@testnetSmokeSuite" ]; then +# echo "Run in testnetSmokeSuite only" +# E2ENETWORK='${{ inputs.testnet_network_value_for_e2e }}' npx cucumber-js --tags "${{ matrix.tags }} ${{ inputs.environmentTags }} and not @mainnet" +# else +# echo "Run in mainnet" +# E2ENETWORK='${{ inputs.default_network_value_for_e2e }}' npx cucumber-js --tags "${{ matrix.tags }} ${{ inputs.environmentTags }} and not @testnet" +# fi +# +# - name: Save artifacts to Git +# if: always() +# uses: actions/upload-artifact@v3 +# with: +# name: allure-results +# path: packages/app/allure-results +# +# - name: Upload test results to Allure reporter +# if: always() +# env: +# ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} +# run: | +# ./allurectl upload allure-results +# echo "*Public report link: https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html" +# echo "*Public report link will be available when the 'Allure Report' job will be succesfully executed." +# +# - if: failure() +# name: Save artifacts +# uses: actions/upload-artifact@v3 +# with: +# name: portal_e2e_${{ github.run_number }}_artifacts +# path: packages/app/tests/e2e/artifacts/* +# +# publish: +# name: Allure Report +# runs-on: ubuntu-latest +# permissions: +# contents: write +# needs: e2e +# if: always() +# steps: +# - uses: actions/checkout@v3 +# +# - uses: actions/download-artifact@v2 +# with: +# name: allure-results +# path: packages/app/allure-results +# +# - name: Get Allure history +# uses: actions/checkout@v3 +# if: always() +# continue-on-error: true +# with: +# ref: gh-pages +# path: gh-pages +# +# - name: Allure Report action from marketplace +# uses: simple-elf/allure-report-action@v1.7 +# if: always() +# id: allure-report +# with: +# allure_results: packages/app/allure-results +# gh_pages: gh-pages +# allure_report: allure-report +# allure_history: allure-history +# keep_reports: 10 +# +# - name: Deploy report to Github Pages +# if: always() +# uses: peaceiris/actions-gh-pages@v2 +# env: +# PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# PUBLISH_BRANCH: gh-pages +# PUBLISH_DIR: allure-history +# +# - 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: | +# LINK1="${{ vars.ALLURE_ENDPOINT }}project/${{ vars.ALLURE_PROJECT_ID }}/launches?search=${{ env.BASE64_SEARCH_REQUEST }}" +# LINK2="https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html" +# echo "Allure [Private]($LINK1) and [Public]($LINK2) links:rocket: in git run #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY diff --git a/packages/tmp_workflows/release.yml b/.github/workflows/release.yml similarity index 100% rename from packages/tmp_workflows/release.yml rename to .github/workflows/release.yml diff --git a/packages/tmp_workflows/validate-pr.yml b/.github/workflows/validate-pr.yml similarity index 100% rename from packages/tmp_workflows/validate-pr.yml rename to .github/workflows/validate-pr.yml diff --git a/packages/tmp_workflows/app-e2e.yml b/packages/tmp_workflows/app-e2e.yml deleted file mode 100644 index 0e56d22699..0000000000 --- a/packages/tmp_workflows/app-e2e.yml +++ /dev/null @@ -1,192 +0,0 @@ -name: BE App E2E tests - -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-scan-v2.zksync.dev/' - required: true - default_network_value_for_e2e: - type: string - default: '/?network=mainnet' - required: true - testnet_network_value_for_e2e: - type: string - default: '/?network=sepolia' - 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_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 }} - -jobs: - e2e: - runs-on: [matterlabs-ci-runner] - permissions: - contents: read - defaults: - run: - working-directory: ./packages/app - strategy: - fail-fast: false - matrix: - tags: [ - "@artifactsSet1", - "@artifactsSet2", - "@artifactsSet3", - "@artifactsSet4", - "@redirectionSet1", - "@redirectionSet2", - "@redirectionSet3", - "@copying", - "@search", - "@testnetSmokeSuite" - ] - - name: '${{ matrix.tags }}' - container: - image: mcr.microsoft.com/playwright:v1.27.0-focal - options: --user 1001 - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - cache: 'npm' - - - name: Cache node modules - id: cache-nodemodules - uses: actions/cache@v3 - env: - cache-name: cache-node-modules - # Workaround for bug https://github.com/typicode/husky/issues/991 - HUSKY: 0 - with: - path: node_modules - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-build-${{ env.cache-name }}- - ${{ runner.os }}-build- - ${{ runner.os }}- - - - name: Install dependencies - working-directory: ./ - if: steps.cache-nodemodules.outputs.cache-hit != 'true' - run: | - npm pkg delete scripts.prepare - npm ci - - - 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 - env: - CI: 'true' - TARGET_ENV: ${{ inputs.targetUrl }} - run: | - echo "Run tests" - if [ "${{ matrix.tags }}" = "@testnetSmokeSuite" ]; then - echo "Run in testnetSmokeSuite only" - E2ENETWORK='${{ inputs.testnet_network_value_for_e2e }}' npx cucumber-js --tags "${{ matrix.tags }} ${{ inputs.environmentTags }} and not @mainnet" - else - echo "Run in mainnet" - E2ENETWORK='${{ inputs.default_network_value_for_e2e }}' npx cucumber-js --tags "${{ matrix.tags }} ${{ inputs.environmentTags }} and not @testnet" - fi - - - name: Save artifacts to Git - if: always() - uses: actions/upload-artifact@v3 - with: - name: allure-results - path: packages/app/allure-results - - - name: Upload test results to Allure reporter - if: always() - env: - ALLURE_TOKEN: ${{ secrets.ALLURE_TOKEN }} - run: | - ./allurectl upload allure-results - echo "*Public report link: https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html" - echo "*Public report link will be available when the 'Allure Report' job will be succesfully executed." - - - if: failure() - name: Save artifacts - uses: actions/upload-artifact@v3 - with: - name: portal_e2e_${{ github.run_number }}_artifacts - path: packages/app/tests/e2e/artifacts/* - - publish: - name: Allure Report - runs-on: ubuntu-latest - permissions: - contents: write - needs: e2e - if: always() - steps: - - uses: actions/checkout@v3 - - - uses: actions/download-artifact@v2 - with: - name: allure-results - path: packages/app/allure-results - - - name: Get Allure history - uses: actions/checkout@v3 - if: always() - continue-on-error: true - with: - ref: gh-pages - path: gh-pages - - - name: Allure Report action from marketplace - uses: simple-elf/allure-report-action@v1.7 - if: always() - id: allure-report - with: - allure_results: packages/app/allure-results - gh_pages: gh-pages - allure_report: allure-report - allure_history: allure-history - keep_reports: 10 - - - name: Deploy report to Github Pages - if: always() - uses: peaceiris/actions-gh-pages@v2 - env: - PERSONAL_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PUBLISH_BRANCH: gh-pages - PUBLISH_DIR: allure-history - - - 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: | - LINK1="${{ vars.ALLURE_ENDPOINT }}project/${{ vars.ALLURE_PROJECT_ID }}/launches?search=${{ env.BASE64_SEARCH_REQUEST }}" - LINK2="https://raw.githack.com/matter-labs/block-explorer/gh-pages/${{ github.run_number }}/index.html" - echo "Allure [Private]($LINK1) and [Public]($LINK2) links:rocket: in git run #${{ github.run_number }}" >> $GITHUB_STEP_SUMMARY