-
Notifications
You must be signed in to change notification settings - Fork 1
Use ASAN when running unit tests in CI #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,10 +1,8 @@ | ||||||||||||||||||||||||||
| FROM registry.fedoraproject.org/fedora:43 as builder | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ARG RUST_VERSION=stable | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN dnf install -y \ | ||||||||||||||||||||||||||
| rust \ | ||||||||||||||||||||||||||
| cargo \ | ||||||||||||||||||||||||||
| clippy \ | ||||||||||||||||||||||||||
| rustfmt \ | ||||||||||||||||||||||||||
| # for stub \ | ||||||||||||||||||||||||||
| nasm \ | ||||||||||||||||||||||||||
| # for script jit \ | ||||||||||||||||||||||||||
|
|
@@ -15,7 +13,19 @@ RUN dnf install -y \ | |||||||||||||||||||||||||
| # for bpf \ | ||||||||||||||||||||||||||
| clang \ | ||||||||||||||||||||||||||
| kernel-devel \ | ||||||||||||||||||||||||||
| libbpf-devel | ||||||||||||||||||||||||||
| libbpf-devel && \ | ||||||||||||||||||||||||||
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | \ | ||||||||||||||||||||||||||
| sh -s -- -y --default-toolchain $RUST_VERSION --profile minimal | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| # $HOME is not evaluated here, any better way of getting the toolchain | ||||||||||||||||||||||||||
| # directory? | ||||||||||||||||||||||||||
| ENV PATH="${PATH}:/root/.cargo/bin" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN rustup component add rustfmt clippy | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN if [ "${RUST_VERSION}" == "nightly" ]; then \ | ||||||||||||||||||||||||||
| rustup component add rust-src --toolchain nightly; \ | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ADD ./ /berserker/ | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
@@ -32,7 +42,12 @@ RUN cargo build -r | |||||||||||||||||||||||||
| # Test will require stub binary to be available | ||||||||||||||||||||||||||
| ENV PATH="${PATH}:/berserker:/berserker/target/release" | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| RUN cargo test | ||||||||||||||||||||||||||
| RUN if [ "${RUST_VERSION}" == "nightly" ]; then \ | ||||||||||||||||||||||||||
| TARGET=$(rustc --version --verbose | grep host | cut -d" " -f2) && \ | ||||||||||||||||||||||||||
| RUSTFLAGS="-Z sanitizer=address" cargo +nightly test -Z build-std --target "$TARGET"; \ | ||||||||||||||||||||||||||
| else \ | ||||||||||||||||||||||||||
| cargo test; \ | ||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||
|
Comment on lines
+45
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win Nightly ASAN run never enables the crate's This branch runs 🔧 Proposed fix RUN if [ "${RUST_VERSION}" == "nightly" ]; then \
TARGET=$(rustc --version --verbose | grep host | cut -d" " -f2) && \
- RUSTFLAGS="-Z sanitizer=address" cargo +nightly test -Z build-std --target "$TARGET"; \
+ RUSTFLAGS="-Z sanitizer=address" cargo +nightly test --features nightly -Z build-std --target "$TARGET"; \
else \
cargo test; \
fi📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| FROM registry.fedoraproject.org/fedora:43 | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ endif | |
| .PHONY: all | ||
| all: | ||
| docker build -t berserker -f Containerfile . | ||
| docker build -t berserker -f Containerfile --build-arg=RUST_VERSION=nightly . | ||
|
Comment on lines
9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== Files ==\n'
git ls-files | rg '(^|/)(Makefile|Containerfile|Dockerfile|README.md)$'
printf '\n== Makefile (mapped) ==\n'
ast-grep outline Makefile --view expanded || true
printf '\n== Makefile with line numbers ==\n'
cat -n Makefile | sed -n '1,120p'
printf '\n== Containerfile with line numbers ==\n'
cat -n Containerfile | sed -n '1,220p'
printf '\n== Search for berserker tag usage ==\n'
rg -n 'berserker|RUST_VERSION=nightly|build-and-push|docker build' -S .Repository: stackrox/berserker Length of output: 8595 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== README build / image references ==\n'
rg -n 'make |docker build|docker run|latest|BERSERKER_TAG|tag:' README.md Makefile Containerfile Containerfile.test scripts -S
printf '\n== README excerpt around usage ==\n'
cat -n README.md | sed -n '1,140p'Repository: stackrox/berserker Length of output: 5722 Makefile:9-10 — Use a separate tag for the nightly build. The second 🤖 Prompt for AI Agents |
||
| docker build -t berserker-test -f Containerfile.test . | ||
| docker run --privileged berserker-test | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Minor Dockerfile lint fixes flagged by pipeline.
asshould matchFROMcasing (AS) on line 1, andENTRYPOINTshould use JSON/exec form on line 62.🧹 Proposed fix
Also applies to: 62-62
🧰 Tools
🪛 GitHub Actions: Main berserker CI / 0_build-and-push.txt
[warning] 1-1: Dockerfile lint warning: FromAsCasing - 'as' and 'FROM' keywords' casing do not match.
🤖 Prompt for AI Agents
Source: Pipeline failures