Skip to content

Commit

Permalink
Merge pull request #125 from cdrini/feature/github-ci
Browse files Browse the repository at this point in the history
Add lint/test CI
  • Loading branch information
cdrini authored Nov 19, 2023
2 parents 8c0602b + 5d8548c commit 8d16236
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 3 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
install:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
# Keep in sync
node-version: 20.x
- name: Cache node_modules
uses: actions/cache@v3
id: cache
with:
# Caching node_modules isn't recommended because it can break across
# Node versions and won't work with npm ci (See https://github.com/actions/cache/blob/main/examples.md#node---npm )
# But we pin the node version, and we don't update it that often anyways. And
# we don't use `npm ci` specifically to try to get faster CI flows. So caching
# `node_modules` directly.
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- if: steps.cache.outputs.cache-hit != 'true'
run: npm install

build:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v3
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- run: npm run buildOnly

lint:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v3
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- run: npm run lint

test:
needs: install
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Load node_modules from cache
uses: actions/cache@v3
with:
# Use node_modules from previous jobs
path: 'node_modules'
key: ${{ runner.os }}-node-20-${{ hashFiles('package*.json') }}
- run: npm run test
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@
"lint": "eslint src test",
"watch": "watch 'npm run build' src test",
"test": "vitest run",
"prebuild": "npm run lint -s && npm run clean -s && mkdirp dist",
"build": "npm run rollup -s && npm run babel -s",
"prebuild": "npm run lint -s",
"build": "npm run buildOnly",
"buildOnly": "npm run clean -s && mkdirp dist && npm run rollup -s && npm run babel -s",
"rollup-esm": "rollup src/index.js --output.format esm --name AsyncComputed --output.file dist/vue-async-computed.esm.esnext.js",
"rollup-umd": "rollup src/index.js --output.format umd --name AsyncComputed --output.file dist/vue-async-computed.esnext.js",
"rollup": "npm run rollup-umd -s && npm run rollup-esm -s",
"babel-umd": "babel --optional runtime dist/vue-async-computed.esnext.js --out-file dist/vue-async-computed.js",
"babel-esm": "babel --optional runtime dist/vue-async-computed.esm.esnext.js --out-file dist/vue-async-computed.esm.js",
"babel": "npm run babel-umd -s && npm run babel-esm -s",
"postbuild": "vitest run",
"postbuild": "npm run test -s",
"prepublishOnly": "npm run build -s",
"patch": "npm version patch && npm publish",
"minor": "npm version minor && npm publish",
Expand Down

0 comments on commit 8d16236

Please sign in to comment.