ci: Refactor commitlint installation and execution in PR validation workflow for improved reliability
This commit is contained in:
1 file changed
+15
-4
@@ -45,8 +45,19 @@ jobs:
|
||||
with:
|
||||
bun-version: ${{ env.BUN_VERSION }}
|
||||
|
||||
# Install outside the repo so bun does not migrate its lockfile or install its dependencies.
|
||||
- name: Install commitlint
|
||||
run: bun add --no-save @commitlint/cli @commitlint/config-conventional
|
||||
run: |
|
||||
set -euo pipefail
|
||||
dir="${RUNNER_TEMP}/commitlint"
|
||||
mkdir -p "$dir"
|
||||
bun add --cwd "$dir" @commitlint/cli @commitlint/config-conventional
|
||||
if [[ -e node_modules && ! -L node_modules ]]; then
|
||||
ln -sfn "$dir/node_modules/@commitlint" node_modules/@commitlint
|
||||
else
|
||||
ln -sfn "$dir/node_modules" node_modules
|
||||
fi
|
||||
echo "COMMITLINT_BIN=${dir}/node_modules/.bin/commitlint" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Validate PR Title & Description (<= 500 chars)
|
||||
env:
|
||||
@@ -55,9 +66,9 @@ jobs:
|
||||
COMMITLINT_CONFIG: ${{ steps.commitlint-config.outputs.config }}
|
||||
run: |
|
||||
if [ -z "$PR_BODY" ]; then
|
||||
printf "%s\n" "$PR_TITLE" | bunx commitlint --config "$COMMITLINT_CONFIG"
|
||||
printf "%s\n" "$PR_TITLE" | "$COMMITLINT_BIN" --config "$COMMITLINT_CONFIG"
|
||||
else
|
||||
printf "%s\n\n%s\n" "$PR_TITLE" "$PR_BODY" | bunx commitlint --config "$COMMITLINT_CONFIG"
|
||||
printf "%s\n\n%s\n" "$PR_TITLE" "$PR_BODY" | "$COMMITLINT_BIN" --config "$COMMITLINT_CONFIG"
|
||||
fi
|
||||
|
||||
- name: Validate All Commits in PR
|
||||
@@ -66,4 +77,4 @@ jobs:
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
COMMITLINT_CONFIG: ${{ steps.commitlint-config.outputs.config }}
|
||||
run: |
|
||||
bunx commitlint --from "$BASE_SHA" --to "$HEAD_SHA" --verbose --config "$COMMITLINT_CONFIG"
|
||||
"$COMMITLINT_BIN" --from "$BASE_SHA" --to "$HEAD_SHA" --verbose --config "$COMMITLINT_CONFIG"
|
||||
Reference in new issue
Block a user