142 lines
4.0 KiB
YAML
142 lines
4.0 KiB
YAML
name: Build
|
|
|
|
on: [push]
|
|
|
|
jobs:
|
|
#
|
|
# dependencies job
|
|
#
|
|
dependencies:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js 16.x
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16.x'
|
|
always-auth: true
|
|
registry-url: https://registry.npmjs.org
|
|
- id: cache_npm
|
|
name: Cache Node.js modules
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.npm
|
|
./node_modules.tar.zstd
|
|
key: ${{ runner.OS }}-node16.x-${{ hashFiles('**/package-lock.json') }}
|
|
restore-keys: |
|
|
${{ runner.OS }}-node16.x-
|
|
- name: Install dependencies with NPM
|
|
if: steps.cache_npm.outputs.cache-hit != 'true'
|
|
run: npm ci
|
|
- name: Archive node_modules
|
|
if: steps.cache_npm.outputs.cache-hit != 'true'
|
|
run: tar --use-compress-program "zstd -T0 --long=31 -1" -cf node_modules.tar.zstd -P node_modules
|
|
- name: Persisting node_modules artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: node_modules.tar.zstd
|
|
path: node_modules.tar.zstd
|
|
retention-days: 2
|
|
|
|
#
|
|
# lint job
|
|
#
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
needs: [dependencies]
|
|
|
|
steps:
|
|
# Setup
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
token: ${{ secrets.BUILD_USER_TOKEN || github.token }} # allows commit of any fixes to trigger a new workflow run
|
|
- name: Use Node.js 16.x
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16.x'
|
|
always-auth: true
|
|
registry-url: https://registry.npmjs.org
|
|
- name: Restore node_modules artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: node_modules.tar.zstd
|
|
- name: Unarchive node_modules
|
|
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
|
|
# Lint
|
|
- name: Run linters
|
|
uses: wearerequired/lint-action@v2
|
|
with:
|
|
prettier: true
|
|
eslint: true
|
|
eslint_args: "--ext '.ts,.js' --ignore-path '.gitignore' --ignore-pattern '.github/*'"
|
|
continue_on_error: false
|
|
auto_fix: ${{ secrets.BUILD_USER_TOKEN && 'true' || 'false' }}
|
|
git_name: equabot
|
|
git_email: git@equalogic.com
|
|
|
|
#
|
|
# build job
|
|
#
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: [dependencies]
|
|
|
|
steps:
|
|
# Setup
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js 16.x
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16.x'
|
|
always-auth: true
|
|
registry-url: https://registry.npmjs.org
|
|
- name: Restore node_modules artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: node_modules.tar.zstd
|
|
- name: Unarchive node_modules
|
|
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
|
|
# Build
|
|
- name: Build application
|
|
run: npm run build
|
|
env:
|
|
CI: true
|
|
- name: Check build worked correctly
|
|
run: |
|
|
if [ ! -f ./dist/index.js ]; then
|
|
echo "Something went wrong: no ./dist/index.js file was built!"
|
|
exit 1
|
|
else
|
|
echo "Build appears to be successful: ./dist/index.js was created"
|
|
fi
|
|
|
|
#
|
|
# test job
|
|
#
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
needs: [build, lint]
|
|
|
|
steps:
|
|
# Setup
|
|
- uses: actions/checkout@v3
|
|
- name: Use Node.js 16.x
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '16.x'
|
|
always-auth: true
|
|
registry-url: https://registry.npmjs.org
|
|
- name: Restore node_modules artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: node_modules.tar.zstd
|
|
- name: Unarchive node_modules
|
|
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
|
|
# Tests
|
|
- name: Run project tests
|
|
run: node_modules/.bin/dotenv -e .env.ci -- npm run test:ci
|
|
env:
|
|
CI: true
|