From 2970b3edf2eaa1643b6a81e61ec49e5962da49fe Mon Sep 17 00:00:00 2001 From: Konnor Rogers Date: Thu, 19 Sep 2024 11:22:57 -0400 Subject: [PATCH] Reduce GH Action minutes (#177) * dont cache playwright * prettier * prettier * fix crashing in form.test.ts * prettier * prettier * fix crashing in form.test.ts --- .github/workflows/node.js.yml | 83 +++++++++++------------------------ package.json | 1 - src/internal/form.test.ts | 6 ++- web-test-runner.config.js | 4 +- 4 files changed, 34 insertions(+), 60 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index dbc3a46d1..565f2252a 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -1,37 +1,6 @@ # # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node # # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions -# name: Node.js CI - -# on: -# push: -# branches: [next] -# pull_request: -# branches: [next] - -# jobs: -# build: -# runs-on: ubuntu-latest - -# strategy: -# matrix: -# node-version: [20.x] -# # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - -# steps: -# - uses: actions/checkout@v4 -# - name: Use Node.js ${{ matrix.node-version }} -# uses: actions/setup-node@v4 -# with: -# node-version: ${{ matrix.node-version }} -# cache: 'npm' -# - run: npm ci -# - run: npx playwright install-deps -# - run: npm run verify - -# # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions - name: Node.js CI on: @@ -41,7 +10,7 @@ on: branches: [next] jobs: - lint: + client_test: runs-on: ubuntu-latest strategy: @@ -56,10 +25,19 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - run: npm ci - - run: npm run prettier && npm run lint - test_client: + - name: Install dependencies + run: npm ci + - name: Lint + run: npm run prettier && npm run lint + - name: Build + run: npm run build + - name: Install Playwright + run: npx playwright install --with-deps + - name: Run CSR tests + # FAIL_FAST to fail on first failing test. + run: FAIL_FAST="true" CSR_ONLY="true" npm run test + ssr_test: runs-on: ubuntu-latest strategy: @@ -74,28 +52,19 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' - - run: npm ci - - run: npx playwright uninstall --all && npx playwright install --force chromium firefox webkit --with-deps - - run: npm run build - # --bail to fail on first failing test. - - run: CSR_ONLY="true" npm run test -- --bail + - name: Install dependencies + run: npm ci + # Just lint here too. Save some GH Action minutes and not need to use "depends_on" or anything. + - name: Lint + run: npm run prettier && npm run lint - test_ssr: - runs-on: ubuntu-latest + - name: Build + run: npm run build - strategy: - matrix: - node-version: [20.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + - name: Install Playwright + run: npx playwright install --with-deps + + - name: Run SSR tests + # FAIL_FAST to fail on first failing test. + run: FAIL_FAST="true" SSR_ONLY="true" npm run test - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - run: npm ci - - run: npx playwright uninstall --all && npx playwright install --force chromium firefox webkit --with-deps - - run: npm run build - - run: SSR_ONLY="true" npm run test -- --bail diff --git a/package.json b/package.json index 1f6d0b88f..073a2fbb6 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "start:alpha": "node scripts/build.js --alpha --develop", "publish-alpha-cdn": "./publish-alpha-cdn.sh", "create": "plop --plopfile scripts/plop/plopfile.js", - "prepare": "npm i --ignore-scripts && npx playwright install", "test": "web-test-runner --group default", "test:component": "web-test-runner -- --watch --group", "test:watch": "web-test-runner --watch --group default", diff --git a/src/internal/form.test.ts b/src/internal/form.test.ts index 42cdaf9b4..48b4e2ab4 100644 --- a/src/internal/form.test.ts +++ b/src/internal/form.test.ts @@ -1,4 +1,5 @@ import { aTimeout, expect, waitUntil } from '@open-wc/testing'; +import { clickOnElement } from './test.js'; import { fixtures } from './test/fixture.js'; import { html } from 'lit'; import sinon from 'sinon'; @@ -8,7 +9,6 @@ describe('Form tests', () => { describe(`with "${fixture.type}" rendering`, () => { // Reproduction of this issue: https://github.com/shoelace-style/shoelace/issues/1703 it('Should still run form validations if an element is removed', async () => { - await aTimeout(500); const form = await fixture(html`
@@ -28,6 +28,10 @@ describe('Form tests', () => { expect(form.checkValidity()).to.equal(false); expect(form.reportValidity()).to.equal(false); + + // This is silly,but it fixes an issue with `reportValidity()` causing WebKit to crash. + await clickOnElement(document.body); + await aTimeout(100); }); it('should submit the correct form values', async () => { diff --git a/web-test-runner.config.js b/web-test-runner.config.js index ec1e40fcc..db0e32e06 100644 --- a/web-test-runner.config.js +++ b/web-test-runner.config.js @@ -33,7 +33,9 @@ export default { testFramework: { config: { timeout: 3000, - retries: 1 + retries: 1, + // fails the whole test suite on first failure rather than letting the whole test suite run. + bail: process.env['FAIL_FAST'] === 'true' } }, plugins: [