f20fff9613
Add test workflow
85 lines
2 KiB
YAML
85 lines
2 KiB
YAML
name: test
|
|
|
|
on:
|
|
pull_request:
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
container: ubuntu
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3.5.0
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3.7.0
|
|
with:
|
|
node-version: '20.x'
|
|
|
|
- name: Cache node modules
|
|
id: cache-npm
|
|
uses: actions/cache@v3.3.1
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
|
|
name: List the state of node modules
|
|
continue-on-error: true
|
|
run: npm list
|
|
|
|
- name: Install NPM dependencies
|
|
run: npm ci
|
|
|
|
- name: NPM Build
|
|
run: npm run build
|
|
|
|
- name: Run tests
|
|
run: npm test
|
|
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3.5.0
|
|
|
|
- name: Use Node.js
|
|
uses: actions/setup-node@v3.7.0
|
|
with:
|
|
node-version: '20.x'
|
|
|
|
- name: Cache node modules
|
|
id: cache-npm
|
|
uses: actions/cache@v3.3.1
|
|
env:
|
|
cache-name: cache-node-modules
|
|
with:
|
|
path: ~/.npm
|
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-build-${{ env.cache-name }}-
|
|
${{ runner.os }}-build-
|
|
${{ runner.os }}-
|
|
|
|
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
|
|
name: List the state of node modules
|
|
continue-on-error: true
|
|
run: npm list
|
|
|
|
- name: Install NPM dependencies
|
|
run: npm ci
|
|
|
|
- name: Lint
|
|
run: npm run lint -- --no-fix
|