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

Make test in pillar container #3804

Merged
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Unit tests
name: Go Tests
on: # yamllint disable-line rule:truthy
push:
branches:
Expand All @@ -22,7 +22,7 @@ jobs:
- name: Test
run: |
make test
- name : Test (TPM Required)
- name: Test (TPM Required)
run: |
bash tests/tpm/prep-and-test.sh
- name: Report test results as Annotations
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,9 @@ currentversion:

test: $(LINUXKIT) test-images-patches | $(DIST)
@echo Running tests on $(GOMODULE)
$(QUIET)$(DOCKER_GO) "gotestsum --jsonfile $(DOCKER_DIST)/results.json --junitfile $(DOCKER_DIST)/results.xml --raw-command -- go test -coverprofile=coverage.txt -covermode=atomic -race -json ./..." $(GOTREE) $(GOMODULE)
$(QUIET)$(DOCKER_GO) "cd /eve/pkg/pillar; ../../tools/fuzz_test.sh" $(GOTREE) $(GOMODULE)
make -C pkg/pillar test
cp pkg/pillar/results.json $(DIST)/
cp pkg/pillar/results.xml $(DIST)/
$(QUIET): $@: Succeeded

# wrap command into DOCKER_GO and propagate it to the pillar's Makefile
Expand Down
4 changes: 4 additions & 0 deletions pkg/pillar/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ FROM build-native AS target-arm64-build-arm64
# hadolint ignore=DL3006
FROM target-${TARGETARCH}-build-${BUILDARCH} AS build
ARG DEV=n
ARG TEST_TOOLS=n
ARG TARGETARCH

# some parts of pillar are build conditionally based on the hypervisor
Expand Down Expand Up @@ -110,6 +111,9 @@ RUN --mount=type=cache,target=/root/.cache/go-build if [ ${DEV} = "y" ]; then \
GOFLAGS= CGO_ENABLED=0 go build -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv && \
cp dlv /final/opt/ ; \
fi
RUN --mount=type=cache,target=/root/.cache/go-build if [ "${TEST_TOOLS}" = "y" ]; then \
GOBIN=/final/opt/ GOFLAGS="" go install gotest.tools/gotestsum@v1.7.0; \
fi

FROM lfedge/eve-fscrypt:e8507303431c8c11ec1a2b3b7fb02e1a0dcdf296 as fscrypt
FROM lfedge/eve-dnsmasq:3af908d86a95a627c729e09b1b125bf8de7fadcb as dnsmasq
Expand Down
21 changes: 19 additions & 2 deletions pkg/pillar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,25 @@ enter-docker-dev: build-docker-dev
build-docker-git:
git archive HEAD | docker build $(DOCKER_ARGS) -t $(DOCKER_TAG) -

test:
go test -mod=vendor ./...
build-docker-test:
docker build $(DOCKER_ARGS) --build-arg TEST_TOOLS=y -t $(DOCKER_TAG) . --target build

test: build-docker-test
rm -f results.json
rm -f results.xml
touch results.json
touch results.xml
docker run --platform linux/$(ZARCH) -w /pillar \
--mount type=bind,source=./results.json,target=/pillar/results.json \
--mount type=bind,source=./results.xml,target=/pillar/results.xml \
--entrypoint /final/opt/gotestsum $(DOCKER_TAG) \
--jsonfile /pillar/results.json \
--junitfile /pillar/results.xml \
--raw-command -- go test -coverprofile=coverage.txt -covermode=atomic -race -json \
./...
docker run --platform linux/$(ZARCH) -w /pillar \
--entrypoint /bin/sh $(DOCKER_TAG) \
/pillar/build-scripts/fuzz_test.sh

clean:
@rm -rf $(DISTDIR)
Expand Down
File renamed without changes.
Loading