From b743ac1400b480f3b095cab333c893b44ed4452e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Go=CC=81mez=20Bachiller?= Date: Thu, 28 Mar 2024 12:58:06 +0100 Subject: [PATCH] ci: add e2e test sharding --- .github/workflows/shard-e2e.yaml | 66 ++++++++++++++++++++++++++++++++ playwright.config.ts | 3 +- 2 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/shard-e2e.yaml diff --git a/.github/workflows/shard-e2e.yaml b/.github/workflows/shard-e2e.yaml new file mode 100644 index 0000000..08ff031 --- /dev/null +++ b/.github/workflows/shard-e2e.yaml @@ -0,0 +1,66 @@ +name: Run e2e tests + +on: + push: + branches: + - 'test-ci' + pull_request: + branches: + - 'test-ci' + +env: + MAILER_SECRET: E2E + AUTH_SECRET: E2E + +jobs: + e2e: + runs-on: ubuntu-latest + if: always() + services: + smtp: + image: "inbucket/inbucket" + ports: + - 1025:2500 + - 8025:9000 + db: + image: "postgres:12" + env: + POSTGRES_HOST_AUTH_METHOD: trust + POSTGRES_DB: codex_test + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + - 5432:5432 + strategy: + fail-fast: false + matrix: + node-version: [ 20.x ] + shardIndex: [ 1, 2 ] + shardTotal: [ 2 ] + name: Run e2e tests on Node ${{ matrix.node-version }} + env: + DATABASE_URL: postgres://postgres@localhost/codex_test_${{ matrix.shardIndex}} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup node + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - name: Install dependencies + run: yarn install --frozen-lockfile + - name: Run database migrations + run: npx prisma migrate reset --force + - name: Run e2e tests + run: yarn test:e2e --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} + - name: Upload test report + uses: actions/upload-artifact@v4 + if: always() + with: + name: blob-report-${{ matrix.shardIndex }} + path: blob-report/ + retention-days: 1 diff --git a/playwright.config.ts b/playwright.config.ts index 510e18d..10476bb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -8,6 +8,7 @@ dotenv.config({ path: '.env.test', }) +// eslint-disable-next-line import/no-default-export export default defineConfig({ fullyParallel: false, projects: [ @@ -22,7 +23,7 @@ export default defineConfig({ }, }, ], - reporter: 'html', + reporter: process.env.CI ? 'blob' : 'html', retries: 3, testDir: './e2e', use: {