Skip to content

Commit ff87f13

Browse files
committed
ci: create setup action for Node.js environment and update CI workflow
1 parent 5352fcd commit ff87f13

File tree

2 files changed

+67
-29
lines changed

2 files changed

+67
-29
lines changed

.github/action/setup/action.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup
2+
description: Setup Node.js and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js
8+
uses: actions/setup-node@v4
9+
with:
10+
node-version-file: .nvmrc
11+
12+
- name: Cache dependencies
13+
id: yarn-cache
14+
uses: actions/cache@v3
15+
with:
16+
path: |
17+
**/node_modules
18+
.yarn/install-state.gz
19+
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}-${{ hashFiles('**/package.json', '!node_modules/**') }}
20+
restore-keys: |
21+
${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
22+
${{ runner.os }}-yarn-
23+
24+
- name: Install dependencies
25+
if: steps.yarn-cache.outputs.cache-hit != 'true'
26+
run: yarn install --immutable
27+
shell: bash

.github/workflows/test.yml

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,51 @@
1-
name: Test
2-
1+
name: CI
32
on:
3+
push:
4+
branches:
5+
- main
46
pull_request:
5-
types: [opened, synchronize, reopened]
67
branches:
78
- main
8-
- master
9+
merge_group:
10+
types:
11+
- checks_requested
912

1013
jobs:
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Setup
21+
uses: ./.github/actions/setup
22+
23+
- name: Lint files
24+
run: yarn lint
25+
26+
- name: Typecheck files
27+
run: yarn typecheck
28+
1129
test:
1230
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v3
34+
35+
- name: Setup
36+
uses: ./.github/actions/setup
1337

14-
strategy:
15-
matrix:
16-
node-version: [18.x]
38+
- name: Run unit tests
39+
run: yarn test:coverage --maxWorkers=2
1740

41+
build-library:
42+
runs-on: ubuntu-latest
1843
steps:
19-
- uses: actions/checkout@v4
20-
21-
- name: Use Node.js ${{ matrix.node-version }}
22-
uses: actions/setup-node@v4
23-
with:
24-
node-version: ${{ matrix.node-version }}
25-
cache: 'npm'
26-
27-
- name: Install dependencies
28-
run: npm ci
29-
30-
- name: Run tests with coverage
31-
run: npm test -- --coverage
32-
33-
- name: Upload coverage reports to Codecov
34-
uses: codecov/codecov-action@v4
35-
with:
36-
token: ${{ secrets.CODECOV_TOKEN }}
37-
directory: ./coverage/
38-
flags: unittests
39-
name: codecov-umbrella
40-
fail_ci_if_error: true
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
47+
- name: Setup
48+
uses: ./.github/actions/setup
49+
50+
- name: Build package
51+
run: yarn prepare

0 commit comments

Comments
 (0)