Skip to content

Commit

Permalink
wip: test
Browse files Browse the repository at this point in the history
  • Loading branch information
hemengke1997 committed Oct 19, 2023
1 parent 9fe26ee commit 71d8ef2
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 14 deletions.
85 changes: 74 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
name: Test

env:
# install playwright binary manually (because pnpm only runs install script once)
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
# Vitest auto retry on flaky segfault
VITEST_SEGFAULT_RETRY: 3

on:
push:
branches:
Expand All @@ -11,25 +17,82 @@ on:

jobs:
test:
timeout-minutes: 20
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/[email protected]
uses: pnpm/action-setup@v2

- name: Set node version to 18
uses: actions/setup-node@v3
with:
version: 8.7.0
node-version: 18
cache: pnpm

- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Install deps
run: pnpm install

- name: Lint
run: pnpm lint

# Install playwright's binary under custom directory to cache
- name: Set Playwright path (non-windows)
if: runner.os != 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME/.cache/playwright-bin" >> $GITHUB_ENV
- name: Set Playwright path (windows)
if: runner.os == 'Windows'
run: echo "PLAYWRIGHT_BROWSERS_PATH=$HOME\.cache\playwright-bin" >> $env:GITHUB_ENV

- name: Cache Playwright's binary
uses: actions/cache@v3
with:
# Playwright removes unused browsers automatically
# So does not need to add playwright version to key
key: ${{ runner.os }}-playwright-bin-v1
path: ${{ env.PLAYWRIGHT_BROWSERS_PATH }}

- name: Install Playwright
# does not need to explicitly set chromium after https://github.com/microsoft/playwright/issues/14862 is solved
run: pnpm playwright install chromium

- name: Build
run: pnpm run build

- name: Test
run: pnpm test
run: pnpm run test:unit

- name: Test serve
run: pnpm run test:serve

- name: Test build
run: pnpm run test:build

lint:
timeout-minutes: 10
runs-on: ubuntu-latest
name: 'Lint: node-LTS, ubuntu-latest'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node version to LTS
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: pnpm

- name: Install deps
run: pnpm install

- name: Build
run: pnpm run build

- name: Lint
run: pnpm run lint
16 changes: 13 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
node_modules
dist
!**/glob-import/dir/node_modules
.DS_Store
.idea
.Ds_store
*.cpuprofile
*.local
*.log
/.vscode/
dist
dist-ssr
explorations
node_modules
playground-temp
temp
.eslintcache
coverage

0 comments on commit 71d8ef2

Please sign in to comment.