2021-09-09 23:58:19 +08:00
|
|
|
# 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
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [main]
|
|
|
|
pull_request:
|
|
|
|
branches: [main]
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
format:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node-version: [14.x]
|
|
|
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
ref: ${{ github.head_ref }}
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: '~/.npm'
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
- run: npm ci
|
2021-09-10 00:40:30 +08:00
|
|
|
- run: npm run format --if-present
|
|
|
|
- run: npm run lint --if-present -- --fix
|
2021-09-09 23:58:19 +08:00
|
|
|
- name: Commit changes if any
|
|
|
|
run: |
|
|
|
|
git config user.name "GitHub Actions"
|
|
|
|
git config user.email "action@github.com"
|
|
|
|
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
|
|
|
|
git commit -m "ci: Automatic code formatting" -a
|
|
|
|
git push
|
|
|
|
fi
|
|
|
|
|
|
|
|
test:
|
2021-09-10 00:45:44 +08:00
|
|
|
runs-on: ${{ matrix.os }}
|
2021-09-09 23:58:19 +08:00
|
|
|
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-09-10 00:45:44 +08:00
|
|
|
os: [ubuntu-latest, windows-latest, macOS-latest]
|
2021-09-09 23:58:19 +08:00
|
|
|
node-version: [14.x, 16.x]
|
|
|
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
2021-09-10 00:54:26 +08:00
|
|
|
exclude:
|
2021-09-10 00:55:55 +08:00
|
|
|
- {os: windows-latest, node-version: 16.x}
|
|
|
|
- {os: macOS-latest, node-version: 16.x}
|
2021-09-09 23:58:19 +08:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
|
|
|
- uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: '~/.npm'
|
|
|
|
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-node-
|
|
|
|
- run: npm ci
|
|
|
|
- run: npm run type-check --if-present
|
2021-09-10 00:40:30 +08:00
|
|
|
- run: npm run format --if-present
|
2021-09-09 23:58:19 +08:00
|
|
|
- run: npm run lint --if-present
|
|
|
|
# TODO: Generate and publish a HTML artifact
|
|
|
|
- run: npm start
|
|
|
|
# vim: set et ts=2 sw=2:
|