diff --git a/.github/workflows/test_ui.yml b/.github/workflows/test_ui.yml index e6114de50..b46a82667 100644 --- a/.github/workflows/test_ui.yml +++ b/.github/workflows/test_ui.yml @@ -7,7 +7,7 @@ on: - ".github/workflows/test_ui.yml" jobs: - test: + checks: runs-on: artemis-ui-test-runner-4 env: UI_PATH: ./ui @@ -22,6 +22,8 @@ jobs: uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # actions/setup-node@v4.4.0 with: node-version-file: "${{ env.UI_PATH }}/.nvmrc" + cache: npm + cache-dependency-path: "${{ env.UI_PATH }}/package-lock.json" - uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # hashicorp/setup-terraform@v3.1.2 @@ -36,10 +38,38 @@ jobs: working-directory: ${{ env.UI_PATH }} - name: Run precommit checks (linting & testing etc) - run: make -C $UI_PATH precommit + run: make -C $UI_PATH lint check audit + + tests: + runs-on: artemis-ui-test-runner-4 + strategy: + matrix: + shard: [1, 2, 3, 4] + env: + UI_PATH: ./ui + NPM_VERSION: 10 + steps: + - name: Checkout the code + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # actions/checkout@v4.2.2 + + - name: Setup node from node version file + uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # actions/setup-node@v4.4.0 + with: + node-version-file: "${{ env.UI_PATH }}/.nvmrc" + cache: npm + cache-dependency-path: "${{ env.UI_PATH }}/package-lock.json" + + - name: Set up the npm version + run: npm install --global npm@$NPM_VERSION + + - name: Install npm packages + run: make -C $UI_PATH install + + - name: Run tests + run: make -C $UI_PATH test JESTFLAGS="--shard=${{ matrix.shard }}/${{ strategy.job-total }}" - name: Save test results uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # actions/upload-artifact@v4.6.2 with: - name: ui-test + name: ui-test-${{ matrix.shard }} path: ui/test-report/index.html diff --git a/ui/Makefile b/ui/Makefile index 2be859ed9..45d30e6d8 100644 --- a/ui/Makefile +++ b/ui/Makefile @@ -30,6 +30,8 @@ ifeq ($(HADOLINT),) HADOLINT := ${CURDIR}/hadolint endif TERRAFORM = terraform +# Additional Jest options. +JESTFLAGS = APP := artemis-ui PORT := 3000 @@ -212,7 +214,7 @@ audit: package.json package-lock.json ## Audit package dependencies for vulnera .PHONY: test test: ## Run tests @echo "${INFO}Running tests" - CI=true $(NPM) test -- --env=jsdom --coverage --silent + CI=true $(NPM) test -- --env=jsdom --coverage --silent $(JESTFLAGS) @echo "${OK}" # run coding standards check