From 4e148151b543791ca40af152cdeecae55cd62c21 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Wed, 25 Jun 2025 13:57:18 +0800 Subject: [PATCH] cache playwright in ci --- .github/actions/setup-playwright/action.yml | 20 ++++++++++++++++++++ .github/workflows/tests.yml | 15 ++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 .github/actions/setup-playwright/action.yml diff --git a/.github/actions/setup-playwright/action.yml b/.github/actions/setup-playwright/action.yml new file mode 100644 index 00000000..dcb08c9e --- /dev/null +++ b/.github/actions/setup-playwright/action.yml @@ -0,0 +1,20 @@ +name: "Setup Playwright" +description: "Setup Playwright with caching, using npm (should already be installed)" +runs: + using: "composite" + steps: + - name: Extract Playwright version + id: playwright-version + shell: bash + run: echo "PLAYWRIGHT_VERSION=$(jq -r '.devDependencies.playwright' package.json)" >> $GITHUB_ENV + + - name: Cache Playwright + id: playwright-cache + uses: actions/cache@v4 + with: + path: ~/.cache/ms-playwright + key: playwright-${{ runner.os }}-${{ env.PLAYWRIGHT_VERSION }} + + - name: Install Playwright dependencies + shell: bash + run: npx playwright install --with-deps --only-shell diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3927ed44..0b891a7c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -101,35 +101,44 @@ jobs: name: Test next-ui steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version-file: '.nvmrc' cache: 'npm' cache-dependency-path: next-ui/package-lock.json + - name: npm install working-directory: next-ui run: npm ci - - name: npx playwright install --with-deps - working-directory: next-ui - run: npx playwright install --with-deps + + - name: Setup Playwright + uses: ./.github/actions/setup-playwright + - name: test:unit working-directory: next-ui run: npm run test:unit + + # retry because of https://github.com/storybookjs/storybook/issues/31599 - name: test:storybook uses: nick-fields/retry@v3 with: command: npm run --prefix next-ui test:storybook max_attempts: '3' timeout_minutes: '5' + - name: lint working-directory: next-ui run: npm run lint + - name: prettier working-directory: next-ui run: npm run prettier + - name: type-check working-directory: next-ui run: npm run type-check + - name: build working-directory: next-ui run: npm run build-only