-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirill Azovtsev
committed
Feb 15, 2025
1 parent
a976cf1
commit 93e325e
Showing
10 changed files
with
281 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
**/build/ | ||
**/build-*/ | ||
**/build_*/ | ||
**/cmake-build-*/ | ||
*.DS_Store | ||
*.vscode/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 80 additions & 40 deletions
120
housekeeping/docker/kagome-dev/Makefile.include/kagome_bin.mk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,112 @@ | ||
kagome_dev_docker_build: | ||
$(MAKE) get_versions | ||
kagome_docker_build: | ||
@echo "-- Building Kagome binary for $(ARCHITECTURE) architecture..." ; \ | ||
$(MAKE) docker_run ; \ | ||
if $(MAKE) docker_exec; then \ | ||
echo "-- Build successful."; \ | ||
else \ | ||
echo "-- Build failed. Cleaning up..."; \ | ||
$(MAKE) clean_container; \ | ||
exit 1; \ | ||
fi ; \ | ||
$(MAKE) clean_container | ||
|
||
stop_container: | ||
@echo "-- Stopping and removing polkadot_builder container..." | ||
docker stop $(KAGOME_BUILD_CONTAINER_NAME) || true | ||
|
||
clean_container: stop_container | ||
@echo "-- Removing previous build container..." | ||
docker rm $(KAGOME_BUILD_CONTAINER_NAME) || true | ||
|
||
reset_build_state: clean_container | ||
@echo "-- Resetting build state..." ; \ | ||
rm -f ./commit_hash.txt ./kagome_version.txt || true; \ | ||
$(call safe_rm,$(BUILD_DIR)) || true | ||
|
||
docker_run: clean_container | ||
@echo "-- Running Kagome build container..." ; \ | ||
mkdir -p \ | ||
$(CACHE_DIR)/.cargo/git \ | ||
$(CACHE_DIR)/.cargo/registry \ | ||
$(CACHE_DIR)/.cargo \ | ||
$(CACHE_DIR)/.hunter \ | ||
$(CACHE_DIR)/.cache/ccache ; \ | ||
CONTAINER_NAME=kagome_dev_build_$$(openssl rand -hex 6); \ | ||
SHORT_COMMIT_HASH=$$(grep 'short_commit_hash:' commit_hash.txt | cut -d ' ' -f 2); \ | ||
DOCKER_EXEC_RESULT=0 ; \ | ||
echo "Build type: $(BUILD_TYPE)"; \ | ||
docker run -d --name $$CONTAINER_NAME \ | ||
docker run -d --name $(CONTAINER_NAME) \ | ||
--platform $(PLATFORM) \ | ||
--entrypoint "/bin/bash" \ | ||
-e SHORT_COMMIT_HASH=$$SHORT_COMMIT_HASH \ | ||
-e SHORT_COMMIT_HASH=$(SHORT_COMMIT_HASH) \ | ||
-e BUILD_TYPE=$(BUILD_TYPE) \ | ||
-e PACKAGE_ARCHITECTURE=$(PACKAGE_ARCHITECTURE) \ | ||
-e ARCHITECTURE=$(ARCHITECTURE) \ | ||
-e GITHUB_HUNTER_USERNAME=$(GITHUB_HUNTER_USERNAME) \ | ||
-e GITHUB_HUNTER_TOKEN=$(GITHUB_HUNTER_TOKEN) \ | ||
-e CTEST_OUTPUT_ON_FAILURE=$(CTEST_OUTPUT_ON_FAILURE) \ | ||
-v $$(pwd)/../../../../kagome:/opt/kagome \ | ||
-v $(GOOGLE_APPLICATION_CREDENTIALS):/root/.gcp/google_creds.json \ | ||
-v $(CACHE_DIR)/.cargo/git:/root/.cargo/git \ | ||
-v $(CACHE_DIR)/.cargo/registry:/root/.cargo/registry \ | ||
-v $(CACHE_DIR)/.hunter:/root/.hunter \ | ||
-v $(CACHE_DIR)/.cache/ccache:/root/.cache/ccache \ | ||
-v $(GOOGLE_APPLICATION_CREDENTIALS):$(IN_DOCKER_HOME)/.gcp/google_creds.json \ | ||
-v ./build_apt_package.sh:$(IN_DOCKER_HOME)/build_apt_package.sh \ | ||
-v $(WORKING_DIR):$(IN_DOCKER_HOME)/kagome \ | ||
-v $(BUILD_DIR)/pkg:$(IN_DOCKER_HOME)/pkg \ | ||
-v $(BUILD_DIR)/kagome_binary:$(IN_DOCKER_HOME)/kagome_binary \ | ||
-v $(CACHE_DIR)/.cargo:$(IN_DOCKER_HOME)/.cargo \ | ||
-v $(CACHE_DIR)/.hunter:$(IN_DOCKER_HOME)/.hunter \ | ||
-v $(CACHE_DIR)/.cache/ccache:$(IN_DOCKER_HOME)/.cache/ccache \ | ||
$(DOCKER_REGISTRY_PATH)kagome_builder_deb:$(BUILDER_IMAGE_TAG) \ | ||
-c "tail -f /dev/null"; \ | ||
docker exec -t $$CONTAINER_NAME /bin/bash -c \ | ||
"cd /opt/kagome && \ | ||
git config --global --add safe.directory /opt/kagome && \ | ||
git config --global --add safe.directory /root/.hunter/_Base/Cache/meta && \ | ||
tail -f /dev/null ; \ | ||
until [ "$$(docker inspect --format='{{.State.Health.Status}}' $(CONTAINER_NAME))" = "healthy" ]; do \ | ||
echo "Health is: \"$$(docker inspect --format='{{.State.Health.Status}}' $(CONTAINER_NAME))\"" ; \ | ||
sleep 5 ; \ | ||
done | ||
|
||
docker_exec: | ||
echo "-- Executing kagome_builder container..." ; \ | ||
docker exec -t $(CONTAINER_NAME) gosu $(USER_ID):$(GROUP_ID) /bin/bash -c \ | ||
"echo \"-- Setting up environment...\"; \ | ||
env ; \ | ||
cd $(IN_DOCKER_HOME)/kagome && \ | ||
git config --global --add safe.directory $(IN_DOCKER_HOME)/kagome && \ | ||
git config --global --add safe.directory $(IN_DOCKER_HOME)/.hunter/_Base/Cache/meta && \ | ||
source /venv/bin/activate && \ | ||
git submodule update --init && \ | ||
echo \"Building in $$(pwd)\" && \ | ||
cmake . -B\"$(BUILD_DIR)\" -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=\"$(BUILD_TYPE)\" -DBACKWARD=OFF -DWERROR=$(WERROR) && \ | ||
cmake --build \"$(BUILD_DIR)\" --target kagome -- -j$(BUILD_THREADS) && \ | ||
mkdir -p /tmp/kagome && \ | ||
cp /opt/kagome/$(BUILD_DIR)/node/kagome /tmp/kagome/kagome && \ | ||
cd /opt/kagome/housekeeping/docker/kagome-dev && \ | ||
./build_apt_package.sh \ | ||
\"$$(date +'%y.%m.%d')-$${SHORT_COMMIT_HASH}-$(BUILD_TYPE)\" \ | ||
$(PACKAGE_ARCHITECTURE) \ | ||
echo \"-- Recent commits:\" && git log --oneline -n 5 && \ | ||
echo \"Building Kagome in $$(pwd)\" && \ | ||
$(BUILD_COMMANDS) && \ | ||
echo \"-- Copying Kagome binary...\" && \ | ||
cp $(IN_DOCKER_HOME)/kagome/$(DOCKER_BUILD_DIR_NAME)/node/kagome $(IN_DOCKER_HOME)/kagome_binary/kagome && \ | ||
echo \"-- Building apt package...\" && \ | ||
cd $(IN_DOCKER_HOME) && ./build_apt_package.sh \ | ||
$(KAGOME_DEB_PACKAGE_VERSION) \ | ||
$(ARCHITECTURE) \ | ||
kagome-dev \ | ||
/tmp/kagome \ | ||
$(IN_DOCKER_HOME)/kagome_binary \ | ||
'Kagome Dev Ubuntu Package' \ | ||
'$(DEPENDENCIES)' && \ | ||
if [ "$(IS_MAIN_OR_TAG)" = "true" ] && [ "$(GIT_REF_NAME)" != "master" ] && [ "$(BUILD_TYPE)" = "Release" ]; then \ | ||
./build_apt_package.sh \ | ||
\"$(KAGOME_SANITIZED_VERSION)-$(BUILD_TYPE)\" \ | ||
$(PACKAGE_ARCHITECTURE) \ | ||
$(KAGOME_DEB_RELEASE_PACKAGE_VERSION) \ | ||
$(ARCHITECTURE) \ | ||
kagome \ | ||
/tmp/kagome \ | ||
$(IN_DOCKER_HOME)/kagome_binary \ | ||
'Kagome Ubuntu Package' \ | ||
'$(DEPENDENCIES)' ; \ | ||
fi; \ | ||
" || DOCKER_EXEC_RESULT=$$? ; \ | ||
if [ $$DOCKER_EXEC_RESULT -ne 0 ]; then \ | ||
echo "Error: Docker exec failed with return code $$DOCKER_EXEC_RESULT"; \ | ||
docker stop $$CONTAINER_NAME; \ | ||
exit $$DOCKER_EXEC_RESULT; \ | ||
fi; \ | ||
docker stop $$CONTAINER_NAME | ||
fi | ||
|
||
upload_apt_package: | ||
SHORT_COMMIT_HASH=$$(grep 'short_commit_hash:' commit_hash.txt | cut -d ' ' -f 2); \ | ||
@echo "-- Uploading Kagome binary to Google Cloud Storage..." ; \ | ||
gcloud config set artifacts/repository $(ARTIFACTS_REPO); \ | ||
gcloud config set artifacts/location $(REGION); \ | ||
gcloud artifacts apt upload $(ARTIFACTS_REPO) --source=./pkg/kagome-dev_$$(date +'%y.%m.%d')-$${SHORT_COMMIT_HASH}-$(BUILD_TYPE)_$(PACKAGE_ARCHITECTURE).deb ; \ | ||
gcloud artifacts versions delete $(KAGOME_DEB_PACKAGE_VERSION) --package=kagome-dev --quiet || true ; \ | ||
gcloud artifacts apt upload $(ARTIFACTS_REPO) --source=./$(BUILD_DIR)/pkg/$(KAGOME_DEB_PACKAGE_NAME) ; \ | ||
if [ "$(IS_MAIN_OR_TAG)" = "true" ] && [ "$(GIT_REF_NAME)" != "master" ] && [ "$(BUILD_TYPE)" = "Release" ]; then \ | ||
gcloud artifacts apt upload $(PUBLIC_ARTIFACTS_REPO) --source=./pkg/kagome_$(KAGOME_SANITIZED_VERSION)-$(BUILD_TYPE)_$(PACKAGE_ARCHITECTURE).deb ; \ | ||
echo "-- Uploading Kagome release binary to Google Cloud Storage..." ; \ | ||
gcloud artifacts versions delete $(KAGOME_DEB_RELEASE_PACKAGE_VERSION) --package=kagome-dev --quiet || true ; \ | ||
gcloud artifacts apt upload $(PUBLIC_ARTIFACTS_REPO) --source=./$(BUILD_DIR)/pkg/KAGOME_DEB_RELEASE_PACKAGE_NAME ; \ | ||
fi; | ||
|
||
kagome_deb_package_info: | ||
@echo "Kagome version: $(KAGOME_SANITIZED_VERSION)" | ||
@echo "Kagome deb package version: $(KAGOME_DEB_PACKAGE_VERSION)" | ||
@echo "Kagome deb package name: $(KAGOME_DEB_PACKAGE_NAME)" | ||
@echo "Kagome deb release package version: $(KAGOME_DEB_RELEASE_PACKAGE_VERSION)" | ||
@echo "Kagome deb release package name: $(KAGOME_DEB_RELEASE_PACKAGE_NAME)" |
Oops, something went wrong.