Add lint-checks composite action (prettier/eslint/commitlint, opt-in)
This commit is contained in:
parent
43f0cdb92a
commit
1b62ee5f85
1 changed files with 7 additions and 16 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
name: lint-checks
|
name: lint-checks
|
||||||
description: >
|
description: >
|
||||||
Node formatting, linting, and conventional-commit checks: prettier
|
Style and hygiene checks: prettier (via the repo's format:check script),
|
||||||
(`format:check`) and eslint (`lint`) npm scripts, each `--if-present`,
|
eslint (via the repo's lint script), and conventional-commit linting when
|
||||||
plus commitlint if the repo has a commitlint config. Run after
|
a commitlint config exists. Each check is --if-present/config-gated, so
|
||||||
actions/checkout and npm ci (e.g. after node-checks), in a job with node
|
repos opt in by defining the script or config. Run after node-checks in
|
||||||
available.
|
the same job (needs node_modules from npm ci).
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: composite
|
||||||
steps:
|
steps:
|
||||||
|
|
@ -13,18 +13,9 @@ runs:
|
||||||
- run: npm run lint --if-present
|
- run: npm run lint --if-present
|
||||||
shell: bash
|
shell: bash
|
||||||
- shell: bash
|
- shell: bash
|
||||||
env:
|
|
||||||
GITHUB_EVENT_NAME: ${{ github.event_name }}
|
|
||||||
GITHUB_BASE_REF: ${{ github.base_ref }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
|
||||||
if ls commitlint.config.* .commitlintrc* >/dev/null 2>&1; then
|
if ls commitlint.config.* .commitlintrc* >/dev/null 2>&1; then
|
||||||
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
|
npx --no-install commitlint --last --verbose
|
||||||
git fetch origin "$GITHUB_BASE_REF" --depth=1
|
|
||||||
npx --yes commitlint --from "origin/$GITHUB_BASE_REF" --to HEAD
|
|
||||||
else
|
|
||||||
npx --yes commitlint --from HEAD~1 --to HEAD
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "no commitlint config found, skipping conventional-commit check"
|
echo "no commitlint config, skipping conventional-commit check"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue