Skip to content

Commit

Permalink
test: Ensure branches are also testable
Browse files Browse the repository at this point in the history
test-commit-message runs on PR, but also on push in other branches
which aren't PRs. We need to test those too.

This is fixed by ensuring the same kind of behaviour than travis CI:
When a patch is put on a branch, it's using the branchname for
testing [1].

[1]:
https://docs-staging.travis-ci.com/user/environment-variables/#default-environment-variables
  • Loading branch information
evrardjp committed Mar 3, 2021
1 parent 4511c54 commit 636248a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion test/test-commit-message.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@ then
done
elif [[ -n "$GITHUB_SHA" ]]
then
commits=$(git log --no-merges --format=%H origin/${GITHUB_BASE_REF}..${GITHUB_SHA})
# GITHUB_SHA is the HEAD of the branch
# GITHUB_REF: The branch or tag ref that triggered the workflow. For example, refs/heads/feature-branch-1. If neither a branch or tag is available for the event type, the variable will not exist.
# GITHUB_BASE_REF: Only set for pull request events. The name of the base branch.
if [[ -n "${GITHUB_BASE_REF}" ]]; then
ref=${GITHUB_BASE_REF}
head=${GITHUB_SHA}
else
ref=$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')
head=""
fi
commits=$(git log --no-merges --format=%H origin/${ref}..${head})
[[ -n "$commits" ]]

for commit in $commits
Expand Down

0 comments on commit 636248a

Please sign in to comment.