Skip to content

Commit

Permalink
Move SMOKE_TEST udc to the std_build.py script
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Jan 15, 2024
1 parent fc78e3f commit e41830e
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 22 deletions.
12 changes: 0 additions & 12 deletions earthly/rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,3 @@ SETUP:
rustup show && \
cargo --version && \
cargo +nightly --version

# Check if the build executable, isn't a busted mess.
SMOKE_TEST:
COMMAND
ARG --required bin

RUN ldd target/release/$bin
RUN readelf -p .comment target/release/$bin
RUN strip -v target/release/$bin

# ALL executables MUST have `--help` as an option.
RUN target/release/$bin --help
48 changes: 42 additions & 6 deletions earthly/rust/scripts/std_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ def cargo_modules_bin(results: cli.Results, package: str, bin: str):
+ f"--package '{package}' --bin '{bin}' > 'target/doc/{package}.{bin}.bin.modules.dot' ",
name=f"Generate Module Graphs for {package}/{bin}"))

# ALL executables MUST have `--help` as an option.
def help_check(results: cli.Results, bin: str):
results.add(cli.run(f"target/release/{bin} --help",
name=f"Executable {bin} MUST have `--help` as an option."))

def ldd(results: cli.Results, bin: str):
results.add(cli.run(f"ldd target/release/{bin}",
name="ldd",
verbose=True))

def readelf(results: cli.Results, bin: str):
results.add(cli.run(f"readelf -p .comment target/release/{bin}",
name="readelf",
verbose=True))

def strip(results: cli.Results, bin: str):
results.add(cli.run(f"strip -v target/release/{bin}",
name="strip",
verbose=True))

def main():
# Force color output in CI
Expand All @@ -117,11 +136,13 @@ def main():
parser.add_argument("--cov_report", default="", help="The output coverage report file path. If omitted, coverage will not be run.")
parser.add_argument("--with_bench", action='store_true', help="Flag to indicate whether to run benchmarks.")
parser.add_argument("--libs", default="", help="The list of lib crates `cargo-modules` docs to build separated by comma.")
parser.add_argument("--bins", default="", help="The list of binaries `cargo-modules` docs to build.")
parser.add_argument("--bins", default="", help="The list of binaries `cargo-modules` docs to build and made a smoke tests on them.")
args = parser.parse_args()

results = cli.Results("Rust build")
libs = filter(lambda lib: lib != "", args.libs.split(", "))
bins = list(filter(lambda bin: bin != "", args.bins.split(", ")))

results = cli.Results("Rust build")
# Build the code.
cargo_build(results, args.build_flags)
# Check the code passes all clippy lint checks.
Expand All @@ -146,16 +167,31 @@ def main():
# Generate dependency graphs
cargo_depgraph(results)

for lib in filter(lambda lib: lib != "", args.libs.split(", ")):
for lib in libs:
cargo_modules_lib(results, lib)

for bin in filter(lambda bin: bin != "", args.bins.split(", ")):
package, bin = bin.split('/')
cargo_modules_bin(results, package, bin)
for bin in bins:
package, bin_name = bin.split('/')
cargo_modules_bin(results, package, bin_name)

results.print()
if not results.ok():
exit(1)

# Check if the build executable, isn't a busted mess.
results = cli.Results("Smoke test")

for bin in bins:
_, bin_name = bin.split('/')
help_check(results, bin_name)
ldd(results, bin_name)
readelf(results, bin_name)
strip(results, bin_name)

results.print()
if not results.ok():
exit(1)


if __name__ == "__main__":
main()
2 changes: 0 additions & 2 deletions examples/rust/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ build:
SAVE ARTIFACT target/doc doc
SAVE ARTIFACT target/release/foo foo

DO ./../../earthly/rust+SMOKE_TEST --bin="foo"

# Test which runs check with all supported host tooling. Needs qemu or rosetta to run.
# Only used to validate tooling is working across host toolsets.
all-hosts-build:
Expand Down
4 changes: 2 additions & 2 deletions utilities/dbviz/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ all-hosts-check:
build:
FROM +builder

RUN /scripts/std_build.py --with_test
DO ../../earthly/rust+SMOKE_TEST --bin=dbviz
RUN /scripts/std_build.py --with_test \
--bins="dbviz/dbviz"

SAVE ARTIFACT target/doc doc
SAVE ARTIFACT target/release/dbviz dbviz
Expand Down

0 comments on commit e41830e

Please sign in to comment.