Skip to content

Commit 6b2d17b

Browse files
committed
Merge bitcoin/bitcoin#33888: ci: Re-enable LINT_CI_SANITY_CHECK_COMMIT_SIG
55555db doc: Add missing --platform=linux to docker build command (MarcoFalke) fa0ce4c ci: Re-enable LINT_CI_SANITY_CHECK_COMMIT_SIG (MarcoFalke) faa0973 ci: [refactor] Rename CIRRUS_PR env var to LINT_CI_IS_PR (MarcoFalke) fa1daca ci: Move lint exec snippet to stand-alone py file (MarcoFalke) Pull request description: The sanity check to check the last few merge commit signatures on the main branch was accidentally and silently disabled while moving from the `cirrus-ci.com` platform to the GHA platform. So fix that by re-enabling it. Also, contains a few other lint cleanup commits. ACKs for top commit: janb84: re ACK 55555db willcl-ark: ACK 55555db Tree-SHA512: e623dc88035ee4d1c6a8efa5fad33c35cface87f54e78c7ebfe5d468d28d8d8097150344d276f90f8ed52a89e61609ce95380476ea0151b50f73ad5919233933
2 parents ac71df4 + 55555db commit 6b2d17b

File tree

4 files changed

+61
-42
lines changed

4 files changed

+61
-42
lines changed

.github/ci-lint-exec.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env python3
2+
# Copyright (c) The Bitcoin Core developers
3+
# Distributed under the MIT software license, see the accompanying
4+
# file COPYING or https://opensource.org/license/mit.
5+
6+
import os
7+
import shlex
8+
import subprocess
9+
import sys
10+
import time
11+
12+
13+
def run(cmd, **kwargs):
14+
print("+ " + shlex.join(cmd), flush=True)
15+
kwargs.setdefault("check", True)
16+
try:
17+
return subprocess.run(cmd, **kwargs)
18+
except Exception as e:
19+
sys.exit(e)
20+
21+
22+
def main():
23+
CONTAINER_NAME = os.environ["CONTAINER_NAME"]
24+
25+
build_cmd = [
26+
"docker", "buildx", "build",
27+
f"--tag={CONTAINER_NAME}",
28+
*shlex.split(os.getenv("DOCKER_BUILD_CACHE_ARG", "")),
29+
"--file=./ci/lint_imagefile",
30+
"."
31+
]
32+
33+
if run(build_cmd, check=False).returncode != 0:
34+
print("Retry building image tag after failure")
35+
time.sleep(3)
36+
run(build_cmd)
37+
38+
extra_env = []
39+
if os.environ["GITHUB_EVENT_NAME"] == "pull_request":
40+
extra_env = ["--env", "LINT_CI_IS_PR=1"]
41+
if os.environ["GITHUB_EVENT_NAME"] != "pull_request" and os.environ["GITHUB_REPOSITORY"] == "bitcoin/bitcoin":
42+
extra_env = ["--env", "LINT_CI_SANITY_CHECK_COMMIT_SIG=1"]
43+
44+
run([
45+
"docker",
46+
"run",
47+
"--rm",
48+
*extra_env,
49+
f"--volume={os.getcwd()}:/bitcoin",
50+
CONTAINER_NAME,
51+
])
52+
53+
54+
if __name__ == "__main__":
55+
main()

.github/workflows/ci.yml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -621,40 +621,4 @@ jobs:
621621
cache-provider: ${{ needs.runners.outputs.provider }}
622622

623623
- name: CI script
624-
shell: python
625-
run: |
626-
import os, shlex, subprocess, sys, time
627-
628-
def run(cmd, **kwargs):
629-
print("+ " + shlex.join(cmd), flush=True)
630-
kwargs.setdefault("check", True)
631-
try:
632-
return subprocess.run(cmd, **kwargs)
633-
except Exception as e:
634-
sys.exit(e)
635-
636-
CONTAINER_NAME = os.environ["CONTAINER_NAME"]
637-
638-
build_cmd = [
639-
"docker", "buildx", "build",
640-
f"--tag={CONTAINER_NAME}",
641-
*shlex.split(os.getenv("DOCKER_BUILD_CACHE_ARG", "")),
642-
"--file=./ci/lint_imagefile",
643-
"."
644-
]
645-
646-
if run(build_cmd, check=False).returncode != 0:
647-
print("Retry building image tag after failure")
648-
time.sleep(3)
649-
run(build_cmd)
650-
651-
CIRRUS_PR_FLAG = []
652-
if '${{ github.event_name }}' == "pull_request":
653-
CIRRUS_PR_FLAG = ["-e", "CIRRUS_PR=1"]
654-
655-
run([
656-
"docker", "run", "--rm",
657-
*CIRRUS_PR_FLAG,
658-
f"--volume={os.getcwd()}:/bitcoin",
659-
CONTAINER_NAME,
660-
])
624+
run: python .github/ci-lint-exec.py

ci/lint/06_script.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66

77
export LC_ALL=C
88

9-
set -ex
9+
set -o errexit -o pipefail -o xtrace
1010

11-
if [ -n "$CIRRUS_PR" ]; then
11+
if [ -n "${LINT_CI_IS_PR}" ]; then
1212
export COMMIT_RANGE="HEAD~..HEAD"
1313
if [ "$(git rev-list -1 HEAD)" != "$(git rev-list -1 --merges HEAD)" ]; then
14-
echo "Error: The top commit must be a merge commit, usually the remote 'pull/${PR_NUMBER}/merge' branch."
14+
echo "Error: The top commit must be a merge commit, usually the remote 'pull/<PR_NUMBER>/merge' branch."
1515
false
1616
fi
1717
fi
1818

1919
RUST_BACKTRACE=1 cargo run --manifest-path "./test/lint/test_runner/Cargo.toml"
2020

21-
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
21+
if [ "${LINT_CI_SANITY_CHECK_COMMIT_SIG}" = "1" ] ; then
2222
# Sanity check only the last few commits to get notified of missing sigs,
2323
# missing keys, or expired keys. Usually there is only one new merge commit
2424
# per push on the master branch and a few commits on release branches, so

test/lint/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To run linters locally with the same versions as the CI environment, use the inc
77
Dockerfile:
88

99
```sh
10-
DOCKER_BUILDKIT=1 docker build -t bitcoin-linter --file "./ci/lint_imagefile" ./ && docker run --rm -v $(pwd):/bitcoin -it bitcoin-linter
10+
DOCKER_BUILDKIT=1 docker build --platform=linux --tag=bitcoin-linter --file="./ci/lint_imagefile" ./ && docker run --rm -v $(pwd):/bitcoin -it bitcoin-linter
1111
```
1212

1313
Building the container can be done every time, because it is fast when the

0 commit comments

Comments
 (0)