From 85e637792904bd610278952c1a956ed8c0a9b599 Mon Sep 17 00:00:00 2001 From: Ambrose Chua Date: Thu, 9 Sep 2021 23:58:19 +0800 Subject: [PATCH] ci: Add GitHub Actions --- .github/workflows/node.yml | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/node.yml diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml new file mode 100644 index 0000000..3c88fdf --- /dev/null +++ b/.github/workflows/node.yml @@ -0,0 +1,73 @@ +# 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 + - run: npm run format + - 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: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [14.x, 16.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + 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 + - run: npm run lint --if-present + # TODO: Generate and publish a HTML artifact + - run: npm start + + +# vim: set et ts=2 sw=2: