|
| 1 | +name: Core Extension E2E Smoke Tests |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ['CI for main'] |
| 6 | + types: [completed] |
| 7 | + branches: [main] |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + test-run-type: |
| 11 | + type: choice |
| 12 | + description: 'Run smoke tests or full regression?' |
| 13 | + options: |
| 14 | + - smoke |
| 15 | + - full |
| 16 | + required: true |
| 17 | + default: 'smoke' |
| 18 | + push: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + pull_request: |
| 22 | + branches: |
| 23 | + - main |
| 24 | + types: |
| 25 | + - opened |
| 26 | + - reopened |
| 27 | + - synchronize |
| 28 | + - ready_for_review |
| 29 | + |
| 30 | +jobs: |
| 31 | + build-extension: |
| 32 | + name: Build Core Extension |
| 33 | + runs-on: ubuntu-latest-16-cores-core-extension |
| 34 | + if: '${{ !github.event.pull_request.draft }}' |
| 35 | + environment: alpha |
| 36 | + env: |
| 37 | + RUNNER: CI |
| 38 | + LOG_LEVEL: info |
| 39 | + POST_TO_TESTRAIL: true |
| 40 | + TESTRAIL_API_KEY: '${{ secrets.TESTRAIL_API_KEY }}' |
| 41 | + outputs: |
| 42 | + test_run_id: ${{ steps.trid.outputs.test_run_id }} |
| 43 | + steps: |
| 44 | + - name: Setup Node.js |
| 45 | + uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version: 22.14.0 |
| 48 | + check-latest: true |
| 49 | + |
| 50 | + - name: Enable corepack |
| 51 | + run: corepack enable |
| 52 | + |
| 53 | + - name: Checkout extension |
| 54 | + uses: actions/checkout@v4 |
| 55 | + with: |
| 56 | + ref: '${{ github.head_ref }}' |
| 57 | + fetch-depth: 0 |
| 58 | + |
| 59 | + - name: Create .npmrc |
| 60 | + run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}' >> .npmrc |
| 61 | + |
| 62 | + - name: Create env file |
| 63 | + run: | |
| 64 | + touch .env.production |
| 65 | + echo RELEASE=alpha >> .env.production |
| 66 | + echo POSTHOG_KEY=${{ secrets.POSTHOG_KEY }} >> .env.production |
| 67 | + echo POSTHOG_URL=${{ secrets.POSTHOG_URL }} >> .env.production |
| 68 | + echo COVALENT_API_KEY=${{ secrets.COVALENT_API_KEY }} >> .env.production |
| 69 | + echo GLACIER_URL=${{ secrets.GLACIER_URL }} >> .env.production |
| 70 | + echo PROXY_URL=${{ secrets.PROXY_URL }} >> .env.production |
| 71 | + echo CORE_EXTENSION_LANDING_URL=${{ secrets.CORE_EXTENSION_LANDING_URL }} >> .env.production |
| 72 | + echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> .env.production |
| 73 | + echo COINBASE_APP_ID=${{ secrets.COINBASE_APP_ID }} >> .env.production |
| 74 | + echo CORE_WEB_BASE_URL=${{ secrets.CORE_WEB_BASE_URL }} >> .env.production |
| 75 | + echo GLACIER_API_KEY=${{ secrets.GLACIER_API_KEY }} >> .env.production |
| 76 | + echo FIREBASE_CONFIG=${{ secrets.FIREBASE_CONFIG }} >> .env.production |
| 77 | + echo ID_SERVICE_URL=${{ secrets.ID_SERVICE_URL }} >> .env.production |
| 78 | + echo GASLESS_SERVICE_URL=${{ secrets.GASLESS_SERVICE_URL }} >> .env.production |
| 79 | + echo EXTENSION_PUBLIC_KEY=${{ secrets.EXTENSION_PUBLIC_KEY_E2E }} >> .env.production |
| 80 | + echo ID_SERVICE_API_KEY=${{ secrets.ID_SERVICE_API_KEY }} >> .env.production |
| 81 | + echo NOTIFICATION_SENDER_SERVICE_URL=${{ secrets.NOTIFICATION_SENDER_SERVICE_URL }} >> .env.production |
| 82 | +
|
| 83 | + - name: Install dependencies |
| 84 | + run: | |
| 85 | + yarn install |
| 86 | + yarn allow-scripts |
| 87 | +
|
| 88 | + - name: Build extension |
| 89 | + run: yarn build:next:alpha |
| 90 | + |
| 91 | + - name: Inject extension key |
| 92 | + run: | |
| 93 | + echo $(cat ./dist-next/manifest.json | jq '.key = "${{ secrets.EXTENSION_PUBLIC_KEY_E2E }}"') > ./dist-next/manifest.json |
| 94 | +
|
| 95 | + - name: Upload built extension |
| 96 | + uses: actions/upload-artifact@v4 |
| 97 | + with: |
| 98 | + name: extension |
| 99 | + path: ./dist-next |
| 100 | + |
| 101 | + - name: Install TestRail CLI |
| 102 | + run: pip3 install trcli |
| 103 | + |
| 104 | + - name: Create test run in TestRail |
| 105 | + id: trid |
| 106 | + run: | |
| 107 | + TS=$(date -u +'%Y-%m-%d-%H:%M:%S') |
| 108 | + TEST_RUN_ID=`trcli -y -h https://avalabs.testrail.io --project "Core Extension" --username ${{ vars.TESTRAIL_EMAIL }} --key ${{ secrets.TESTRAIL_API_KEY }} add_run --title "New Gen Core Extension - $TS" --run-include-all | grep "run_id:" | awk '{print $2}'` |
| 109 | + echo "test_run_id=$TEST_RUN_ID" >> $GITHUB_OUTPUT |
| 110 | +
|
| 111 | + playwright-tests: |
| 112 | + name: Run Extension E2E Tests - Shard ${{ matrix.shardIndex }}/${{ matrix.shardTotal }} |
| 113 | + needs: build-extension |
| 114 | + runs-on: ubuntu-latest-16-cores-core-extension |
| 115 | + permissions: |
| 116 | + id-token: write |
| 117 | + contents: read |
| 118 | + strategy: |
| 119 | + fail-fast: false |
| 120 | + matrix: |
| 121 | + shardIndex: [1] |
| 122 | + shardTotal: [1] |
| 123 | + env: |
| 124 | + AWS_REGION: us-east-1 |
| 125 | + TEST_RUN_ID: ${{ needs.build-extension.outputs.test_run_id }} |
| 126 | + RUNNER: CI |
| 127 | + LOG_LEVEL: info |
| 128 | + HEADLESS: 'true' |
| 129 | + WALLET_PASSWORD: '${{ secrets.WALLET_PASSWORD }}' |
| 130 | + RECOVERY_PHRASE_12_WORDS: '${{ secrets.RECOVERY_PHRASE_12_WORDS }}' |
| 131 | + RECOVERY_PHRASE_24_WORDS: '${{ secrets.RECOVERY_PHRASE_24_WORDS }}' |
| 132 | + container: |
| 133 | + image: mcr.microsoft.com/playwright:v1.52.0-noble |
| 134 | + options: --ipc=host --security-opt=seccomp=unconfined --cap-add=SYS_ADMIN --shm-size=4gb --memory=6g --cpus=4 |
| 135 | + |
| 136 | + steps: |
| 137 | + - name: Checkout |
| 138 | + uses: actions/checkout@v4 |
| 139 | + with: |
| 140 | + fetch-depth: 0 |
| 141 | + |
| 142 | + - name: Install Chrome |
| 143 | + working-directory: e2e_Playwright_Tests |
| 144 | + run: | |
| 145 | + apt-get update |
| 146 | + apt-get install -y wget gnupg |
| 147 | + wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - |
| 148 | + echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list |
| 149 | + apt-get update |
| 150 | + apt-get install -y google-chrome-stable |
| 151 | +
|
| 152 | + - name: Download built extension |
| 153 | + uses: actions/download-artifact@v4 |
| 154 | + with: |
| 155 | + name: extension |
| 156 | + path: ./e2e_Playwright_Tests/dist |
| 157 | + |
| 158 | + - name: Output Github runner |
| 159 | + run: | |
| 160 | + curl ifconfig.io |
| 161 | +
|
| 162 | + - name: Create test environment file |
| 163 | + run: | |
| 164 | + cd e2e_Playwright_Tests |
| 165 | + touch .env |
| 166 | + echo "WALLET_PASSWORD=${{ secrets.WALLET_PASSWORD }}" >> .env |
| 167 | + echo "RECOVERY_PHRASE_12_WORDS=${{ secrets.RECOVERY_PHRASE_12_WORDS }}" >> .env |
| 168 | + echo "RECOVERY_PHRASE_24_WORDS=${{ secrets.RECOVERY_PHRASE_24_WORDS }}" >> .env |
| 169 | +
|
| 170 | + - name: Configure aws Credentials |
| 171 | + uses: aws-actions/[email protected] |
| 172 | + with: |
| 173 | + role-to-assume: arn:aws:iam::975050371175:role/github-flow-sa-role |
| 174 | + role-session-name: GitHub_to_AWS_via_FederatedOIDC |
| 175 | + aws-region: ${{ env.AWS_REGION }} |
| 176 | + |
| 177 | + - name: Set Python for AWS CLI |
| 178 | + uses: actions/setup-python@v5 |
| 179 | + with: |
| 180 | + python-version: '3.13' |
| 181 | + |
| 182 | + - name: Install AWS dependencies |
| 183 | + shell: bash |
| 184 | + run: | |
| 185 | + python3 -m venv ~/py_env |
| 186 | + source ~/py_env/bin/activate |
| 187 | + pip3 install awscli |
| 188 | +
|
| 189 | + - name: Download Extension snapshots from AWS S3 bucket |
| 190 | + shell: bash |
| 191 | + working-directory: e2e_Playwright_Tests/helpers |
| 192 | + run: | |
| 193 | + mkdir -p storage-snapshots |
| 194 | + cd storage-snapshots |
| 195 | + source ~/py_env/bin/activate |
| 196 | + aws s3 sync s3://core-qa-automation-snapshots/ext/ . || echo "No snapshots found in S3, continuing..." |
| 197 | +
|
| 198 | + - name: Install Playwright dependencies |
| 199 | + run: | |
| 200 | + cd e2e_Playwright_Tests |
| 201 | + npm install |
| 202 | + npx playwright install --with-deps chromium |
| 203 | +
|
| 204 | + - name: Run Playwright smoke tests |
| 205 | + if: github.event.inputs.test-run-type == 'smoke' || github.event.inputs.test-run-type == '' || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_run' |
| 206 | + env: |
| 207 | + CI: true |
| 208 | + PLAYWRIGHT_SHARD: ${{ matrix.shardIndex }} |
| 209 | + run: | |
| 210 | + cd e2e_Playwright_Tests |
| 211 | + GREP_FILTER=$([ -z "${{ github.event.inputs.test-run-type }}" ] || [ "${{ github.event.inputs.test-run-type }}" = "smoke" ] && echo "--grep=@smoke" || echo "") |
| 212 | + PLAYWRIGHT_SHARD=${{ matrix.shardIndex }} npx playwright test --config=config/base.config.ts --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} $GREP_FILTER |
| 213 | +
|
| 214 | + - name: Run Playwright full regression tests |
| 215 | + if: github.event.inputs.test-run-type == 'full' |
| 216 | + env: |
| 217 | + CI: true |
| 218 | + PLAYWRIGHT_SHARD: ${{ matrix.shardIndex }} |
| 219 | + run: | |
| 220 | + cd e2e_Playwright_Tests |
| 221 | + PLAYWRIGHT_SHARD=${{ matrix.shardIndex }} npx playwright test --config=config/base.config.ts --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} |
| 222 | +
|
| 223 | + - name: Upload results to TestRail |
| 224 | + if: always() |
| 225 | + shell: bash |
| 226 | + run: | |
| 227 | + python3 -m venv ~/py_env |
| 228 | + source ~/py_env/bin/activate |
| 229 | + pip3 install trcli |
| 230 | + trcli -n -h https://avalabs.testrail.io --project "Core Extension" --username ${{ vars.TESTRAIL_EMAIL }} --key ${{ secrets.TESTRAIL_API_KEY }} parse_junit -f ./e2e_Playwright_Tests/test-results/junit-report-${{ matrix.shardIndex }}.xml --run-id=${{ env.TEST_RUN_ID }} || echo "TestRail upload failed, continuing..." |
| 231 | +
|
| 232 | + - name: Output TestRail run link |
| 233 | + if: always() |
| 234 | + run: echo https://avalabs.testrail.io/index.php?/runs/view/${{ env.TEST_RUN_ID }} |
| 235 | + |
| 236 | + - name: Upload files as artifacts |
| 237 | + if: always() |
| 238 | + uses: actions/upload-artifact@v4 |
| 239 | + with: |
| 240 | + name: test-results-${{ matrix.shardIndex }} |
| 241 | + path: | |
| 242 | + e2e_Playwright_Tests/test-results |
| 243 | + e2e_Playwright_Tests/playwright-report |
| 244 | + retention-days: 30 |
0 commit comments