Skip to content

Commit 1f716d9

Browse files
committed
fix returning artifacts from other builds
1 parent d167c75 commit 1f716d9

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

rust/Earthfile

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,17 @@ CARGO:
1717
RUN --mount=type=cache,mode=0777,sharing=shared,target=$CARGO_HOME/registry \
1818
--mount=type=cache,mode=0777,sharing=shared,target=$CARGO_HOME/git \
1919
--mount=type=cache,mode=0777,target=target \
20-
cargo $args;
20+
cargo $args; \
21+
if [ -n "$output" ]; then \
22+
mkdir /earthly_lib_rust_temp; \
23+
cd target; \
24+
find . -type f -regextype posix-egrep -regex "./$output" -exec cp --parents \{\} /earthly_lib_rust_temp \; ; \
25+
fi
2126
IF [ "$output" != "" ]
22-
DO +COPY_FROM_TARGET_CACHE --regex=$output
27+
RUN mkdir -p target; \
28+
mv /earthly_lib_rust_temp/* target 2>/dev/null || echo "no files found within ./target matching the provided output regexp" ;
2329
END
2430

25-
# COPY_FROM_TARGET_CACHE copies the files matching the regex from the target cache to the caller filesystem (image layers).
26-
COPY_FROM_TARGET_CACHE:
27-
COMMAND
28-
ARG regex
29-
RUN --no-cache --mount=type=cache,mode=0777,target=target \
30-
mkdir earthly_lib_rust_temp; \
31-
cd target; \
32-
find . -regextype posix-egrep -regex "./$regex" -exec cp --parents \{\} ../earthly_lib_rust_temp \; ; \
33-
cd ..; \
34-
echo "Copied output: $(du -hs earthly_lib_rust_temp | awk '{print $1}')";
35-
RUN mkdir -p target; \
36-
mv earthly_lib_rust_temp/* target;
37-
3831
# REMOVE_SOURCE_FINGERPRINTS removes the Cargo fingerprint folders of the source packages.
3932
# This guarantees Cargo compiles the packages when COPY commands of the source folders have a static timestamp (see --keep-ts)
4033
REMOVE_SOURCE_FINGERPRINTS:

0 commit comments

Comments
 (0)