-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMakefile
More file actions
230 lines (205 loc) · 11.2 KB
/
Makefile
File metadata and controls
230 lines (205 loc) · 11.2 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
include ./mk-files/begin.mk
include ./mk-files/semver.mk
include ./mk-files/release.mk
include ./mk-files/semaphore.mk
# Install node_modules from package-lock.json
.PHONY: install-dependencies
install-dependencies:
npm ci --prefer-offline --include=dev
npx playwright install
# Install additional test dependencies to run VS Code testing in headless mode
# ref: https://code.visualstudio.com/api/working-with-extensions/continuous-integration#github-actions
# (just linux for now, but maybe eventually darwin)
.PHONY: install-test-dependencies
install-test-dependencies:
@echo "Installing test dependencies for $(shell uname -s)"
@if [ $$(uname -s) = "Linux" ]; then \
sudo apt-get update; \
sudo apt install -y libgbm1 libgtk-3-0 xvfb; \
fi
.PHONY: setup-test-env
setup-test-env:
@echo "Pulling automated-test-user credentials from Vault into .env file for testing"
@if [ -z "$(IDE_SIDECAR_CONNECTIONS_CCLOUD_BASE_PATH)" ] || [ "$(IDE_SIDECAR_CONNECTIONS_CCLOUD_BASE_PATH)" = "confluent.cloud" ]; then \
echo "Setting up prod env vars for testing"; \
echo "E2E_USERNAME=$(shell vault kv get -field=E2E_USERNAME stag/kv/semaphore/vscodeextension/testing)" > .env; \
echo "E2E_PASSWORD=$(shell vault kv get -field=E2E_PASSWORD stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_SR_API_KEY=$(shell vault kv get -field=E2E_SR_API_KEY stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_SR_API_SECRET=$(shell vault kv get -field=E2E_SR_API_SECRET stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_SR_URL=$(shell vault kv get -field=E2E_SR_URL stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_KAFKA_API_KEY=$(shell vault kv get -field=E2E_KAFKA_API_KEY stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_KAFKA_API_SECRET=$(shell vault kv get -field=E2E_KAFKA_API_SECRET stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_KAFKA_BOOTSTRAP_SERVERS=$(shell vault kv get -field=E2E_KAFKA_BOOTSTRAP_SERVERS stag/kv/semaphore/vscodeextension/testing)" >> .env; \
echo "E2E_KAFKA_CLUSTER_NAME=$(shell vault kv get -field=E2E_KAFKA_CLUSTER_NAME stag/kv/semaphore/vscodeextension/testing)" >> .env; \
elif [ "$(IDE_SIDECAR_CONNECTIONS_CCLOUD_BASE_PATH)" = "stag.cpdev.cloud" ]; then \
echo "Setting up stag env vars for testing"; \
echo "E2E_USERNAME_STAG=$(shell vault kv get -field=E2E_USERNAME_STAG stag/kv/semaphore/vscodeextension/testing)" > .env; \
echo "E2E_PASSWORD_STAG=$(shell vault kv get -field=E2E_PASSWORD_STAG stag/kv/semaphore/vscodeextension/testing)" >> .env; \
fi; \
echo "IDE_SIDECAR_CONNECTIONS_CCLOUD_BASE_PATH=$(IDE_SIDECAR_CONNECTIONS_CCLOUD_BASE_PATH)" >> .env; \
.PHONY: remove-test-env
remove-test-env:
@echo "Removing .env file"
@rm -f .env
# Run only unit (Mocha) tests (split for CI parallelization)
.PHONY: test-mocha
test-mocha: setup-test-env install-test-dependencies install-dependencies
npx gulp build
@if [ $$(uname -s) = "Linux" ]; then \
xvfb-run -a npx gulp test; \
elif [ $$(uname -s) = "Darwin" ]; then \
if pgrep -x "Dock" > /dev/null; then \
echo "GUI session is active."; \
npx gulp test; \
else \
echo "No active GUI session. Aborting tests."; \
exit 1; \
fi \
else \
npx gulp test; \
fi
# Run only webview (Playwright) tests (split for CI parallelization)
.PHONY: test-playwright-webviews
test-playwright-webviews: setup-test-env install-test-dependencies install-dependencies
npx gulp build
npx gulp functional
# Look up the Kafka and Schema Registry Docker image repo:tag values from package.json via the
# getKafkaImageRepoTag and getSchemaRegistryImageRepoTag gulp tasks, then handle all of the caching
# and loading for Semaphore. IMPORTANT: we need to use the platform and arch here for caching so
# we don't see errors from Docker when creating containers like:
# "The requested image's platform (X) does not match the detected host platform (Y)"
.PHONY: load-cached-docker-images
load-cached-docker-images: install-dependencies
@KAFKA_IMAGE=$$(npx gulp getKafkaImageRepoTag --silent 2>/dev/null | tail -1); \
SCHEMA_REGISTRY_IMAGE=$$(npx gulp getSchemaRegistryImageRepoTag --silent 2>/dev/null | tail -1); \
SEMAPHORE_KAFKA_KEY="vscode-docker-$$PLATFORM-$$ARCH-kafka-$$KAFKA_IMAGE"; \
SEMAPHORE_SCHEMA_REGISTRY_KEY="vscode-docker-$$PLATFORM-$$ARCH-schema-registry-$$SCHEMA_REGISTRY_IMAGE"; \
echo "Loading cached Docker images: $$KAFKA_IMAGE and $$SCHEMA_REGISTRY_IMAGE"; \
cache restore $$SEMAPHORE_KAFKA_KEY; \
[ -f kafka.tgz ] && docker load -i kafka.tgz && rm -rf kafka.tgz || true; \
cache restore $$SEMAPHORE_SCHEMA_REGISTRY_KEY; \
[ -f schema-registry.tgz ] && docker load -i schema-registry.tgz && rm -rf schema-registry.tgz || true
# No need for install-dependencies here since this runs as an epilogue step after we've already
# installed dependencies in the upstream steps
.PHONY: cache-docker-images
cache-docker-images:
@KAFKA_IMAGE=$$(npx gulp getKafkaImageRepoTag --silent 2>/dev/null | tail -1); \
SCHEMA_REGISTRY_IMAGE=$$(npx gulp getSchemaRegistryImageRepoTag --silent 2>/dev/null | tail -1); \
SEMAPHORE_KAFKA_KEY="vscode-docker-$$PLATFORM-$$ARCH-kafka-$$KAFKA_IMAGE"; \
SEMAPHORE_SCHEMA_REGISTRY_KEY="vscode-docker-$$PLATFORM-$$ARCH-schema-registry-$$SCHEMA_REGISTRY_IMAGE"; \
echo "Caching Docker images: $$KAFKA_IMAGE and $$SCHEMA_REGISTRY_IMAGE"; \
cache has_key $$SEMAPHORE_KAFKA_KEY || ( \
docker pull $$KAFKA_IMAGE && \
docker save $$KAFKA_IMAGE | gzip > kafka.tgz && \
cache store $$SEMAPHORE_KAFKA_KEY kafka.tgz && \
rm -rf kafka.tgz); \
cache has_key $$SEMAPHORE_SCHEMA_REGISTRY_KEY || ( \
docker pull $$SCHEMA_REGISTRY_IMAGE && \
docker save $$SCHEMA_REGISTRY_IMAGE | gzip > schema-registry.tgz && \
cache store $$SEMAPHORE_SCHEMA_REGISTRY_KEY schema-registry.tgz && \
rm -rf schema-registry.tgz)
# Run E2E (Playwright) tests with optional test name
# Usage: make test-playwright-e2e (runs all tests)
# Usage: make test-playwright-e2e TEST_SUITE=@smoke
# Usage: make test-playwright-e2e TEST_SUITE=@regression
.PHONY: test-playwright-e2e
test-playwright-e2e: setup-test-env install-test-dependencies install-dependencies
@if [ -n "$(TEST_SUITE)" ] && [ "$(TEST_SUITE)" != "" ] && [ "$(TEST_SUITE)" != "TEST_SUITE" ]; then \
TEST_SUITE_ARG="-t $(TEST_SUITE)"; \
else \
TEST_SUITE_ARG=""; \
fi; \
if [ $$(uname -s) = "Linux" ]; then \
xvfb-run -a npx gulp e2e $$TEST_SUITE_ARG; \
else \
npx gulp e2e $$TEST_SUITE_ARG; \
fi
# Validates bump based on current version (in package.json)
# and the version to be bumped to (in .versions/next.txt)
.PHONY: validate-bump
validate-bump:
@node ./.semaphore/scripts/validateBump.script.js
.PHONY: bump-microversion
bump-microversion:
export VERSION_OVERRIDE=$(shell cat ./.versions/next.txt) ;\
export VERSION_POST=$(MICROVERSION_POST) ;\
export BUMP=none ;\
export SKIP_TAG_RELEASE=true ;\
$(MAKE) release-ci
.PHONY: release-current-version
release-current-version:
export VERSION_OVERRIDE=$(CURRENT_SEM_VERSION) ;\
export BUMP=none ;\
export CI_SKIP= ;\
$(MAKE) release-ci
version_no_v = $(shell echo $(1) | sed 's,^v,,' )
.PHONY: upload-vsix-files-to-gh-releases
upload-vsix-files-to-gh-releases:
ifeq ($(LATEST_VERSION_NO_V), $(CURRENT_VERSION))
for target in darwin-x64 darwin-arm64 linux-x64 linux-arm64 win32-x64; do \
vsix_file=$$(find packaged-vsix-files -name "*$$target*.vsix"); \
gh release upload $(LATEST_VERSION) $$vsix_file --clobber; \
done;
else
@echo "Skipping upload of VSIX files to GitHub release since the version checked out is not the latest version. Latest version is $(LATEST_VERSION_NO_V) and the version checked out is $(CURRENT_VERSION)"
exit 1;
endif
IDE_SIDECAR_VERSION = $(shell cat .versions/ide-sidecar.txt)
IDE_SIDECAR_VERSION_NO_V := $(call version_no_v,$(IDE_SIDECAR_VERSION))
# Get the OS and architecture combination for the sidecar executable
SIDECAR_OS_ARCH ?= $(shell echo "$$(uname -s | tr '[:upper:]' '[:lower:]' | sed 's/darwin/macos/')-$$(uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')" )
# Check if we're targeting the Windows sidecar executable from a non-Windows agent
# (currently only done in `.semaphore/prerelease-multi-arch-packaging.yml` since the pipeline at
# `.semaphore/multi-arch-packaging.yml` uses `scripts/windows/download-sidecar-executable.ps1`)
IS_WINDOWS = $(shell echo "$(SIDECAR_OS_ARCH)" | grep -q 'windows' && echo true || echo false)
ifeq ($(IS_WINDOWS),true)
EXECUTABLE_DOWNLOAD_PATH := bin/ide-sidecar-$(IDE_SIDECAR_VERSION_NO_V)-runner.exe
export EXECUTABLE_PATH := ide-sidecar-$(IDE_SIDECAR_VERSION_NO_V)-runner-$(SIDECAR_OS_ARCH).exe
else
EXECUTABLE_DOWNLOAD_PATH := bin/ide-sidecar-$(IDE_SIDECAR_VERSION_NO_V)-runner
export EXECUTABLE_PATH := ide-sidecar-$(IDE_SIDECAR_VERSION_NO_V)-runner-$(SIDECAR_OS_ARCH)
endif
# Skip download if the executable already exists and is executable
SKIP_DOWNLOAD_EXECUTABLE := $(shell [ -x $(EXECUTABLE_DOWNLOAD_PATH) ] && echo true || echo false)
IDE_SIDECAR_REPO := confluentinc/ide-sidecar
# This target is meant for non-Windows platforms to download the sidecar executable
# For Windows, we use scripts/windows/download-sidecar-executable.ps1
.PHONY: download-sidecar-executable
download-sidecar-executable:
ifeq ($(SKIP_DOWNLOAD_EXECUTABLE),true)
@echo "Skipping download of sidecar executable since it already exists at $(EXECUTABLE_DOWNLOAD_PATH)"
else
mkdir -p bin && \
echo "Using curl to download sidecar executable from GitHub release $(IDE_SIDECAR_VERSION): $(EXECUTABLE_DOWNLOAD_PATH)"; \
curl --fail -L -o $(EXECUTABLE_DOWNLOAD_PATH) "https://github.com/$(IDE_SIDECAR_REPO)/releases/download/$(IDE_SIDECAR_VERSION)/$${EXECUTABLE_PATH}" && \
chmod +x $(EXECUTABLE_DOWNLOAD_PATH) && \
if [ $$(stat -f%z $(EXECUTABLE_DOWNLOAD_PATH) 2>/dev/null || stat -c%s $(EXECUTABLE_DOWNLOAD_PATH)) -lt 1048576 ]; then \
echo "Error: Downloaded sidecar executable is too small (< 1MB), likely corrupted or failed download" >&2; \
cat $(EXECUTABLE_DOWNLOAD_PATH) | head -20 >&2; \
rm -f $(EXECUTABLE_DOWNLOAD_PATH); \
exit 1; \
fi && \
echo "Downloaded sidecar executable to $(EXECUTABLE_DOWNLOAD_PATH) ($$(stat -f%z $(EXECUTABLE_DOWNLOAD_PATH) 2>/dev/null || stat -c%s $(EXECUTABLE_DOWNLOAD_PATH)) bytes)";
endif
# Downloads the THIRD_PARTY_NOTICES.txt file from the latest release of ide-sidecar as THIRD_PARTY_NOTICES_IDE_SIDECAR.txt
.PHONY: download-third-party-notices-sidecar
download-third-party-notices-sidecar:
ifeq ($(CI),true)
gh release download $(IDE_SIDECAR_VERSION) --repo $(IDE_SIDECAR_REPO) --pattern=THIRD_PARTY_NOTICES.txt --output THIRD_PARTY_NOTICES_IDE_SIDECAR.txt --clobber
endif
.PHONY: generate-third-party-notices
generate-third-party-notices:
@./scripts/generate-third-party-notices.sh
# Creates a PR against the currently checked out branch with a newly generated `THIRD_PARTY_NOTICES.txt` file.
# Runs `generate-third-party-notices` before creating the PR.
.PHONY: update-third-party-notices-pr
update-third-party-notices-pr:
@./scripts/update-third-party-notices-pr.sh
.PHONY: collect-notices-vsix
collect-notices-vsix:
@./scripts/notices/collect-notices-vsix.sh
# Captures the output of the version check, strips away any ANSI escape codes, and posts a comment
# to the PR if the version check fails.
.PHONY: check-sidecar-versions
check-sidecar-versions:
@./scripts/check-sidecar-versions.sh