Repository navigation
Commit 3707971
authored
feat: add commit-check-ci to check a whole merge or pull request (#714)
* feat: add a container image for GitLab CI and Bitbucket Pipelines
The image holds the CLI, git, and commit-check-ci, which checks a whole
merge or pull request: the branch, the title and description, and every
commit the request adds. A GitLab job or a Bitbucket pipe starts it
instead of copying a script from the documentation.
A release publishes it to ghcr.io/commit-check/commit-check from the
wheel that went to PyPI. CI builds and starts it on every pull request,
so a broken Dockerfile is not found on release day.
* refactor: give each request check a method of its own
run_for held four checks and their error paths in one body. Each is now
a short method, which is also easier to read next to its heading.
The image installs the wheel with --only-binary, so a source
distribution could never run a setup script there, and the entrypoint's
case names its default branch.
* refactor: ship commit-check-ci in the package instead of an image
A container image means a push on every release, a base image to keep
current, and a registry package to look after. None of that is needed
to check a merge or pull request: the command is now part of the PyPI
package, so a GitLab or Bitbucket job installs commit-check and runs
commit-check-ci.
The Dockerfile, its entry point, the image jobs and the Dependabot
entry are gone. Checks are chosen by options only; the variables a
pipe needed (MESSAGE, BRANCH, ...) are gone too, since a project
variable with such a name is common in CI.
* fix: fail when a shallow clone ends inside the request
git lists a range that runs into the end of a shallow clone without an
error, so a request with more commits than the clone depth passed with
its older commits unchecked. The job now fails and names the setting
that gives it the full history.
On Bitbucket, a destination ref that is behind the destination commit
is moved to it, so the rebase check cannot pass against an old target.
* fix: keep modules in the checkout from replacing installed ones
The checks ran as "python -m commit_check.main" in the request's
checkout, and -m puts the working directory first on the module search
path. A commit_check directory or a file named like a standard library
module in the repository was imported instead of the real one. The
command now runs with -P, which leaves the working directory out.
On Bitbucket a missing destination commit now fails the branch check
even when the clone has a ref for the destination branch.
* fix: check the last commit's own author outside a request
Outside a merge or pull request the commit checks ran without --rev, so
the author checks read the identity the runner would commit with
(GIT_AUTHOR_*, user.*) rather than the author of the commit under test.
A check that is given no text now gets an empty standard input, so text a
runner leaves there is not taken for the branch name.1 parent 44ed6c8 commit 3707971
4 files changed
Lines changed: 1399 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
0 commit comments