Skip to content

Commit 77a379c

Browse files
committed
👷 add GitHub Actions as CI
1 parent 04a0ce7 commit 77a379c

File tree

3 files changed

+71
-5
lines changed

3 files changed

+71
-5
lines changed

.github/actions/setup/action.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'Setup'
2+
description: "Setups Node.js and npm to run GitHub Actions' jobs."
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: 'Setup Node.js'
7+
uses: 'actions/setup-node@v3'
8+
with:
9+
node-version: '16.x'
10+
11+
- name: 'Keep npm cache'
12+
uses: 'actions/cache@v3'
13+
with:
14+
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}"
15+
path: '~/.npm'
16+
restore-keys: |
17+
${{ runner.os }}-node-
18+
19+
- name: 'Install dependencies'
20+
run: 'npm ci'
21+
shell: 'bash'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: 'Continuous Integrations'
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
7+
jobs:
8+
lint:
9+
name: 'Run ESLint and Prettier'
10+
runs-on: 'ubuntu-latest'
11+
steps:
12+
- name: 'Checkout the repository'
13+
uses: 'actions/checkout@v3'
14+
15+
- name: 'Setup Node.js and npm'
16+
uses: './.github/actions/setup'
17+
18+
- name: 'Execute the lint script'
19+
run: 'npm run lint'
20+
21+
22+
test:
23+
name: 'Run unit tests with Jest'
24+
runs-on: 'ubuntu-latest'
25+
steps:
26+
- name: 'Checkout the repository'
27+
uses: 'actions/checkout@v3'
28+
29+
- name: 'Setup Node.js and npm'
30+
uses: './.github/actions/setup'
31+
32+
- name: 'Execute the test script'
33+
run: 'npm run test'
34+
35+
bundle:
36+
name: 'Bundle package with Rollup.js'
37+
runs-on: 'ubuntu-latest'
38+
steps:
39+
- name: 'Checkout the repository'
40+
uses: 'actions/checkout@v3'
41+
42+
- name: 'Setup Node.js and npm'
43+
uses: './.github/actions/setup'
44+
45+
- name: 'Execute the build script'
46+
run: 'npm run build'

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,11 @@
4141
},
4242
"scripts": {
4343
"doc": "typedoc src/index.ts",
44-
"test": "npm run test:lint && npm run test:unit",
45-
"test:lint": "eslint \"*/**/*.{ts,js,json}\"",
46-
"test:unit": "jest",
47-
"lint": "eslint \"*/**/*.{ts,js,json}\" --fix",
44+
"test": "jest",
45+
"lint": "eslint \"*/**/*.{ts,js,json}\"",
46+
"lint:fix": "eslint \"*/**/*.{ts,js,json}\" --fix",
4847
"build": "rollup --config ./rollup.config.js",
49-
"prepublishOnly": "npm run doc && npm run build && npm run test"
48+
"prepublishOnly": "npm run doc && npm run lint && npm run test && npm run build"
5049
},
5150
"repository": {
5251
"type": "git",

0 commit comments

Comments
 (0)