Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(CI): add other platform/arch agents Build & Test blocks #453

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 62 additions & 6 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,76 @@ global_job_config:
- make store-test-results-to-semaphore

blocks:
- name: "Build & Test"
# --- Build & Test (multi-platform/-arch) ---
- name: "Build & Test (linux x64)"
dependencies: []
# Skip when:
# - change in the release.svg file, signaling a `chore: none version bump vN.N.N` commit.
# - change in the .versions/next.txt file, signaling a release PR merge commit.
skip:
skip: &build-test-skip
when: "change_in(['/release.svg', '/.versions/next.txt'], {pipeline_file: 'ignore', branch_range: '$SEMAPHORE_GIT_COMMIT_RANGE', default_branch: 'main'})"
task:
jobs:
agent:
machine:
type: s1-prod-ubuntu20-04-amd64-1
jobs: &build-test-jobs
- name: "Build & Test"
commands:
- make test
epilogue:
epilogue: &build-test-epilogue
always:
commands:
- make remove-test-env

- name: "Build & Test (linux arm64)"
dependencies: []
skip: *build-test-skip
task:
agent:
machine:
type: s1-prod-ubuntu20-04-arm64-1
jobs: *build-test-jobs
epilogue: *build-test-epilogue

- name: "Build & Test (darwin x64)"
dependencies: []
skip: *build-test-skip
task:
agent:
machine:
type: s1-prod-macos-13-5-amd64
jobs: *build-test-jobs
epilogue: *build-test-epilogue

- name: "Build & Test (darwin arm64)"
dependencies: []
skip: *build-test-skip
task:
agent:
machine:
type: s1-prod-macos-13-5-arm64
jobs: *build-test-jobs
epilogue: *build-test-epilogue

- name: "Build & Test (win32 x64)"
dependencies: []
skip: *build-test-skip
task:
agent:
machine:
type: s1-prod-windows
jobs: *build-test-jobs
epilogue: *build-test-epilogue

# --- End Build & Test (multi-platform/-arch) ---

- name: "Bump microversion"
dependencies: ["Build & Test"]
dependencies:
- "Build & Test (linux x64)"
- "Build & Test (linux arm64)"
- "Build & Test (darwin x64)"
- "Build & Test (darwin arm64)"
- "Build & Test (win32 x64)"
skip:
# For main branch: Always bump microversion on every commit (except those that bump next.txt
# to set the next version under development)
Expand All @@ -73,7 +124,12 @@ blocks:
- make bump-microversion

- name: "Set next version under development"
dependencies: ["Build & Test"]
dependencies:
- "Build & Test (linux x64)"
- "Build & Test (linux arm64)"
- "Build & Test (darwin x64)"
- "Build & Test (darwin arm64)"
- "Build & Test (win32 x64)"
run:
when: "branch = 'main' and change_in('/.versions/next.txt', {pipeline_file: 'ignore', default_branch: 'main'})"
task:
Expand Down
40 changes: 33 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ 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
.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; \
elif [ $$(uname -s) = "Darwin" ]; then \
sudo mkdir -p /usr/local/var/lib /usr/local/var/run/dbus /usr/local/Caskroom/xquartz; \
sudo chown -R $$(whoami) /usr/local/var /usr/local/Caskroom; \
sudo chmod -R 775 /usr/local/var /usr/local/Caskroom; \
HOMEBREW_NO_AUTO_UPDATE=1 brew install gtk+3; \
HOMEBREW_NO_AUTO_UPDATE=1 brew install --cask xquartz; \
else \
echo "Unsupported OS for headless testing"; \
exit 1; \
fi

.PHONY: setup-test-env
setup-test-env:
@echo "Pulling automated-test-user credentials from Vault into .env file for testing"
Expand All @@ -20,14 +39,21 @@ remove-test-env:
@echo "Removing .env file"
@rm -f .env

# Install additional dependencies to run VSCode testing in headless mode
# ref: https://code.visualstudio.com/api/working-with-extensions/continuous-integration#github-actions
.PHONY: test
test: setup-test-env install-dependencies
sudo apt-get update
sudo apt install -y libgbm1 libgtk-3-0 xvfb
test: setup-test-env install-test-dependencies install-dependencies
npx gulp ci
xvfb-run -a npx gulp test
@if [ $$(uname -s) = "Linux" ]; then \
xvfb-run -a npx gulp test; \
elif [ $$(uname -s) = "Darwin" ]; then \
echo "Starting XQuartz..."; \
open -a /Applications/Utilities/XQuartz.app || open -a /opt/X11/bin/XQuartz || echo "Failed to start XQuartz"; \
sleep 5; \
export DISPLAY=:0; \
launchctl load -w /Library/LaunchAgents/org.xquartz.startx.plist 2>/dev/null || true; \
npx gulp test; \
else \
npx gulp test; \
fi
npx gulp functional

# Validates bump based on current version (in package.json)
Expand Down Expand Up @@ -73,7 +99,7 @@ EXECUTABLE_DOWNLOAD_PATH := bin/ide-sidecar-$(IDE_SIDECAR_VERSION_NO_V)-runner
SKIP_DOWNLOAD_EXECUTABLE := $(shell [ -x $(EXECUTABLE_DOWNLOAD_PATH) ] && echo true || echo false)

# 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/')" )
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/')" )

IDE_SIDECAR_REPO := confluentinc/ide-sidecar

Expand Down
11 changes: 6 additions & 5 deletions mk-files/semaphore.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SEM_CACHE_DURATION_DAYS ?= 7
current_time := $(shell date +"%s")
# OS Name
os_name := $(shell uname -s)
os_name_and_arch := $(shell echo $$(uname -s)-$$(uname -m) | tr '[:upper:]' '[:lower:]')

.PHONY: store-test-results-to-semaphore
store-test-results-to-semaphore:
Expand All @@ -23,10 +24,10 @@ endif
ci-bin-sem-cache-store:
ifneq ($(SEMAPHORE_GIT_REF_TYPE),pull-request)
@echo "Storing semaphore caches"
$(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name)_npm_cache SEM_CACHE_PATH=$(HOME)/.npm
$(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name_and_arch)_npm_cache SEM_CACHE_PATH=$(HOME)/.npm
# Cache packages installed by `npx playwright install`
[[ $(os_name) == "Darwin" ]] && $(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name)_playwright_cache SEM_CACHE_PATH=$(HOME)/Library/Caches/ms-playwright || true
[[ $(os_name) == "Linux" ]] && $(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name)_playwright_cache SEM_CACHE_PATH=$(HOME)/.cache/ms-playwright || true
[[ $(os_name) == "Darwin" ]] && $(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name_and_arch)_playwright_cache SEM_CACHE_PATH=$(HOME)/Library/Caches/ms-playwright || true
[[ $(os_name) == "Linux" ]] && $(MAKE) _ci-bin-sem-cache-store SEM_CACHE_KEY=$(os_name_and_arch)_playwright_cache SEM_CACHE_PATH=$(HOME)/.cache/ms-playwright || true
endif

# cache restore allows fuzzy matching. When it finds multiple matches, it will select the most recent cache archive.
Expand Down Expand Up @@ -54,5 +55,5 @@ _ci-bin-sem-cache-store:
.PHONY: ci-bin-sem-cache-restore
ci-bin-sem-cache-restore:
@echo "Restoring semaphore caches"
cache restore $(os_name)_npm_cache
cache restore $(os_name)_playwright_cache || true
cache restore $(os_name_and_arch)_npm_cache
cache restore $(os_name_and_arch)_playwright_cache || true
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.