From f9ab874c9a68df4339ff95d23d0f2b5c1ed349f3 Mon Sep 17 00:00:00 2001 From: Mikhail Malyshev Date: Thu, 22 Aug 2024 07:54:21 +0200 Subject: [PATCH] Add a placeholder for tests Signed-off-by: Mikhail Malyshev --- test/.dockerignore | 4 ++++ test/.gitignore | 1 + test/Cargo.toml | 6 ++++++ test/Dockerfile.native | 16 ++++++++++++++++ test/Makefile | 24 ++++++++++++++++++++++++ test/src/main.rs | 3 +++ 6 files changed, 54 insertions(+) create mode 100644 test/.dockerignore create mode 100644 test/.gitignore create mode 100644 test/Cargo.toml create mode 100644 test/Dockerfile.native create mode 100644 test/Makefile create mode 100644 test/src/main.rs diff --git a/test/.dockerignore b/test/.dockerignore new file mode 100644 index 0000000..6b947b9 --- /dev/null +++ b/test/.dockerignore @@ -0,0 +1,4 @@ +target +Dockerfile.native +.gitignore +Makefile diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +/target diff --git a/test/Cargo.toml b/test/Cargo.toml new file mode 100644 index 0000000..98d28ac --- /dev/null +++ b/test/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "test-arch" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test/Dockerfile.native b/test/Dockerfile.native new file mode 100644 index 0000000..1d37d14 --- /dev/null +++ b/test/Dockerfile.native @@ -0,0 +1,16 @@ +FROM mikemzed/eve-rust:1.80.1-alpine-3.20-cross-5 AS rust + +ADD . /test +WORKDIR /test + +# tools already in place +RUN cargo build --release +RUN cargo sbom > sbom.spdx.json + +FROM lfedge/eve-alpine:1f7685f95a475c6bbe682f0b976f12180b6c8726 AS build +RUN apk add file busybox bash +# do the rest of your regular eve-alpine work + +COPY --from=rust /test/target/release/test-native-comile /out/test-native-comile + +# do not do FROM scratch here. We need 'file' and 'shell' to validate the image diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 0000000..c1ff9d1 --- /dev/null +++ b/test/Makefile @@ -0,0 +1,24 @@ +.PHONY: all +all: arm x86 +.PHONY: test +test: test-arm test-x86 + +.PHONY: arm64 +arm64: + docker buildx build --platform=linux/arm64 -t test-native-compile-arm --no-cache --load -f Dockerfile.native . + +.PHONY: x86 +x86: + docker buildx build --platform=linux/amd64 -t test-native-compile-x86 --no-cache --load -f Dockerfile.native . + +test-x86: x86 + # Run the Docker container and get the file information + $(eval arch = $(shell docker run --rm --platform=linux/amd64 test-native-compile-x86 file /out/test-native-comile | cut -d ',' -f2 | sed 's/,/ /g' | sed 's/:/ /')) + @echo "Architecture detected: '$(arch)'" + # TODO: check if the architecture is x86_64 + +test-arm64: arm64 + # Run the Docker container and get the file information + $(eval arch = $(shell docker run --rm --platform=linux/arm64 test-native-compile-arm file /out/test-native-comile | cut -d ',' -f2 | sed 's/,/ /g' | sed 's/:/ /')) + @echo "Architecture detected: '$(arch)'" + # TODO: check if the architecture is arm64 diff --git a/test/src/main.rs b/test/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/test/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}