From 076a7d35e58cfe613688cfea8f853333bf4d3eb4 Mon Sep 17 00:00:00 2001 From: Birol Bilgin Date: Thu, 2 Oct 2025 19:02:59 +0200 Subject: [PATCH] Fix workflow commit range handling for push events - Add conditional logic to handle pull_request vs push events - Use commit range for pull requests and single commit for pushes Signed-off-by: Birol Bilgin --- .github/workflows/lint-go.yaml | 6 +++++- .github/workflows/test-go.yaml | 18 +++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint-go.yaml b/.github/workflows/lint-go.yaml index 3a1abb3..4ff186d 100644 --- a/.github/workflows/lint-go.yaml +++ b/.github/workflows/lint-go.yaml @@ -47,7 +47,11 @@ jobs: - name: Verify commit signed-off run: | set -eu -o pipefail - COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + if [ "${{ github.event_name }}" = "pull_request" ]; then + COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + else + COMMITS="${{ github.sha }}" + fi for commit in $COMMITS; do commit_msg=$(git log --format=%B -n 1 $commit) if ! echo "$commit_msg" | grep -qE "^Signed-off-by: .+ <.+@.+>$"; then diff --git a/.github/workflows/test-go.yaml b/.github/workflows/test-go.yaml index 7789330..0181068 100644 --- a/.github/workflows/test-go.yaml +++ b/.github/workflows/test-go.yaml @@ -34,7 +34,11 @@ jobs: - name: Build for every commit run: | set -eu -o pipefail - COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + if [ "${{ github.event_name }}" = "pull_request" ]; then + COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + else + COMMITS="${{ github.sha }}" + fi for commit in $COMMITS ; do git checkout $commit || exit 1 go build ./... @@ -66,7 +70,11 @@ jobs: - name: Run unit test for every commit run: | set -eu -o pipefail - COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + if [ "${{ github.event_name }}" = "pull_request" ]; then + COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + else + COMMITS="${{ github.sha }}" + fi for commit in $COMMITS ; do git checkout $commit || exit 1 make test @@ -98,7 +106,11 @@ jobs: - name: Run CLI tests for every commit run: | set -eu -o pipefail - COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + if [ "${{ github.event_name }}" = "pull_request" ]; then + COMMITS=$(git rev-list ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}) + else + COMMITS="${{ github.sha }}" + fi for commit in $COMMITS ; do git checkout $commit || exit 1 make cli-test clean