Skip to content

Enforce the license header, with any2bazel's checker and workflow - #2

Merged
anakanemison merged 2 commits into
mainfrom
copyright-headers
Nov 30, 2026
Merged

anakanemison merged 2 commits into
mainfrom
copyright-headers

Conversation

@anakanemison

Copy link
Copy Markdown
Contributor

Every source file must begin with the Apache 2.0 header, and a pull request now fails when one
does not.

The check is any2bazel's, copied from its main at
1ceba9f: infra/internal/check_copyright_headers (a Go program run with bazel run),
.bazelversion, MODULE.bazel.lock, and the copyright job of .github/workflows/main.yml.

What differs from any2bazel's copy, and why

  • Two more exemptions in the checker. NOTICE, and everything under templates/. Those are
    starting files an operator copies into records of their own. One of them is the prompt every run
    is launched with, whose bytes a run records.
  • The lock file. On a machine set up for the lab, Bazel fetches modules from a copy of the
    registry on that machine's disk, and running the check there rewrote MODULE.bazel.lock to
    point at that copy. So .bazelrc tells Bazel to ignore the lock file (--lockfile_mode=off).
    The workflow overrides that with --lockfile_mode=error, which fails unless the committed lock
    file is exactly right.
  • MODULE.bazel is new. This repository had no Bazel module. The lab's tools are not built
    with Bazel, and the checker is the one target.
  • The Go import path names this repository.

What else changes

  • CLAUDE.md's conventions say how to add a file and how to run the check.
  • .gitignore loses two patterns left from before the records moved out of this repository, and
    ignores Bazel's symlinks.

How it was tried

On a trial machine set up by SETUP.md, with Bazel 9.2.0:

  • The check passes on this branch, run as an operator would run it and as the workflow runs it
    (the repository's .bazelrc alone, the public registry, --lockfile_mode=error). Neither
    leaves a change in the checkout.
  • Four planted defects each failed it and were named: a new script with no header, the header
    removed from a tool, another owner's name in the copyright line, and a header pushed past the
    first 1000 bytes. A control, a file with no header under templates/, passed.
  • With a dependency changed in MODULE.bazel and the lock left as it was, the workflow's command
    failed.
  • Two configuration files that the lab installs gained the header, tools/env/containers.conf
    and the AppArmor profile. With both installed, podman read the first, apparmor_parser loaded
    the second, the lab's preflight ended OK, and tools/tests/run_all.sh reported 50 tests, all
    passing.

Not tried before this pull request: the workflow on GitHub's own runner. Its first run is the one
on this pull request.

🤖 Generated with Claude Code

anakanemison and others added 2 commits November 25, 2026 14:30
Two patterns removed by the operator, by hand: runs/*/target and
runs/.alloc.lock. Runs live in an operator's records root, not in this
repository. A reviewer of the first pull request asked whether they were a
vestige.
Every source file must begin with the Apache 2.0 header, and a pull request
now fails when one does not. The check is EngFlow/any2bazel's, copied from its
main at 1ceba9f: infra/internal/check_copyright_headers (a Go program run with
`bazel run`), .bazelversion, MODULE.bazel.lock, and the copyright job of
.github/workflows/main.yml.

What differs from any2bazel's copy, and why:

- Two more exemptions in the checker: NOTICE, and everything under templates/
  (starting files an operator copies into records of their own; one of them is
  the prompt every run is launched with, whose bytes a run records).
- The Go import path names this repository.
- The lock file. On a machine set up for the lab, Bazel fetches modules from a
  copy of the registry on that machine's disk, and running the check there
  rewrote MODULE.bazel.lock to point at that copy. So .bazelrc tells Bazel to
  ignore the lock file (--lockfile_mode=off). The workflow overrides that with
  --lockfile_mode=error, which fails unless the committed lock file is exactly
  right.
- MODULE.bazel is new: this repository had no Bazel module. The lab's tools
  are not built with Bazel, and this is the one target.

Six of the lab's files gained the header: lab.local.conf.example,
tools/cooldown/frozen_snapshots.example.txt, tools/env/containers.conf,
tools/runner/apparmor/a2b-private-tmp, and the two case files under
tools/judge/examples. Each is read by a parser that skips comment lines.
CLAUDE.md's conventions say how to add a file and how to run the check.

Tried on a trial machine set up by SETUP.md, with Bazel 9.2.0:

- The check passes on this commit, as an operator would run it and as the
  workflow runs it (the repository's .bazelrc alone, the public registry,
  --lockfile_mode=error). Neither leaves a change in the checkout.
- Four planted defects each failed it and were named: a new script with no
  header, the header removed from a tool, another owner's name in the
  copyright line, and a header pushed past the first 1000 bytes. A control, a
  file with no header under templates/, passed.
- With a dependency changed in MODULE.bazel and the lock left as it was, the
  workflow's command failed.
- The command MODULE.bazel gives for updating the lock left it byte for byte
  the same when nothing had changed.
- The two configuration files that gained a header were installed and used:
  podman read containers.conf, apparmor_parser loaded the profile, preflight
  ended OK, and tools/tests/run_all.sh reported 50 tests, all passing.

Not tried: the workflow on GitHub's own runner, which first runs when this is
pushed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@anakanemison
anakanemison merged commit 21d879b into main Nov 30, 2026
1 check passed
@anakanemison
anakanemison deleted the copyright-headers branch November 30, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants