Skip to content

Commit e4e4881

Browse files
authored
ci: docker e2e test default to local build (#2383)
# Pull Request: Use Local Docker Build for E2E Tests by Default ## Summary This PR modifies the Docker E2E testing framework to use locally built Docker images by default instead of attempting to pull from `ghcr.io/rollkit/rollkit`. This resolves issues where developers encounter "pull access denied" errors when running Docker E2E tests locally. ## Benefits 1. __Developer Experience__: Eliminates "pull access denied" errors for local development 2. __Self-Contained Testing__: Tests use the current codebase instead of potentially outdated registry images 3. __Automatic Cleanup__: Prevents accumulation of test images in the local Docker environment 4. __CI/CD Compatibility__: Maintains ability to override image repository and tag for production environments ## Usage ### Local Development (Default) ```bash make test-docker-e2e ``` This will automatically: - Build the Docker image as `rollkit:local-dev` - Run the Docker E2E tests - Clean up the image after tests complete ### CI/CD (Override) ```bash ROLLKIT_IMAGE_REPO=ghcr.io/rollkit/rollkit ROLLKIT_IMAGE_TAG=v1.0.0 make test-docker-e2e ``` ## Testing - Verified that `make test-docker-e2e` builds the image locally and runs tests successfully - Confirmed that environment variable overrides still work for CI/CD scenarios - Tested cleanup functionality to ensure images are properly removed after tests ## Breaking Changes None. This change only affects the default behavior for local development. All existing CI/CD configurations using environment variables will continue to work unchanged. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added a Makefile target to build a local Docker image for development and testing. - Introduced a composite test target to run both unit and Docker-based end-to-end tests with a single command. - **Improvements** - Enhanced Docker-based end-to-end test workflow to use a locally built image by default and clean up after tests. - Updated environment variable handling in test workflows for better local development support. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 4ee6b80 commit e4e4881

4 files changed

Lines changed: 47 additions & 4 deletions

File tree

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
- name: Run Docker E2E Tests
8282
run: make test-docker-e2e
8383
env:
84+
ROLLKIT_IMAGE_REPO: ghcr.io/${{ github.repository }}
8485
ROLLKIT_IMAGE_TAG: ${{ inputs.image-tag }}
8586

8687
build_all-apps:

scripts/build.mk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,17 @@ build-da:
6666
@echo " Check the binary with: $(CURDIR)/build/local-da"
6767
.PHONY: build-da
6868

69+
## docker-build: Build Docker image for local testing
70+
docker-build:
71+
@echo "--> Building Docker image for local testing"
72+
@docker build -t rollkit:local-dev .
73+
@echo "--> Docker image built: rollkit:local-dev"
74+
@echo "--> Checking if image exists locally..."
75+
@docker images rollkit:local-dev
76+
.PHONY: docker-build
77+
6978
## clean: clean and build
70-
clean:
79+
clean:
7180
@echo "--> Cleaning Testapp CLI"
7281
@rm -rf $(CURDIR)/build/
7382
@echo "--> Testapp CLI Cleaned!"

scripts/test.mk

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ test:
1010
@go run -tags='run integration' scripts/test.go
1111
.PHONY: test
1212

13+
## test-all: Running all tests including Docker E2E
14+
test-all: test test-docker-e2e
15+
@echo "--> All tests completed"
16+
.PHONY: test-all
17+
1318
## test-e2e: Running e2e tests
1419
test-integration:
1520
@echo "--> Running e2e tests"
@@ -40,6 +45,33 @@ test-evm:
4045
@cd execution/evm && go test -mod=readonly -failfast -timeout=15m ./... -tags=evm
4146

4247
## test-docker-e2e: Running Docker E2E tests
43-
test-docker-e2e:
48+
test-docker-e2e: docker-build-if-local
4449
@echo "--> Running Docker E2E tests"
50+
@echo "--> Verifying Docker image exists locally..."
51+
@if [ -z "$(ROLLKIT_IMAGE_REPO)" ] || [ "$(ROLLKIT_IMAGE_REPO)" = "rollkit" ]; then \
52+
echo "--> Verifying Docker image exists locally..."; \
53+
docker image inspect rollkit:local-dev >/dev/null 2>&1 || (echo "ERROR: rollkit:local-dev image not found. Run 'make docker-build' first." && exit 1); \
54+
fi
4555
@cd test/docker-e2e && go test -mod=readonly -failfast -tags='docker_e2e' -timeout=30m ./...
56+
@$(MAKE) docker-cleanup-if-local
57+
58+
## docker-build-if-local: Build Docker image if using local repository
59+
docker-build-if-local:
60+
@if [ -z "$(ROLLKIT_IMAGE_REPO)" ] || [ "$(ROLLKIT_IMAGE_REPO)" = "rollkit" ]; then \
61+
echo "--> Local repository detected, building Docker image..."; \
62+
$(MAKE) docker-build; \
63+
else \
64+
echo "--> Using remote repository: $(ROLLKIT_IMAGE_REPO)"; \
65+
fi
66+
.PHONY: docker-build-if-local
67+
68+
## docker-cleanup-if-local: Clean up local Docker image if using local repository
69+
docker-cleanup-if-local:
70+
@if [ -z "$(ROLLKIT_IMAGE_REPO)" ] || [ "$(ROLLKIT_IMAGE_REPO)" = "rollkit" ]; then \
71+
echo "--> Untagging local Docker image (preserving layers for faster rebuilds)..."; \
72+
docker rmi rollkit:local-dev --no-prune 2>/dev/null || echo "Image rollkit:local-dev not found or already removed"; \
73+
else \
74+
echo "--> Using remote repository, no cleanup needed"; \
75+
fi
76+
.PHONY: docker-cleanup-if-local
77+

test/docker-e2e/docker_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,16 @@ func (s *DockerTestSuite) StartRollkitNode(ctx context.Context, bridgeNode tasto
232232

233233
// getRollkitImage returns the Docker image configuration for Rollkit
234234
// Uses ROLLKIT_IMAGE_REPO and ROLLKIT_IMAGE_TAG environment variables if set
235+
// Defaults to locally built image using a unique tag to avoid registry conflicts
235236
func getRollkitImage() tastoradocker.DockerImage {
236237
repo := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_REPO"))
237238
if repo == "" {
238-
repo = "ghcr.io/rollkit/rollkit"
239+
repo = "rollkit"
239240
}
240241

241242
tag := strings.TrimSpace(os.Getenv("ROLLKIT_IMAGE_TAG"))
242243
if tag == "" {
243-
tag = "latest"
244+
tag = "local-dev"
244245
}
245246

246247
return tastoradocker.DockerImage{

0 commit comments

Comments
 (0)