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 Makefile target to cleanup testing artifacts #1205

Merged
merged 1 commit into from
May 13, 2024
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
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ COMPRESSION_FBS_GO_FILES=$(wildcard $(COMPRESSION_FBS_DIR)/zinfo/*.go)
COMMIT=$(shell git rev-parse HEAD)
STARGZ_BINARY?=/usr/local/bin/containerd-stargz-grpc

INTEG_TEST_CONTAINERS=$(strip $(shell docker ps -aqf name="soci-integration-*"))
SOCI_BASE_IMAGE_IDS=$(shell docker image ls -qf reference="*:soci_test")

CMD=soci-snapshotter-grpc soci

CMD_BINARIES=$(addprefix $(OUTDIR)/,$(CMD))

GO_BENCHMARK_TESTS?=.

.PHONY: all build check flatc add-ltag install uninstall tidy vendor clean \
test integration release benchmarks build-benchmarks \
clean-integration test integration release benchmarks build-benchmarks \
benchmarks-perf-test benchmarks-comparison-test

all: build
Expand Down Expand Up @@ -89,12 +92,28 @@ uninstall:
@echo "$@"
@rm -f $(addprefix $(CMD_DESTDIR)/bin/,$(notdir $(CMD_BINARIES)))

clean:
clean: clean-integration
@echo "🧹 ... 🗑️"
@rm -rf $(OUTDIR)
@rm -rf $(CURDIR)/release/
@echo "All clean!"

clean-integration:
austinvazquez marked this conversation as resolved.
Show resolved Hide resolved
@echo "🧹 Cleaning leftover integration test artifacts..."

@echo "🐳 Cleaning Docker artifacts..."
ifneq ($(INTEG_TEST_CONTAINERS),)
docker stop $(INTEG_TEST_CONTAINERS)
docker rm $(INTEG_TEST_CONTAINERS)
docker network rm $(shell docker network ls -qf name="soci-integration-*")
docker image rm $(SOCI_BASE_IMAGE_IDS)
@echo "🐳 All SOCI containers, networks, and images cleaned!"
else
@echo "🐳 No leftover Docker artifacts."
endif

@echo "All testing artifacts cleaned!"

tidy:
@GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
@cd ./cmd ; GO111MODULE=$(GO111MODULE_VALUE) go mod tidy
Expand Down
2 changes: 1 addition & 1 deletion integration/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func withPlainHTTP() registryConfigOpt {

func newRegistryConfig(opts ...registryConfigOpt) registryConfig {
rc := registryConfig{
host: fmt.Sprintf("registry-%s.test", xid.New().String()),
host: fmt.Sprintf("%s-registry-%s.test", compose.TestContainerBaseName, xid.New().String()),
user: "dummyuser",
pass: "dummypass",
}
Expand Down
7 changes: 6 additions & 1 deletion util/dockershell/compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package compose
import (
"bufio"
"errors"
"fmt"
"io"
"os"
"os/exec"
Expand All @@ -45,6 +46,10 @@ import (
"github.com/rs/xid"
)

const (
TestContainerBaseName string = "soci-integration"
)

// Supported checks if this pkg can run on the current system.
func Supported() error {
return exec.Command("docker", "--version").Run()
Expand Down Expand Up @@ -133,7 +138,7 @@ func Up(dockerComposeYaml string, opts ...Option) (*Compose, error) {
for _, o := range opts {
o(&cOpts)
}
tmpContext, err := os.MkdirTemp("", "compose"+xid.New().String())
tmpContext, err := os.MkdirTemp("", fmt.Sprintf("%s-compose-%s", TestContainerBaseName, xid.New().String()))
if err != nil {
return nil, err
}
Expand Down