Skip to content
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

Add a placeholder for tests #9

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions test/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
Dockerfile.native
.gitignore
Makefile
1 change: 1 addition & 0 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
6 changes: 6 additions & 0 deletions test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "test-arch"
version = "0.1.0"
edition = "2021"

[dependencies]
16 changes: 16 additions & 0 deletions test/Dockerfile.native
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}