Skip to content

Commit

Permalink
Runtime cache build packet - first iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
qdrvm-ci committed Jun 24, 2024
1 parent 6385490 commit 4f68bc2
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/kagome-builder-deb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,36 @@ jobs:
if: env.exists == 'false' || github.event.inputs.kagome_image_rebuild == 'true'
run: make kagome_builder_deb_push \
DOCKER_REGISTRY_PATH=${DOCKER_REGISTRY_PATH}

build_kagome_runtime:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name : "Authenticate with Google Cloud"
uses: 'google-github-actions/auth@v2'
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}

- name: "Set up Cloud SDK"
uses: 'google-github-actions/setup-gcloud@v2'

- name: "Configure Docker for GCR"
run: |
gcloud auth configure-docker --quiet
gcloud auth configure-docker ${{ secrets.GCP_REGISTRY }} --quiet
- name: "Build Runtime Cache"
working-directory: ./housekeeping/docker/kagome-dev
# if: env.exists == 'false' || github.event.inputs.kagome_image_rebuild == 'true'
run: make runtime_cache \
DOCKER_REGISTRY_PATH=${DOCKER_REGISTRY_PATH}

- name: "Push Runtime Cache"
working-directory: ./housekeeping/docker/kagome-dev
# if: env.exists == 'false' || github.event.inputs.kagome_image_rebuild == 'true'
run: make upload_apt_package_runtime \
DOCKER_REGISTRY_PATH=${DOCKER_REGISTRY_PATH}

48 changes: 47 additions & 1 deletion housekeeping/docker/kagome-dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,50 @@ upload_apt_package:
SHORT_COMMIT_HASH=$$(grep 'short_commit_hash:' commit_hash.txt | cut -d ' ' -f 2); \
gcloud config set artifacts/repository $(ARTIFACTS_REPO); \
gcloud config set artifacts/location $(REGION); \
gcloud artifacts apt upload $(ARTIFACTS_REPO) --source=./pkg/kagome-dev_$$(date +'%d.%m.%y')-$${SHORT_COMMIT_HASH}-$${BUILD_TYPE}_$(PACKAGE_ARCHITECTURE).deb
gcloud artifacts apt upload $(ARTIFACTS_REPO) --source=./pkg/kagome-dev_$$(date +'%d.%m.%y')-$${SHORT_COMMIT_HASH}-$${BUILD_TYPE}_$(PACKAGE_ARCHITECTURE).deb


runtime_cache:
CONTAINER_NAME=kagome_dev_runtime_cache_$$(openssl rand -hex 6); \
RUNTIME_VERSION=$$(python3 get_wasmedge_version.py); \
DOCKER_EXEC_RESULT=0 ; \
echo "Runtime version: $$RUNTIME_VERSION"; \
docker run -d --name $$CONTAINER_NAME \
--platform $(PLATFORM) \
--entrypoint "/bin/bash" \
-e RUNTIME_VERSION=$$RUNTIME_VERSION \
-e PACKAGE_ARCHITECTURE=$(PACKAGE_ARCHITECTURE) \
-e GOOGLE_APPLICATION_CREDENTIALS=/root/.gcp/google_creds.json \
-v $$(pwd)/../../../../kagome:/opt/kagome \
-v $(GOOGLE_APPLICATION_CREDENTIALS):/root/.gcp/google_creds.json \
$(DOCKER_REGISTRY_PATH)zombie_tester:latest \
-c "tail -f /dev/null"; \
docker exec -t $$CONTAINER_NAME /bin/bash -c \
"cd /opt/kagome/zombienet && \
sed -i '1s/^#//' /etc/apt/sources.list.d/kagome.list && \
install_packages kagome-dev && \
./precompile.sh && \
mkdir -p /tmp/kagome_runtime && \
cp -r /tmp/kagome/runtimes-cache/* /tmp/kagome_runtime && \
cd /opt/kagome/housekeeping/docker/kagome-dev && \
./build_apt_package.sh \
\"$${RUNTIME_VERSION}\" \
$(PACKAGE_ARCHITECTURE) \
kagome-dev-runtime \
/tmp/kagome_runtime \
'Kagome Runtime Dev Debian Package' \
'kagome' ; \
" || 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


upload_apt_package_runtime:
RUNTIME_VERSION=$$(python3 get_wasmedge_version.py); \
gcloud config set artifacts/repository $(ARTIFACTS_REPO); \
gcloud config set artifacts/location $(REGION); \
gcloud artifacts apt upload $(ARTIFACTS_REPO) --source=./pkg/kagome-dev-runtime_${RUNTIME_VERSION}_$(PACKAGE_ARCHITECTURE).deb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def extract_version_and_sha(config_file_path, package_name):
return version, sha

if __name__ == "__main__":
config_file_path = '../cmake/Hunter/config.cmake'
config_file_path = '../../../cmake/Hunter/config.cmake'
package_name = 'WasmEdge'

version, sha = extract_version_and_sha(config_file_path, package_name)
Expand Down
2 changes: 1 addition & 1 deletion zombienet/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ define run_test
-e GOOGLE_APPLICATION_CREDENTIALS=/root/.gcp/google_creds.json \
$(1) \
-c "sed -i '1s/^#//' /etc/apt/sources.list.d/kagome.list && \
install_packages kagome-dev=$(KAGOME_PACKAGE_VERSION) && \
install_packages kagome-dev=$(KAGOME_PACKAGE_VERSION) kagome-dev-runtime && \
zombienet-linux-x64 test -p native /home/nonroot/bin/$$TEST_PATH " ; \
TEST_EXIT_CODE=$$(docker inspect $$CONTAINER_NAME --format='{{.State.ExitCode}}'); \
if [ "$(COPY_LOGS_TO_HOST)" = "true" ]; then \
Expand Down

0 comments on commit 4f68bc2

Please sign in to comment.