Skip to content

Commit

Permalink
CI - version fix and cache disable option (#2212)
Browse files Browse the repository at this point in the history
CI - version fix and cache disable option 

---------

Co-authored-by: Kirill Azovtsev <[email protected]>
  • Loading branch information
zerg-su and qdrvm-ci authored Sep 17, 2024
1 parent 3924247 commit e785829
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
42 changes: 38 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ on:
options:
- 'true'
- 'false'
use_cache:
description: 'Use cache for build'
required: true
default: 'true'
type: 'choice'
options:
- 'true'
- 'false'

env:
BUILD_DIR: build
Expand All @@ -40,6 +48,7 @@ env:
DOCKER_REGISTRY_PATH: ${{ secrets.GCP_REGISTRY }}/${{ secrets.GCP_PROJECT }}/kagome-dev/
PROJECT_ID: ${{ secrets.GCP_PROJECT }}
CACHE_PATH: ./build/cache
USE_CACHE: ${{ github.event.inputs.use_cache || 'true' }}
DEFAULT_BUILD_TYPE: Release
GIT_REF_NAME: ${{ github.ref_name }}
IS_MAIN_OR_TAG: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) }}
Expand All @@ -52,6 +61,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
if: ${{ env.USE_CACHE == 'true' }}
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ env.CACHE_VERSION }}
Expand Down Expand Up @@ -84,6 +94,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
if: ${{ env.USE_CACHE == 'true' }}
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ matrix.options.name }}-${{ env.CACHE_VERSION }}
Expand Down Expand Up @@ -123,6 +134,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
if: ${{ env.USE_CACHE == 'true' }}
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ matrix.options.name }}-${{ env.CACHE_VERSION }}
Expand All @@ -140,6 +152,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
if: ${{ env.USE_CACHE == 'true' }}
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ env.CACHE_VERSION }}
Expand Down Expand Up @@ -186,6 +199,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
if: ${{ env.USE_CACHE == 'true' }}
with:
path: ${{ env.CACHE_PATHS }}
key: ${{ github.job }}-${{ matrix.options.name }}-${{ env.CACHE_VERSION }}
Expand All @@ -202,6 +216,11 @@ jobs:
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Get master branch"
run: git fetch origin master:master

- name: "Authenticate with Google Cloud"
uses: 'google-github-actions/auth@v2'
Expand All @@ -216,14 +235,19 @@ jobs:
gcloud auth configure-docker --quiet
gcloud auth configure-docker ${{ secrets.GCP_REGISTRY }} --quiet
- name: "Get commit version"
working-directory: ./housekeeping/docker/kagome-dev
run: make get_versions

- name: "Check version"
working-directory: ./housekeeping/docker/kagome-dev
run: |
SHORT_COMMIT_HASH=$(grep 'short_commit_hash:' commit_hash.txt | cut -d ' ' -f 2)
echo "short_commit_hash=${SHORT_COMMIT_HASH}" >> $GITHUB_ENV
echo "short_commit_hash=${SHORT_COMMIT_HASH}" | tee $GITHUB_ENV
- name: "Cache dependencies"
id: cache-restore
if: ${{ env.USE_CACHE == 'true' }}
uses: actions/cache/restore@v4
with:
path: ${{ env.CACHE_PATH }}
Expand Down Expand Up @@ -275,6 +299,11 @@ jobs:
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Get master branch"
run: git fetch origin master:master

- name: "Authenticate with Google Cloud"
uses: 'google-github-actions/auth@v2'
Expand All @@ -289,7 +318,7 @@ jobs:
gcloud auth configure-docker --quiet
gcloud auth configure-docker ${{ secrets.GCP_REGISTRY }} --quiet
- name: "Get Polkadot and Zombienet versions"
- name: "Get commit version"
working-directory: ./housekeeping/docker/kagome-dev
run: make get_versions

Expand All @@ -309,7 +338,7 @@ jobs:
echo "package_exist=${PACKAGE_EXIST}" >> $GITHUB_ENV
- name: "Cache dependencies"
if: env.package_exist == 'False'
if: ${{ env.package_exist == 'False' && env.USE_CACHE == 'true' }}
id: cache-restore
uses: actions/cache/restore@v4
with:
Expand Down Expand Up @@ -439,6 +468,11 @@ jobs:
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Get master branch"
run: git fetch origin master:master

# - name: Create and enable swap
# run: |
Expand All @@ -465,7 +499,7 @@ jobs:
gcloud auth configure-docker --quiet
gcloud auth configure-docker ${{ secrets.GCP_REGISTRY }} --quiet
- name: "Get Polkadot and Zombienet versions"
- name: "Get commit version"
working-directory: ./housekeeping/docker/kagome-dev
run: make get_versions

Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/zombie-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ on:
options:
- 'ON'
- 'OFF'
use_cache:
description: 'Use cache for build'
required: true
default: 'true'
type: 'choice'
options:
- 'true'
- 'false'

env:
DOCKER_REGISTRY_PATH: ${{ secrets.GCP_REGISTRY }}/${{ secrets.GCP_PROJECT }}/kagome-dev/
Expand All @@ -36,6 +44,7 @@ env:

CACHE_VERSION: v01
CACHE_PATH: ./build/cache
USE_CACHE: ${{ github.event.inputs.use_cache || 'true' }}

jobs:
kagome_dev_docker_build:
Expand All @@ -45,6 +54,11 @@ jobs:
steps:
- name: "Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: "Get master branch"
run: git fetch origin master:master

- name: "Authenticate with Google Cloud"
uses: 'google-github-actions/auth@v2'
Expand Down Expand Up @@ -79,7 +93,7 @@ jobs:
echo "package_exist=${PACKAGE_EXIST}" >> $GITHUB_ENV
- name: "Cache dependencies"
if: env.package_exist == 'False'
if: ${{ env.package_exist == 'False' && env.USE_CACHE == 'true' }}
id: cache-restore
uses: actions/cache/restore@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions housekeeping/docker/kagome-dev/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ RUST_VERSION ?= 1.79.0
# kagome_dev_docker_build Variables
BUILD_DIR ?= build
CACHE_DIR := $(shell pwd)/../../../../kagome/$(BUILD_DIR)/cache
WORKING_DIR := $(shell pwd)/../../../../kagome
DEPENDENCIES ?= libstdc++6, zlib1g, libgcc-s1, libc6, libtinfo6, libseccomp2, libatomic1
GITHUB_HUNTER_USERNAME ?=
GITHUB_HUNTER_TOKEN ?=
Expand Down Expand Up @@ -50,6 +51,7 @@ export BUILDKIT_PROGRESS=auto
get_versions:
@echo "full_commit_hash: `git rev-parse HEAD`" | tee commit_hash.txt
@echo "short_commit_hash: `git rev-parse HEAD | head -c 7`" | tee -a commit_hash.txt
@echo "kagome_version: `cd $(WORKING_DIR) && ./get_version.sh`" | tee kagome_version.txt

kagome_builder_deb:
docker build --platform $(PLATFORM) \
Expand Down
5 changes: 3 additions & 2 deletions zombienet/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ endef
get_versions:
python3 version.py https://github.com/paritytech/polkadot-sdk && \
python3 version.py https://github.com/paritytech/zombienet
echo "full_commit_hash: `git rev-parse HEAD`" > commit_hash.txt
echo "short_commit_hash: `git rev-parse HEAD | head -c 7`" >> commit_hash.txt
@echo "full_commit_hash: `git rev-parse HEAD`" | tee commit_hash.txt
@echo "short_commit_hash: `git rev-parse HEAD | head -c 7`" | tee -a commit_hash.txt
@echo "kagome_version: `cd $(WORKING_DIR) && ./get_version.sh`" | tee kagome_version.txt

polkadot_builder:
$(MAKE) get_versions
Expand Down

0 comments on commit e785829

Please sign in to comment.