foundation/actions/lint/action.yml

48 lines
1.6 KiB
YAML
Raw Normal View History

# lint — eslint + yamllint gate (999_testing "linter testing"). Composite action
# (see actions/node-build for why composite, not reusable workflow). Either linter
# finding an error makes the step (hence the job) exit non-zero.
#
# steps:
# - uses: actions/checkout@v4
# - uses: https://forge.olsitec.net/olsitec/foundation/actions/lint@master
# with: { eslint-paths: ".", yamllint-paths: "." }
name: lint
description: Run eslint and yamllint; any error fails the job.
inputs:
eslint:
description: "run eslint (true/false)"
default: "true"
yamllint:
description: "run yamllint (true/false)"
default: "true"
eslint-paths:
default: "."
yamllint-paths:
default: "."
package-manager:
description: "bun | npm | none — to install project-local eslint config/plugins"
default: bun
runs:
using: composite
steps:
- name: eslint
if: ${{ inputs.eslint == 'true' }}
shell: bash
run: |
case "${{ inputs.package-manager }}" in
bun) bun install --frozen-lockfile || bun install || true ;;
npm) npm ci || npm install || true ;;
none) echo "skip install" ;;
esac
if [ -x node_modules/.bin/eslint ]; then
echo "+ project eslint"; node_modules/.bin/eslint ${{ inputs.eslint-paths }}
else
echo "+ image eslint"; eslint ${{ inputs.eslint-paths }}
fi
- name: yamllint
if: ${{ inputs.yamllint == 'true' }}
shell: bash
run: |
echo "+ yamllint ${{ inputs.yamllint-paths }}"
yamllint ${{ inputs.yamllint-paths }}