forked from konveyor/java-analyzer-bundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (125 loc) · 4.89 KB
/
Makefile
File metadata and controls
141 lines (125 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Makefile for Java Analyzer Bundle
# Replicates GitHub Actions CI/CD pipeline for local verification
.PHONY: help all ci clean clean-containers clean-go phase1 phase2 unit-tests build-container run-integration-tests
# Detect container runtime (prefer Podman, fallback to Docker)
CONTAINER_RUNTIME := $(shell command -v podman 2>/dev/null || command -v docker 2>/dev/null)
ifeq ($(CONTAINER_RUNTIME),)
$(error Neither podman nor docker is installed)
endif
# Set volume flags based on container runtime
ifeq ($(findstring podman,$(CONTAINER_RUNTIME)),podman)
VOLUME_FLAGS := :Z
else
VOLUME_FLAGS :=
endif
# Variables
IMAGE_NAME := jdtls-analyzer:test
REPO_ROOT := $(shell pwd)
GO_MODULE := java-analyzer-bundle.test/integration
# Default target
help:
@echo "======================================================================"
@echo "Java Analyzer Bundle - CI/CD Verification Makefile"
@echo "======================================================================"
@echo ""
@echo "Available targets:"
@echo ""
@echo " make ci - Run complete CI/CD pipeline (Phase 1 + 2)"
@echo " make phase1 - Run Phase 1: Unit tests only"
@echo " make phase2 - Run Phase 2: Integration tests only"
@echo ""
@echo "Phase 1 targets:"
@echo " make unit-tests - Run Maven unit tests"
@echo ""
@echo "Phase 2 targets:"
@echo " make build-container - Build JDT.LS container image"
@echo " make run-integration-tests - Run integration tests in container"
@echo ""
@echo "Utility targets:"
@echo " make clean - Clean all build artifacts"
@echo " make clean-containers - Remove container images"
@echo " make clean-go - Clean Go build artifacts"
@echo ""
@echo "Container runtime: $(CONTAINER_RUNTIME)"
@echo "======================================================================"
# Run complete CI/CD pipeline
ci: phase1 phase2
@echo ""
@echo "======================================================================"
@echo "✓ Complete CI/CD Pipeline Succeeded!"
@echo "======================================================================"
# Alias for consistency
all: ci
# Phase 1: Unit Tests
phase1: unit-tests
@echo ""
@echo "======================================================================"
@echo "✓ Phase 1 Complete: Unit tests passed"
@echo "======================================================================"
# Phase 2: Integration Tests
phase2: build-container run-integration-tests
@echo ""
@echo "======================================================================"
@echo "✓ Phase 2 Complete: Integration tests passed"
@echo "======================================================================"
# Phase 1 Targets
unit-tests:
@echo "======================================================================"
@echo "Phase 1: Running Unit Tests"
@echo "======================================================================"
@echo ""
mvn clean integration-test
# Phase 2 Targets
build-container:
@echo ""
@echo "======================================================================"
@echo "Phase 2: Building JDT.LS Container Image"
@echo "======================================================================"
@echo ""
@echo "Using container runtime: $(CONTAINER_RUNTIME)"
@echo ""
$(CONTAINER_RUNTIME) build -t $(IMAGE_NAME) -f Dockerfile.test .
@echo ""
@echo "✓ Container image built: $(IMAGE_NAME)"
run-integration-tests:
@echo ""
@echo "======================================================================"
@echo "Phase 2: Running Integration Tests in Container"
@echo "======================================================================"
@echo ""
@echo "Installing Go and running tests inside container..."
$(CONTAINER_RUNTIME) run --rm \
-v $(REPO_ROOT)/java-analyzer-bundle.test:/tests$(VOLUME_FLAGS) \
-e WORKSPACE_DIR=/tests/projects \
-e JDTLS_PATH=/jdtls \
--workdir /tests/integration \
--entrypoint /bin/sh \
$(IMAGE_NAME) \
-c "microdnf install -y golang && go mod download && go test -v"
@echo ""
@echo "✓ Integration tests passed"
# Clean targets
clean: clean-go
@echo "======================================================================"
@echo "Cleaning Build Artifacts"
@echo "======================================================================"
mvn clean
@echo ""
@echo "✓ Maven artifacts cleaned"
clean-containers:
@echo "======================================================================"
@echo "Removing Container Images"
@echo "======================================================================"
-$(CONTAINER_RUNTIME) rmi $(IMAGE_NAME) 2>/dev/null || true
@echo ""
@echo "✓ Container images removed"
clean-go:
@echo "Cleaning Go build artifacts..."
cd $(GO_MODULE) && go clean -testcache
@echo "✓ Go artifacts cleaned"
# Development targets
.PHONY: test test-phase1 test-phase2 verify
test: ci
test-phase1: phase1
test-phase2: phase2
verify: ci