aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/commit-validation.yml
diff options
context:
space:
mode:
authorJohn MacFarlane <[email protected]>2023-12-19 15:31:50 -0800
committerJohn MacFarlane <[email protected]>2023-12-19 15:31:50 -0800
commit9d15289864e2c1f7d4c43eefdddd7a04cefe2198 (patch)
tree2c24616146dc62488a50b5c80e1e8fc2ab8ad5f7 /.github/workflows/commit-validation.yml
parent2e9e23e9082cdeeb2c4b785d71af44c9ce96a922 (diff)
Attempt to fix commit-validation CI.
Diffstat (limited to '.github/workflows/commit-validation.yml')
-rw-r--r--.github/workflows/commit-validation.yml47
1 files changed, 21 insertions, 26 deletions
diff --git a/.github/workflows/commit-validation.yml b/.github/workflows/commit-validation.yml
index 2d355d658..be88a3692 100644
--- a/.github/workflows/commit-validation.yml
+++ b/.github/workflows/commit-validation.yml
@@ -7,35 +7,30 @@ permissions:
jobs:
check-commit-msg-length:
runs-on: ubuntu-latest
+ id: check-commit-msg-length
steps:
- uses: actions/checkout@v3
- name: Check commit message length
+ with:
+ result-encoding: json
+ script: |
+ var longlines = [];
+ const commits = ${{ toJSON(github.event.commits) }}
+ for (const commit of commits) {
+ if (/^.{79}/.test(commit.message)) {
+ longlines.push(commit.sha)
+ }
+ }
+ return longlines
+ - name: Get result
run: |
- # Get last commit messages
- if [ "${{github.event_name}}" = "push" ]; then
- if [ "${{github.event.before}}" = "0000000000000000000000000000000000000000" ]; then
- # We are on a new branch
- current="$(echo '${{github.ref}}' | sed 's!^refs/heads!origin!')"
- readarray -t other < <(git show-ref | awk -F' ' '{ sub(/^refs\/remotes\//,"",$NF); }($NF != "'"$current"'"){print "^" $NF;}')
- LOG_RANGE=( "$current" "${other[@]}" )
- unset current other
- else
- # We are on existing branch
- LOG_RANGE=( "${{github.event.before}}.." )
- fi
- elif [ "${{github.event_name}}" = "pull_request" ]; then
- LOG_RANGE=( "origin/${{github.base_ref}}.." )
- fi
- if [[ -v LOG_RANGE ]]; then
- if git log --no-merges --pretty=format:"%s" "${LOG_RANGE[@]}" -- | grep -qE "^[^#].{78}"; then
- echo -e "Last commit log contains a line with more than 78 characters:\n"
- git log --no-merges --pretty=format:"%h: %s" "${LOG_RANGE[@]}" -- | grep -E "^[^:]+: [^#].{78}"
- echo
- exit 1
- else
- echo "Commit log looks good."
- fi
- unset LOG_RANGE
+ result="${{steps.check-commit-msg-length.outputs.result}}"
+ if [[ $result = "" ]]; then
+ echo "Ok"
+ exit 0
else
- echo "Not checking commits on ${{github.event_name}}"
+ echo "Commit messages for these commits contain lines > 78 characters:"
+ echo $result
+ exit 1
fi
+