-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (114 loc) · 4.53 KB
/
Makefile
File metadata and controls
136 lines (114 loc) · 4.53 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
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
PROJECT := e2e
VERSION ?= latest
OUT_DIR = bin
HUB ?= docker.io/apache
GO := GO111MODULE=on go
GO_PATH = $(shell $(GO) env GOPATH)
GOARCH ?= $(shell $(GO) env GOARCH)
GOOS ?= $(shell $(GO) env GOOS)
GO_BUILD = $(GO) build
GO_TEST = $(GO) test
GO_LINT = $(GO_PATH)/bin/golangci-lint
GO_BUILD_LDFLAGS = -X github.com/apache/skywalking-$(PROJECT)/commands.version=$(VERSION)
PLATFORMS := windows linux darwin
os = $(word 1, $@)
RELEASE_BIN = skywalking-$(PROJECT)-$(VERSION)-bin
RELEASE_SRC = skywalking-$(PROJECT)-$(VERSION)-src
all: clean lint test build
.PHONY: lint
lint:
$(GO_LINT) version || curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin -d "v2.1.6"
$(GO_LINT) run -v ./...
.PHONY: fix-lint
fix-lint:
$(GO_LINT) run -v --fix ./...
.PHONY: test
test: clean
$(GO_TEST) ./... -coverprofile=coverage.txt -covermode=atomic
@>&2 echo "Great, all tests passed."
windows: PROJECT_SUFFIX=.exe
.PHONY: $(PLATFORMS)
$(PLATFORMS):
mkdir -p $(OUT_DIR)
GOOS=$(os) GOARCH=$(GOARCH) $(GO_BUILD) $(GO_BUILD_FLAGS) -ldflags "$(GO_BUILD_LDFLAGS)" -o $(OUT_DIR)/$(os)/$(PROJECT)$(PROJECT_SUFFIX) cmd/e2e/main.go
.PHONY: build
build: windows linux darwin
.PHONY: clean
clean:
-rm -rf bin
-rm -rf coverage.txt
-rm -rf "$(RELEASE_BIN)"*
-rm -rf "$(RELEASE_SRC)"*
.PHONY: verify
verify: clean lint test
.PHONY: docker
docker:
docker build --no-cache . -t $(HUB)/$(PROJECT):$(VERSION)
release-src: clean
-mkdir $(RELEASE_SRC)
-cp ../NOTICE $(RELEASE_SRC)
-rsync -av . $(RELEASE_SRC) --exclude $(RELEASE_SRC) --exclude .DS_Store
-tar -zcvf $(RELEASE_SRC).tgz $(RELEASE_SRC)
-rm -rf "$(RELEASE_SRC)"
release-bin: build
-mkdir $(RELEASE_BIN)
-cp -R bin $(RELEASE_BIN)
-cp -R dist/* $(RELEASE_BIN)
-cp -R CHANGES.md $(RELEASE_BIN)
-cp -R README.adoc $(RELEASE_BIN)
-cp -R ../NOTICE $(RELEASE_BIN)
-tar -zcvf $(RELEASE_BIN).tgz $(RELEASE_BIN)
-rm -rf "$(RELEASE_BIN)"
release: verify release-src release-bin
gpg --batch --yes --armor --detach-sig $(RELEASE_SRC).tgz
shasum -a 512 $(RELEASE_SRC).tgz > $(RELEASE_SRC).tgz.sha512
gpg --batch --yes --armor --detach-sig $(RELEASE_BIN).tgz
shasum -a 512 $(RELEASE_BIN).tgz > $(RELEASE_BIN).tgz.sha512
.PHONY: install
install: $(GOOS)
-cp $(OUT_DIR)/$(GOOS)/$(PROJECT) $(DESTDIR)
.PHONY: uninstall
uninstall: $(GOOS)
-rm $(DESTDIR)/$(PROJECT)
.PHONY: e2e-test
e2e-test: $(GOOS)
- make build
- ./bin/$(GOOS)/$(PROJECT) run -c ./test/e2e/e2e.yaml
.PHONY: e2e-test-kind
# Run E2E test with KinD to verify import-images functionality
e2e-test-kind:
$(MAKE) $(GOOS)
docker pull busybox:latest
./bin/$(GOOS)/$(PROJECT) run -c ./test/e2e/kind/e2e.yaml
.PHONY: e2e-test-kind-collect
# Run E2E test with KinD to verify collect-on-failure functionality
# This test intentionally fails verification to trigger file collection.
# It succeeds if the collected files exist at the expected output directory.
e2e-test-kind-collect:
$(MAKE) $(GOOS)
docker pull busybox:latest
rm -rf /tmp/e2e-collect-test
./bin/$(GOOS)/$(PROJECT) run -c ./test/e2e/kind/collect-on-failure/e2e.yaml || true
@echo "Verifying collected files..."
@test -d /tmp/e2e-collect-test/default && echo "PASS: output directory created" || (echo "FAIL: output directory not found" && exit 1)
@ls /tmp/e2e-collect-test/default/collect-test/describe.txt > /dev/null 2>&1 && echo "PASS: describe.txt collected" || (echo "FAIL: describe.txt not found" && exit 1)
@ls /tmp/e2e-collect-test/default/collect-test/test-data/logs > /dev/null 2>&1 && echo "PASS: logs/ collected" || (echo "FAIL: logs/ not found" && exit 1)
@ls /tmp/e2e-collect-test/default/collect-test/test-data/debug.txt > /dev/null 2>&1 && echo "PASS: debug.txt collected" || (echo "FAIL: debug.txt not found" && exit 1)
@echo "All collect-on-failure checks passed."