Skip to content

ci(format): check every commit on dispatch runs; gersemi checks the full tree - #14

Merged
zackees merged 1 commit into
masterfrom
ci/format-check-full-base
Oct 9, 2026
Merged

zackees merged 1 commit into
masterfrom
ci/format-check-full-base

Conversation

@zackees

@zackees zackees commented Oct 9, 2026

Copy link
Copy Markdown
Member

Item 1 of #13: why Format / gersemi passed while libobs/cmake/rust.cmake was unformatted, and the fix.

Root cause

rust.cmake was last changed in ae123c3 (PR #10, base grind/meta-4-7c2e). pr-pull.yaml only fires pull_request for master, so PR #10's CI came from workflow_dispatch runs of Pull. In .github/actions/check-changes, any event other than pull_request/push used HEAD~1 as the base. Only the branch's last commit was checked.

In the final dispatch run (37864081724, job Format / gersemi, green), HEAD was 093b539, which touched only rust-unexports-macos.txt. The log shows GIT_BASE_REF: empty, hasChangedFiles=false, and the install and run steps skipped. PR #9 (meta → master) did run gersemi on the right diff, and it failed on rust.cmake (job 113611353780).

run-clang-format uses the same check-changes action, so it had the same gap. This PR fixes that too.

Unrelated bug in the same file: the no-changes branch wrote changedFiles=[] to a file literally named GITHUB_OUTPUT (the $ was missing).

Fix

  • check-changes: for workflow_dispatch, schedule and similar events, diff against git merge-base HEAD origin/<default branch> (from github.event.repository.default_branch). HEAD~1 is still the fallback when HEAD is on the default branch or the ref is missing. Every commit a dispatched branch adds is now checked, by clang-format too. Also fixed the $GITHUB_OUTPUT typo.
  • run-gersemi: no changed-files list. It runs build-aux/run-gersemi --check over the full tree, which takes about 1 s for 198 files locally. A wrong base can no longer hide an unformatted CMake file. clang-format keeps the changed-files list because a full-tree serial check takes about 2m40s; the base fix covers it.
  • libobs/cmake/rust.cmake: formatted. The hunk is identical to PR ci: local gate + attestation skips, quick gate for full builds, ccache for Tier 2 #12's, so the two merge cleanly. Without it, the now full-tree gersemi check would fail on master.

RED → GREEN

Repro harness (below). It runs the run: script of check-changes/action.yaml in a scratch clone set up like the dispatch run: HEAD=093b539f7, origin/master=e18bd465b (master before #9), GITHUB_EVENT_NAME=workflow_dispatch, glob '*.cmake' '*CMakeLists.txt'.

RED (origin/master action):

hasChangedFiles=false

GREEN (this branch):

hasChangedFiles=true
changedFiles=["libobs/CMakeLists.txt","libobs/cmake/rust.cmake"]

Full-tree ./build-aux/run-gersemi --fail-error --check (gersemi 0.25.0), as the action now runs it:

  • RED on origin/master (893ac48): ✖︎ libobs/cmake/rust.cmake requires formatting changes. exit 2
  • GREEN on this branch: exit 0
repro_check_changes.py
import os, subprocess, sys, yaml
action_repo, source_repo, scratch = sys.argv[1:4]
action = yaml.safe_load(open(os.path.join(action_repo, ".github/actions/check-changes/action.yaml")))
script = action["runs"]["steps"][0]["run"].replace("${{ inputs.checkGlob }}", "'*.cmake' '*CMakeLists.txt'")
clone = os.path.join(scratch, "clone")
if not os.path.isdir(clone):
    subprocess.run(["git", "clone", "-q", "--no-checkout", source_repo, clone], check=True)
subprocess.run(["git", "-C", clone, "checkout", "-q", "--detach", "093b539f7"], check=True)
subprocess.run(["git", "-C", clone, "update-ref", "refs/remotes/origin/master", "e18bd465b"], check=True)
out = os.path.join(scratch, "github_output"); open(out, "w").close()
env = dict(os.environ, GITHUB_EVENT_NAME="workflow_dispatch", GITHUB_OUTPUT=out, GIT_BASE_REF="",
           GIT_REF="HEAD", GITHUB_EVENT_FORCED="", GITHUB_REF_BEFORE="", USE_FALLBACK="true",
           DIFF_FILTER="ACM", DEFAULT_BRANCH="master", RUNNER_DEBUG="")
subprocess.run(["bash", "-e", "-o", "pipefail", "-c", script], cwd=clone, env=env, check=True)
print(open(out).read().strip())

./lint, ./unittest and local-gate.toml do not exist on master yet (they come with PR #12), so the local gate was not run. The change is CI-only, plus the one formatting hunk in rust.cmake.

Refs #13

…ull tree

check-changes compared workflow_dispatch (and schedule) runs against
HEAD~1, so only the branch's last commit was format-checked. The Pull
run dispatched for PR #10 (into grind/meta-4-7c2e) ran on a commit that
touched only rust-unexports-macos.txt, so gersemi was skipped while
libobs/cmake/rust.cmake was unformatted. Such runs now compare against
the merge-base with origin/<default branch>.

gersemi checks the whole tree in about a second, so run-gersemi no
longer depends on the changed-files list at all. Also fix the
`>> GITHUB_OUTPUT` typo (missing $) in check-changes, and format
rust.cmake (same hunk as PR #12).

Refs #13
@zackees
zackees merged commit 6396004 into master Oct 9, 2026
21 checks passed
@zackees
zackees deleted the ci/format-check-full-base branch October 9, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant