-
Notifications
You must be signed in to change notification settings - Fork 18
81 lines (66 loc) · 1.96 KB
/
frontend-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Workflow for running several tests for PRs and pushes to the main branch for
# napari hub frontend code.
name: Frontend Tests
on:
push:
branches:
- main
paths:
- 'frontend/**'
pull_request:
branches:
- '**'
paths:
- 'frontend/**'
defaults:
run:
working-directory: frontend/
jobs:
# Runs several tests on the frontend codebase to check for code style,
# formatting, best practices, and run unit/integration tests.
tests:
name: ${{ matrix.name }}
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20.5.x
- name: Get Yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
# cache both yarn-lock and node_modules
- name: Setup Yarn cache
uses: actions/cache@v3
id: yarn-cache
with:
path: |
**/node_modules
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# --prefer-offline forces yarn to use cache if available
- name: Install dependencies with yarn
run: yarn install --prefer-offline --frozen-lockfile
- name: ${{ matrix.name }}
run: ${{ matrix.run }}
# Run linters and tests as matrix strategies so that they:
# 1. Show up as separate GitHub checks.
# 2. So we can reuse the Node.js and Yarn installation steps
strategy:
fail-fast: false
matrix:
include:
- name: prettier
run: yarn lint:prettier
- name: stylelint
run: yarn lint:stylelint
- name: eslint
run: yarn lint:eslint
- name: jest
run: yarn test
- name: tsc
run: yarn type-check