Skip to content

Commit

Permalink
tweak gh actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vincerubinetti committed Sep 10, 2024
1 parent 83fec44 commit 2edb2b3
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 23 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/actions/install-playwright/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Install Playwright
description: Install Playwright and dependencies with cache

# https://github.com/microsoft/playwright/issues/7249

inputs:
working-directory:
description: Where to install Playwright
default: ./

outputs:
version:
description: Installed version of Playwright
value: ${{ steps.version.outputs.version }}
cache-hit:
description: Whether cache for Playwright was found
value: ${{ steps.cache.outputs.cache-hit }}

runs:
using: composite
steps:
- name: Get Playwright version
id: version
shell: bash
working-directory: ${{ inputs.working-directory }}
run: |
VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Version: $VERSION"
echo "PLAYWRIGHT_VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Cache Playwright
id: cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright and its dependencies
shell: bash
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ${{ inputs.working-directory }}
run: npx playwright install chromium --with-deps

- name: Install just Playwright's dependencies
shell: bash
if: steps.cache.outputs.cache-hit == 'true'
working-directory: ${{ inputs.working-directory }}
run: npx playwright install-deps
24 changes: 3 additions & 21 deletions .github/workflows/test-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,28 +87,10 @@ jobs:
if: runner.debug == '1'
uses: mxschmitt/action-tmate@v3

# https://github.com/microsoft/playwright/issues/7249

- name: Get Playwright version
run: |
PLAYWRIGHT_VERSION=$(npm ls @playwright/test | grep @playwright | sed 's/.*@//')
echo "Playwright Version: $PLAYWRIGHT_VERSION"
echo "PLAYWRIGHT_VERSION=$PLAYWRIGHT_VERSION" >> $GITHUB_ENV
- name: Cache Playwright
id: cache-playwright
uses: actions/cache@v4
- name: Install Playwright
uses: ./.github/actions/install-playwright
with:
path: ~/.cache/ms-playwright
key: playwright-${{ env.PLAYWRIGHT_VERSION }}

- name: Install Playwright with dependencies
if: steps.cache-playwright.outputs.cache-hit != 'true'
run: npx playwright install --with-deps

- name: Install Playwright's dependencies
if: steps.cache-playwright.outputs.cache-hit == 'true'
run: npx playwright install-deps
working-directory: ./app

- name: Run test
run: bun run test:e2e
Expand Down
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"build": "vite build",
"dev": "vite",
"preview": "vite preview",
"lint": "eslint . --fix && prettier **/*.{tsx,ts,css,html,md,json,yaml} --write --no-error-on-unmatched-pattern",
"test:lint": "eslint . && prettier **/*.{tsx,ts,css,html,md,json,yaml} --check --no-error-on-unmatched-pattern",
"lint": "eslint . --fix && prettier **/*.{tsx,ts,module.css,css,html,md,json,yaml} --write --no-error-on-unmatched-pattern",
"test:lint": "eslint . && prettier **/*.{tsx,ts,module.css,css,html,md,json,yaml} --check --no-error-on-unmatched-pattern",
"test:types": "tsc",
"test:e2e": "playwright test",
"test": "bun run test:lint && bun run test:types && bun run test:e2e",
Expand Down

0 comments on commit 2edb2b3

Please sign in to comment.