From 51ed353fa48afe1a8a5233fe96489b73aca36bf1 Mon Sep 17 00:00:00 2001 From: Michael Lange Date: Tue, 20 Jun 2023 20:21:37 -0700 Subject: [PATCH] Merge pull request #17626 from hashicorp/f/ui-test-splitting [UI, CI] Test splitting --- .github/workflows/test-ui.yml | 60 +++++++++++++++++++++++++++++------ ui/package.json | 4 ++- ui/testem.js | 26 --------------- 3 files changed, 54 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test-ui.yml b/.github/workflows/test-ui.yml index 87d3b401258f..62f810d7d3dd 100644 --- a/.github/workflows/test-ui.yml +++ b/.github/workflows/test-ui.yml @@ -36,22 +36,64 @@ on: - 'website/**' jobs: - test-ui: + pre-test: runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + working-directory: ui + outputs: + nonce: ${{ steps.nonce.outputs.nonce }} steps: - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 - name: yarn install - run: cd ui && yarn install --frozen-lockfile + run: yarn install --frozen-lockfile - name: lint:js - run: cd ui && yarn run lint:js + run: yarn run lint:js - name: lint:hbs - run: cd ui && yarn run lint:hbs - - name: Ember tests + run: yarn run lint:hbs + - id: nonce + name: nonce + run: echo "nonce=${{ github.run_id }}-$(date +%s)" >> "$GITHUB_OUTPUT" + + tests: + needs: + - pre-test + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + working-directory: ui + strategy: + matrix: + partition: [1, 2, 3, 4] + split: [4] + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: yarn install + run: yarn install --frozen-lockfile + - name: ember exam + env: + PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} + PERCY_PARALLEL_NONCE: ${{ needs.pre-test.outputs.nonce }} + run: yarn exam:parallel --split=${{ matrix.split }} --partition=${{ matrix.partition }} + finalize: + runs-on: ubuntu-latest + timeout-minutes: 30 + defaults: + run: + working-directory: ui + needs: + - pre-test + - tests + steps: + - uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2 + - name: yarn install + run: yarn install --frozen-lockfile + - name: finalize env: PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }} - run: mkdir -p /tmp/test-reports && cd ui && yarn exam - - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 - with: - path: "/tmp/test-reports" + PERCY_PARALLEL_NONCE: ${{ needs.pre-test.outputs.nonce }} + run: yarn percy build:finalize permissions: contents: read diff --git a/ui/package.json b/ui/package.json index af255ac8e458..9320f6ed0b2f 100644 --- a/ui/package.json +++ b/ui/package.json @@ -20,7 +20,9 @@ "build-storybook": "STORYBOOK=true ember build && build-storybook -s dist", "storybook": "STORYBOOK=true start-storybook -p 6006 -s dist", "test": "npm-run-all lint test:*", - "exam": "ember exam --split=4 --parallel", + "exam": "percy exec -- ember exam --split=4 --parallel", + "exam:parallel": "percy exec --parallel -- ember exam", + "percy": "percy", "test:ember": "percy exec -- ember test", "local:qunitdom": "ember test --server --query=dockcontainer", "local:exam": "ember exam --server --load-balance --parallel=4", diff --git a/ui/testem.js b/ui/testem.js index 0d47b107fe77..c77c62b55bd6 100644 --- a/ui/testem.js +++ b/ui/testem.js @@ -1,10 +1,5 @@ 'use strict'; -const MultiReporter = require('testem-multi-reporter'); -const TapReporter = require('testem/lib/reporters/tap_reporter'); -const XunitReporter = require('testem/lib/reporters/xunit_reporter'); -const fs = require('fs'); - const config = { test_page: 'tests/index.html?hidepassed', disable_watching: true, @@ -32,25 +27,4 @@ const config = { }, }; -if (process.env.CI) { - const reporters = [ - { - ReporterClass: TapReporter, - args: [false, null, { get: () => false }], - }, - { - ReporterClass: XunitReporter, - args: [ - false, - fs.createWriteStream('/tmp/test-reports/ui.xml'), - { get: () => false }, - ], - }, - ]; - - const multiReporter = new MultiReporter({ reporters }); - - config.reporter = multiReporter; -} - module.exports = config;