|
| 1 | +.PHONY: help clean $(addprefix test-,$(BACKENDS)) $(addprefix clean-,$(BACKENDS)) test-backends |
| 2 | + |
| 3 | +export UID := $(shell id -u) |
| 4 | +export GID := $(shell id -g) |
| 5 | + |
| 6 | +PROJECT_ROOT := $(shell git rev-parse --show-toplevel) |
| 7 | +SCCACHE_BIN := $(PROJECT_ROOT)/target/debug/sccache |
| 8 | + |
| 9 | +BACKENDS := redis redis-deprecated memcached memcached-deprecated s3 azblob webdav |
| 10 | +TOOLS := gcc clang cmake autotools coverage zstd |
| 11 | + |
| 12 | +# Map backends to their compose profiles |
| 13 | +PROFILE_redis := redis |
| 14 | +PROFILE_redis-deprecated := redis |
| 15 | +PROFILE_memcached := memcached |
| 16 | +PROFILE_memcached-deprecated := memcached |
| 17 | +PROFILE_s3 := s3 |
| 18 | +PROFILE_azblob := azblob |
| 19 | +PROFILE_webdav := webdav |
| 20 | +PROFILE_gcc := gcc |
| 21 | +PROFILE_clang := clang |
| 22 | +PROFILE_cmake := cmake |
| 23 | +PROFILE_autotools := autotools |
| 24 | +PROFILE_coverage := coverage |
| 25 | +PROFILE_zstd := zstd |
| 26 | + |
| 27 | +# Map backends to their services |
| 28 | +SERVICES_redis := redis |
| 29 | +SERVICES_redis-deprecated := redis |
| 30 | +SERVICES_memcached := memcached |
| 31 | +SERVICES_memcached-deprecated := memcached |
| 32 | +SERVICES_s3 := minio minio-setup |
| 33 | +SERVICES_azblob := azurite azurite-setup |
| 34 | +SERVICES_webdav := webdav |
| 35 | +SERVICES_gcc := |
| 36 | +SERVICES_clang := |
| 37 | +SERVICES_cmake := |
| 38 | +SERVICES_autotools := |
| 39 | +SERVICES_coverage := |
| 40 | +SERVICES_zstd := |
| 41 | + |
| 42 | +help: |
| 43 | + @echo "sccache Integration Tests" |
| 44 | + @echo "" |
| 45 | + @echo "Available targets:" |
| 46 | + @echo " make build Build sccache binary" |
| 47 | + @echo "" |
| 48 | + @echo "Backend Storage Tests:" |
| 49 | + @echo " make test-redis Run Redis (new endpoint) test" |
| 50 | + @echo " make test-redis-deprecated Run Redis (deprecated) test" |
| 51 | + @echo " make test-memcached Run Memcached (new endpoint) test" |
| 52 | + @echo " make test-memcached-deprecated Run Memcached (deprecated) test" |
| 53 | + @echo " make test-s3 Run S3/MinIO test" |
| 54 | + @echo " make test-azblob Run Azure Blob Storage test" |
| 55 | + @echo " make test-webdav Run WebDAV test" |
| 56 | + @echo "" |
| 57 | + @echo "Compiler Integration Tests:" |
| 58 | + @echo " make test-gcc Run GCC compiler test" |
| 59 | + @echo " make test-clang Run Clang compiler test" |
| 60 | + @echo "" |
| 61 | + @echo "Build System Tests:" |
| 62 | + @echo " make test-cmake Run CMake integration test" |
| 63 | + @echo " make test-autotools Run Autotools integration test" |
| 64 | + @echo "" |
| 65 | + @echo "Advanced Tests:" |
| 66 | + @echo " make test-coverage Run Rust coverage instrumentation test" |
| 67 | + @echo " make test-zstd Run ZSTD compression levels test" |
| 68 | + @echo "" |
| 69 | + @echo " make test-backends Run all backend tests" |
| 70 | + @echo " make clean Stop all services and clean up" |
| 71 | + @echo " make help Show this help" |
| 72 | + |
| 73 | +build: $(SCCACHE_BIN) $(PROJECT_ROOT)/target/integration-cargo-cache |
| 74 | + |
| 75 | +# Create a persistent cargo cache for integration tests, used to avoid re-downloading dependencies |
| 76 | +$(PROJECT_ROOT)/target/integration-cargo-cache: |
| 77 | + @mkdir -p $@ |
| 78 | + |
| 79 | +$(SCCACHE_BIN): $(PROJECT_ROOT)/Cargo.toml $(PROJECT_ROOT)/Cargo.lock |
| 80 | + @echo "Building sccache in Docker..." |
| 81 | + @docker run --rm \ |
| 82 | + -v $(PROJECT_ROOT):/sccache \ |
| 83 | + -v integration-cargo-cache:/usr/local/cargo/registry \ |
| 84 | + -w /sccache \ |
| 85 | + -e OPENSSL_NO_VENDOR=1 \ |
| 86 | + rust:latest \ |
| 87 | + bash -c "apt-get update -qq && apt-get install -y -qq libssl-dev pkg-config && \ |
| 88 | + cargo build --all-features && \ |
| 89 | + chown -R $(UID):$(GID) target" |
| 90 | + @echo "Binary built: $(SCCACHE_BIN)" |
| 91 | + @ls -lh $(SCCACHE_BIN) |
| 92 | + |
| 93 | +# Pattern rule for cleaning backends |
| 94 | +clean-%: |
| 95 | + @docker compose --profile $(PROFILE_$*) down -v |
| 96 | + |
| 97 | +# Pattern rule for testing backends |
| 98 | +test-%: build clean-% |
| 99 | + @echo "Testing $* backend..." |
| 100 | + @docker compose --profile $(PROFILE_$*) up --quiet-pull -d $(SERVICES_$*) |
| 101 | + @docker compose --profile $(PROFILE_$*) run --quiet-pull --rm test-$* |
| 102 | + @docker compose --profile $(PROFILE_$*) down |
| 103 | + @echo "$* test completed" |
| 104 | + |
| 105 | +test-backends: $(addprefix test-,$(BACKENDS)) |
| 106 | + @echo "All backend tests completed" |
| 107 | + |
| 108 | +test-tools: $(addprefix test-,$(TOOLS)) |
| 109 | + @echo "All backend tests completed" |
| 110 | + |
| 111 | +test: test-backends test-tools |
| 112 | + @echo "All tests completed" |
| 113 | + |
| 114 | +clean: |
| 115 | + @docker compose --profile '*' down -v |
| 116 | + @echo "Cleanup complete" |
0 commit comments