diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index bffd5f4f4..2e9e6ba8c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -100,14 +100,21 @@ jobs: # git log "$GITHUB_BASE_REF".. # bin/commitlint "$GITHUB_BASE_REF".. + # keep synced in all workflows which do this - name: Check commit messages + # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF + # For a push it will be: $BEFORE.. + # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". + # In this and any case where the range is invalid, we'll just check the last N commits. + # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push env: BEFORE: ${{ github.event.before }} - # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF - # for a push it will be: $BEFORE.. - # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" + NUM: 20 run: | - bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + git rev-list --quiet $RANGE \ + && bin/commitlint $RANGE \ + || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) # things to be cached/restored: diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index bb491ee96..a78c6f3fd 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -57,14 +57,21 @@ jobs: with: fetch-depth: 0 + # keep synced in all workflows which do this - name: Check commit messages + # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF + # For a push it will be: $BEFORE.. + # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". + # In this and any case where the range is invalid, we'll just check the last N commits. + # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push env: BEFORE: ${{ github.event.before }} - # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF - # for a push it will be: $BEFORE.. - # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" + NUM: 20 run: | - bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + git rev-list --quiet $RANGE \ + && bin/commitlint $RANGE \ + || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) # things to be cached/restored: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 40c42029d..792ecb31c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -64,14 +64,21 @@ jobs: # git log "$GITHUB_BASE_REF".. # bin/commitlint "$GITHUB_BASE_REF".. + # keep synced in all workflows which do this - name: Check commit messages + # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF + # For a push it will be: $BEFORE.. + # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". + # In this and any case where the range is invalid, we'll just check the last N commits. + # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push env: BEFORE: ${{ github.event.before }} - # for a PR this will be: master..origin/$GITHUB_HEAD_REF - # for a push it will be: $BEFORE.. - # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" + NUM: 20 run: | - bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + git rev-list --quiet $RANGE \ + && bin/commitlint $RANGE \ + || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) # things to be cached/restored: diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index ff4ecf405..c7d387b33 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -47,14 +47,21 @@ jobs: with: fetch-depth: 0 + # keep synced in all workflows which do this - name: Check commit messages + # For a PR, the range will be: master..origin/$GITHUB_HEAD_REF + # For a push it will be: $BEFORE.. + # For a force push, BEFORE is the previous HEAD, and on github (though not locally) this is an "invalid revision range". + # In this and any case where the range is invalid, we'll just check the last N commits. + # related: https://stackoverflow.com/questions/64708371/how-to-run-github-workflow-on-every-commit-of-a-push env: BEFORE: ${{ github.event.before }} - # for a PR this will be: origin/master..origin/$GITHUB_HEAD_REF - # for a push it will be: $BEFORE.. - # for a force push, BEFORE is the previous HEAD, and on github (not locally) this is an "invalid revision range" + NUM: 20 run: | - bin/commitlint ${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + RANGE=${BEFORE:-origin/master}..${GITHUB_HEAD_REF:+origin/$GITHUB_HEAD_REF} + git rev-list --quiet $RANGE \ + && bin/commitlint $RANGE \ + || ( echo "could not identify commits, checking last $NUM instead:"; bin/commitlint -$NUM ) # things to be cached/restored: