Skip to content

Commit

Permalink
add TRY/FINALLY usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Leshiy committed Jan 12, 2024
1 parent c1c45ba commit d30b47d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
15 changes: 7 additions & 8 deletions earthly/rust/scripts/std_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ def cargo_bench(results: cli.Results, flags: str):
+ "--all-targets ",
name="Benchmarks all run to completion check"))

def cargo_doc(results: cli.Results, flags: str):
results.add(cli.run("cargo +nightly docs "
+ f"{flags} ",
def cargo_doc(results: cli.Results):
results.add(cli.run("cargo +nightly docs ",
name="Documentation build"))

def cargo_depgraph(results: cli.Results):
Expand Down Expand Up @@ -115,8 +114,8 @@ def main():
parser.add_argument("--test_flags", default="", help="")
parser.add_argument("--bench_flags", default="", help="")
parser.add_argument("--cov_report", default="", help="The output coverage report file path.")
parser.add_argument("--with_test", action='store_true', help="Running self contained Unit tests flag")
parser.add_argument("--with_bench", action='store_true', help="Running benchmarks flag")
parser.add_argument("--with_test", action='store_true', help="Running tests flag.")
parser.add_argument("--with_bench", action='store_true', help="Running benchmarks flag.")
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.")
args = parser.parse_args()
Expand All @@ -127,10 +126,10 @@ def main():
cargo_build(results, args.build_flags)
# Check the code passes all clippy lint checks.
cargo_clippy(results)
# Check if all documentation tests pass.
cargo_doctest(results, args.doctest_flags)
# Check if all Self contained tests pass (Test that need no external resources).
if args.with_test:
# Check if all documentation tests pass.
cargo_doctest(results, args.doctest_flags)
if args.cov_report == "":
# Without coverage report
cargo_nextest(results, args.test_flags)
Expand All @@ -143,7 +142,7 @@ def main():
cargo_bench(results, args.bench_flags)

# Generate all the documentation.
cargo_doc(results, "")
cargo_doc(results)
# Generate dependency graphs
cargo_depgraph(results)

Expand Down
22 changes: 13 additions & 9 deletions examples/rust/Earthfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION --global-cache 0.7
VERSION --try --global-cache 0.7

# cspell: words USERARCH toolsets rustfmt nextest

Expand Down Expand Up @@ -35,17 +35,21 @@ all-hosts-check:
build:
FROM +builder

RUN /scripts/std_build.py --build_flags="" \
--with_test \
--cov_report="coverage-report.info" \
--libs="bar" \
--bins="foo/foo"
DO ./../../earthly/rust+SMOKE_TEST --bin="foo"
TRY
RUN /scripts/std_build.py --build_flags="" \
--with_test \
--cov_report="coverage-report.info" \
--libs="bar" \
--bins="foo/foo"
FINALLY
SAVE ARTIFACT target/nextest/ci/junit.xml example.junit-report.xml AS LOCAL
SAVE ARTIFACT coverage-report.info example.coverage-report.info AS LOCAL
END

SAVE ARTIFACT target/doc doc
SAVE ARTIFACT target/release/foo foo
SAVE ARTIFACT target/nextest/ci/junit.xml junit-report.xml
SAVE ARTIFACT coverage-report.info coverage-report.info

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.
Expand Down

0 comments on commit d30b47d

Please sign in to comment.