Update reusable workflows, fix review points
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
# This workflow helps to be sure that the code of the action we're going to deploy:
|
||||
# 1. Is well-formated
|
||||
# 2. Is linted
|
||||
# 3. Successfully builds
|
||||
# 4. Passes unit-tests
|
||||
# Additionally node packages used by the action can be audited.
|
||||
name: Basic validation
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
operating-systems:
|
||||
description: "Optional input to set list of operating systems whick the workflow uses. Defaults to ['ubuntu-latest', 'windows-latest', 'macos-latest'] if not set"
|
||||
required: false
|
||||
type: string
|
||||
default: "['ubuntu-latest', 'windows-latest', 'macos-latest']"
|
||||
build-command:
|
||||
description: "Optional input to configure build command in case the default one doesn't suit. Set to an empty string if build isn't needed. Multiline syntax is supported"
|
||||
required: false
|
||||
type: string
|
||||
default: "npm run build"
|
||||
prettier-command:
|
||||
description: "Optional input to set prettier command. Set to an empty string if prettier isn't needed"
|
||||
required: false
|
||||
type: string
|
||||
default: "npm run format-check"
|
||||
linter-command:
|
||||
description: "Optional input to set linter command. Set to an empty string if linting isn't needed"
|
||||
required: false
|
||||
type: string
|
||||
default: "npm run lint"
|
||||
enable-audit:
|
||||
description: "Optional input to enable npm package audit process"
|
||||
required: false
|
||||
type: boolean
|
||||
default: true
|
||||
node-version:
|
||||
description: "Optional input to set version of Node.js used to build a project. The input syntax corresponds to the setup-node's one"
|
||||
required: false
|
||||
type: string
|
||||
default: "16.x"
|
||||
node-caching:
|
||||
description: "Optional input to set up caching for the setup-node action. The input syntax corresponds to the setup-node's one. Set to an empty string if caching isn't needed"
|
||||
required: false
|
||||
type: string
|
||||
default: "npm"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{matrix.operating-systems}}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
operating-systems: ${{fromJson(inputs.operating-systems)}}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node.js ${{inputs.node-version}}
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{inputs.node-version}}
|
||||
cache: ${{inputs.node-caching}}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --ignore-scripts
|
||||
|
||||
- name: Run prettier
|
||||
if: ${{inputs.prettier-command}}
|
||||
run: ${{inputs.prettier-command}}
|
||||
|
||||
- name: Run linter
|
||||
if: ${{inputs.linter-command}}
|
||||
run: ${{inputs.linter-command}}
|
||||
|
||||
- name: Build
|
||||
if: ${{inputs.build-command}}
|
||||
run: ${{inputs.build-command}}
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
- name: Audit packages
|
||||
run: npm audit --audit-level=high
|
||||
if: ${{inputs.enable-audit}}
|
||||
Reference in New Issue
Block a user