From 017b0119e6fcb1efe3d86557ebedbb4b22feb673 Mon Sep 17 00:00:00 2001 From: Eldred Habert Date: Sun, 12 Apr 2026 22:06:28 +0200 Subject: [PATCH] Overhaul `checkdiff` CI (#1930) --- .github/workflows/checkdiff.yml | 22 +++++++++++++--------- contrib/checkdiff.bash | 8 ++++---- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/checkdiff.yml b/.github/workflows/checkdiff.yml index 0420cce9..2f0a32c7 100644 --- a/.github/workflows/checkdiff.yml +++ b/.github/workflows/checkdiff.yml @@ -3,15 +3,19 @@ on: pull_request jobs: checkdiff: - runs-on: ubuntu-latest + runs-on: ubuntu-slim steps: - - name: Set up repo - run: | - git clone -b "${{ github.event.pull_request.head.ref }}" "${{ github.event.pull_request.head.repo.clone_url }}" rgbds - cd rgbds - git remote add upstream "${{ github.event.pull_request.base.repo.clone_url }}" - git fetch upstream + - name: Clone repo + uses: actions/checkout@v6 + with: + ref: ${{ github.event.pull_request.head.sha }} - name: Check diff - working-directory: rgbds + shell: bash # Bash is the default, but specifying it explicitly enables `-o pipefail`. run: | - make checkdiff "BASE_REF=${{ github.event.pull_request.base.sha }}" Q= | tee log + MERGE_BASE=$(gh api "/repos/{owner}/{repo}/compare/$BASE_SHA...$HEAD_SHA" --jq '.merge_base_commit.sha') + git fetch origin "$MERGE_BASE" + contrib/checkdiff.bash "$MERGE_BASE" | sed -E 's/^/::warning::/' + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GH_TOKEN: ${{ github.token }} diff --git a/contrib/checkdiff.bash b/contrib/checkdiff.bash index 50097914..46d8b592 100755 --- a/contrib/checkdiff.bash +++ b/contrib/checkdiff.bash @@ -3,17 +3,17 @@ # SPDX-License-Identifier: MIT declare -A FILES -while read -r -d '' file; do - FILES["$file"]="true" +while IFS= read -r -d '' file; do + FILES["$file"]=true done < <(git diff --name-only -z "$1" HEAD) edited () { - ${FILES["$1"]:-"false"} + ${FILES["$1"]:-false} } dependency () { if edited "$1" && ! edited "$2"; then - echo "'$1' was modified, but not '$2'! $3" | xargs + echo "'$1' was modified, but not '$2'! $3" fi }