Skip to content

Commit 1d02a1d

Browse files
committed
perf(ci): avoid loading unused sanitizer image
1 parent e93856c commit 1d02a1d

4 files changed

Lines changed: 17 additions & 5 deletions

File tree

.github/workflows/build-dockerhub.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ jobs:
110110
--file Dockerfile \
111111
--platform linux/amd64 \
112112
--target builder \
113-
--load \
114-
--tag "subconverter-request-sanitizer:${GITHUB_SHA}" \
113+
--output type=cacheonly \
115114
--cache-from type=gha,scope=request-sanitizers \
116115
--cache-to type=gha,scope=request-sanitizers,mode=max \
117116
--progress plain \

tests/fixtures/ci/workflow-contract-oracle.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"schema": 1,
33
"source_sha": "47d2399444ac6abad78185c479a09d2bc4511536",
4-
"contract_sha256": "6714d876c036e877835e93dba337f686425c9a537edf7254b8e6adcbffad2fec",
5-
"workflow_diff_from_source": "none",
4+
"contract_sha256": "35f179bba0e522e3bb17bc9aa382e4ef95591b554f180d96b19d9ece52385121",
5+
"workflow_diff_from_source": "request-sanitizer-cache-only-output",
66
"run_normalization": "universal-newlines-only",
77
"step_fields": [
88
"continue-on-error",

tests/fixtures/ci/workflow-contract.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@
540540
},
541541
{
542542
"name": "Build and run request sanitizer targets",
543-
"run": "|\nset -euo pipefail\nexport THREADS=\"$(nproc)\"\nexport SHA=\"$GITHUB_SHA\"\nexport VERSION=\"sanitizer-${GITHUB_SHA::7}\"\nexport BUILD_DATE=\"$(git show -s --format=%cI HEAD)\"\nexport BUILD_TESTS=true\nmapfile -t build_args < <(bash scripts/ci/docker-build-args.sh)\nargs=()\nfor arg in \"${build_args[@]}\"; do\n [ -n \"$arg\" ] && args+=(--build-arg \"$arg\")\ndone\nargs+=(--build-arg ENABLE_SANITIZERS=true)\necho \"Sanitizer CMake option: -DENABLE_SANITIZERS=true\"\necho \"Sanitizer build targets: production runtime and all BUILD_TESTS targets\"\necho \"Sanitizer run targets: settings_view, settings_view_invariant_failure, compatibility_security_baseline\"\ndocker buildx build \\\n --file Dockerfile \\\n --platform linux/amd64 \\\n --target builder \\\n --load \\\n --tag \"subconverter-request-sanitizer:${GITHUB_SHA}\" \\\n --cache-from type=gha,scope=request-sanitizers \\\n --cache-to type=gha,scope=request-sanitizers,mode=max \\\n --progress plain \\\n \"${args[@]}\" \\\n .\n",
543+
"run": "|\nset -euo pipefail\nexport THREADS=\"$(nproc)\"\nexport SHA=\"$GITHUB_SHA\"\nexport VERSION=\"sanitizer-${GITHUB_SHA::7}\"\nexport BUILD_DATE=\"$(git show -s --format=%cI HEAD)\"\nexport BUILD_TESTS=true\nmapfile -t build_args < <(bash scripts/ci/docker-build-args.sh)\nargs=()\nfor arg in \"${build_args[@]}\"; do\n [ -n \"$arg\" ] && args+=(--build-arg \"$arg\")\ndone\nargs+=(--build-arg ENABLE_SANITIZERS=true)\necho \"Sanitizer CMake option: -DENABLE_SANITIZERS=true\"\necho \"Sanitizer build targets: production runtime and all BUILD_TESTS targets\"\necho \"Sanitizer run targets: settings_view, settings_view_invariant_failure, compatibility_security_baseline\"\ndocker buildx build \\\n --file Dockerfile \\\n --platform linux/amd64 \\\n --target builder \\\n --output type=cacheonly \\\n --cache-from type=gha,scope=request-sanitizers \\\n --cache-to type=gha,scope=request-sanitizers,mode=max \\\n --progress plain \\\n \"${args[@]}\" \\\n .\n",
544544
"shell": "bash"
545545
}
546546
]

tests/test_sanitizer_workflow_contract.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ def test_job_builds_the_instrumented_runtime_and_request_tests(self):
2525
self.assertIn("compatibility_security_baseline", self.sanitizer_job)
2626
self.assertNotIn("tests/statistics_v2_test.cpp", self.sanitizer_job)
2727

28+
def test_job_exports_only_the_reusable_cache(self):
29+
self.assertIn("--output type=cacheonly", self.sanitizer_job)
30+
self.assertIn(
31+
"--cache-from type=gha,scope=request-sanitizers",
32+
self.sanitizer_job,
33+
)
34+
self.assertIn(
35+
"--cache-to type=gha,scope=request-sanitizers,mode=max",
36+
self.sanitizer_job,
37+
)
38+
self.assertNotIn("--load", self.sanitizer_job)
39+
self.assertNotIn("subconverter-request-sanitizer:", self.sanitizer_job)
40+
2841
def test_sanitizer_flags_and_fail_closed_runtime_are_explicit(self):
2942
for flag in (
3043
"-fsanitize=address,undefined",

0 commit comments

Comments
 (0)