Skip to content

Commit 8d16236

Browse files
authored
Merge pull request #125 from cdrini/feature/github-ci
Add lint/test CI
2 parents 8c0602b + 5d8548c commit 8d16236

File tree

2 files changed

+86
-3
lines changed

2 files changed

+86
-3
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
install:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-node@v4
19+
with:
20+
# Keep in sync
21+
node-version: 20.x
22+
- name: Cache node_modules
23+
uses: actions/cache@v3
24+
id: cache
25+
with:
26+
# Caching node_modules isn't recommended because it can break across
27+
# Node versions and won't work with npm ci (See https://github.com/actions/cache/blob/main/examples.md#node---npm )
28+
# But we pin the node version, and we don't update it that often anyways. And
29+
# we don't use `npm ci` specifically to try to get faster CI flows. So caching
30+
# `node_modules` directly.
31+
path: 'node_modules'
32+
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
33+
- if: steps.cache.outputs.cache-hit != 'true'
34+
run: npm install
35+
36+
build:
37+
needs: install
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: actions/setup-node@v4
42+
with:
43+
node-version: 20.x
44+
- name: Load node_modules from cache
45+
uses: actions/cache@v3
46+
with:
47+
# Use node_modules from previous jobs
48+
path: 'node_modules'
49+
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
50+
- run: npm run buildOnly
51+
52+
lint:
53+
needs: install
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@v4
57+
- uses: actions/setup-node@v4
58+
with:
59+
node-version: 20.x
60+
- name: Load node_modules from cache
61+
uses: actions/cache@v3
62+
with:
63+
# Use node_modules from previous jobs
64+
path: 'node_modules'
65+
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
66+
- run: npm run lint
67+
68+
test:
69+
needs: install
70+
runs-on: ubuntu-latest
71+
steps:
72+
- uses: actions/checkout@v4
73+
- uses: actions/setup-node@v4
74+
with:
75+
node-version: 20.x
76+
- name: Load node_modules from cache
77+
uses: actions/cache@v3
78+
with:
79+
# Use node_modules from previous jobs
80+
path: 'node_modules'
81+
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
82+
- run: npm run test

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
"lint": "eslint src test",
1616
"watch": "watch 'npm run build' src test",
1717
"test": "vitest run",
18-
"prebuild": "npm run lint -s && npm run clean -s && mkdirp dist",
19-
"build": "npm run rollup -s && npm run babel -s",
18+
"prebuild": "npm run lint -s",
19+
"build": "npm run buildOnly",
20+
"buildOnly": "npm run clean -s && mkdirp dist && npm run rollup -s && npm run babel -s",
2021
"rollup-esm": "rollup src/index.js --output.format esm --name AsyncComputed --output.file dist/vue-async-computed.esm.esnext.js",
2122
"rollup-umd": "rollup src/index.js --output.format umd --name AsyncComputed --output.file dist/vue-async-computed.esnext.js",
2223
"rollup": "npm run rollup-umd -s && npm run rollup-esm -s",
2324
"babel-umd": "babel --optional runtime dist/vue-async-computed.esnext.js --out-file dist/vue-async-computed.js",
2425
"babel-esm": "babel --optional runtime dist/vue-async-computed.esm.esnext.js --out-file dist/vue-async-computed.esm.js",
2526
"babel": "npm run babel-umd -s && npm run babel-esm -s",
26-
"postbuild": "vitest run",
27+
"postbuild": "npm run test -s",
2728
"prepublishOnly": "npm run build -s",
2829
"patch": "npm version patch && npm publish",
2930
"minor": "npm version minor && npm publish",

0 commit comments

Comments
 (0)