Skip to content

format job diffs against master's moving tip, so a branch that falls behind fails on someone else's C changes #800

Description

@xroche

The format (clang-format-19, changed lines) job in ci.yml resolves its base as origin/${{ github.base_ref }} and runs git clang-format ... "$base". That is master's tip at job time, not the branch's merge base, so once master moves ahead of the PR branch the comparison also picks up the reverse of whatever landed in between. If any of those commits touched C, the job reports the PR as not clang-format-clean and prints a diff of code the PR never touched.

Hit twice in a row on #796, whose diff contains no C at all. The first failure quoted src/htscache.c (from #776, landed mid-run); after merging master the job failed again quoting src/htscore.c (from #783, landed during that run). Locally, git-clang-format-19 --binary clang-format-19 --diff origin/master on the same branch reports no modified files to format whenever the branch is level with master.

The busier master is, the likelier the false failure, and the only workaround today is to keep merging master until a run happens to fit in the gap.

Fix is to compare against the merge base:

base="$(git merge-base "origin/${{ github.base_ref }}" HEAD)"

actions/checkout already fetches with fetch-depth: 0, so the merge base is available. Same trap applies to any other job that diffs against origin/master rather than the merge base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions