From ac089e536132fe9bfb71979b88e172fc02d225e7 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:11:22 +0900 Subject: [PATCH 1/9] fix cache location of bazelisk --- .bazeliskrc | 1 - execute_tests.bash | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazeliskrc b/.bazeliskrc index 65af518..2a00219 100644 --- a/.bazeliskrc +++ b/.bazeliskrc @@ -1,2 +1 @@ -BAZELISK_HOME=.cache/bazelisk USE_BAZEL_VERSION=7.1.1 diff --git a/execute_tests.bash b/execute_tests.bash index 2960e01..c63c3e5 100755 --- a/execute_tests.bash +++ b/execute_tests.bash @@ -9,6 +9,7 @@ BAZEL_EXECUTABLE=( "env" "-i" BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 + BAZELISK_HOME=.cache/bazelisk "HOME=${HOME}" "PATH=${PATH}" bazelisk From c3cb44cff99436ae2c12e106e6c5c1c091527df0 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:30:01 +0900 Subject: [PATCH 2/9] try to cache --- .github/workflows/unit-tests.yml | 41 +++++++++++++++++++++++++++----- .gitignore | 3 +++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 4ddd675..88187ff 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -10,6 +10,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true +env: + # Location to store the bazelisk executable + BAZELISK_BIN_DIR: .bazelisk-bin + # Version of the bazelisk to use + BAZELISK_VERSION: v1.19.0/bazelisk-linux-amd64 + jobs: unit-tests: runs-on: ubuntu-22.04 @@ -18,12 +24,35 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - - name: Install bazelisk + - name: Try to restore build cache + uses: actions/cache/store@v4 + with: + path: .cache + key: ${{ runner.os }}-build + - name: Try to restore bazelisk binary + id: cache-bazelisk-bin + uses: actions/cache/store@v4 + with: + path: ${{ env.BAZELISK_BIN_DIR }} + key: ${{ env.BAZELISK_VERSION }}-bazelisk-bin + - name: Install bazelisk if it's needed + if: steps.cache-bazelisk-bin.outputs.cache-hit != 'true' run: | - bazelisk_dir="$(realpath "$(mktemp -d -p .)")" - wget https://github.com/bazelbuild/bazelisk/releases/download/v1.19.0/bazelisk-linux-amd64 \ - -O "${bazelisk_dir}/bazelisk" - chmod +x "${bazelisk_dir}/bazelisk" - echo "${bazelisk_dir}" >> "${GITHUB_PATH}" + wget https://github.com/bazelbuild/bazelisk/releases/download/${{ env.BAZELISK_VERSION }} \ + -O "${{ env.BAZELISK_BIN_DIR }}/bazelisk" + chmod +x "${{ env.BAZELISK_BIN_DIR }}/bazelisk" + - name: Save bazelisk binary + uses: actions/cache/save@v4 + if: steps.cache-bazelisk-bin.outputs.cache-hit != 'true' + with: + path: ${{ env.BAZELISK_BIN_DIR }} + key: ${{ env.BAZELISK_VERSION }}-bazelisk-bin + - name: Add bazelisk to PATH + run: echo "${{ env.BAZELISK_BIN_DIR }}" >> "${GITHUB_PATH}" - name: Run unit tests run: ./execute_tests.bash + - name: Save build cache + uses: actions/cache/save@v4 + with: + path: .cache + key: ${{ runner.os }}-build diff --git a/.gitignore b/.gitignore index 699707c..679186e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ # Bazel /bazel-* MODULE.bazel.lock + +# For CI +/.bazelisk-bin From 4d08a62ff4986508aef6b44c1a3a7e6fd60fa6ab Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:33:57 +0900 Subject: [PATCH 3/9] fix: typo --- .github/workflows/unit-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 88187ff..4e258c8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -25,13 +25,13 @@ jobs: with: ref: ${{ github.head_ref }} - name: Try to restore build cache - uses: actions/cache/store@v4 + uses: actions/cache/restore@v4 with: path: .cache key: ${{ runner.os }}-build - name: Try to restore bazelisk binary id: cache-bazelisk-bin - uses: actions/cache/store@v4 + uses: actions/cache/restore@v4 with: path: ${{ env.BAZELISK_BIN_DIR }} key: ${{ env.BAZELISK_VERSION }}-bazelisk-bin From a05046cda310bf7208a6c26bd321082ec2f3cdf8 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:35:19 +0900 Subject: [PATCH 4/9] fix: mkdir --- .github/workflows/unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 4e258c8..c8de7d1 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -38,6 +38,7 @@ jobs: - name: Install bazelisk if it's needed if: steps.cache-bazelisk-bin.outputs.cache-hit != 'true' run: | + mkdir -p ${{ env.BAZELISK_BIN_DIR }} wget https://github.com/bazelbuild/bazelisk/releases/download/${{ env.BAZELISK_VERSION }} \ -O "${{ env.BAZELISK_BIN_DIR }}/bazelisk" chmod +x "${{ env.BAZELISK_BIN_DIR }}/bazelisk" From a28ac0552c76b804295d577823c40a777b501701 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:39:56 +0900 Subject: [PATCH 5/9] try rerunning From 79ddd00e5fbb09c6c6379f71466ebf6949d3600f Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:48:14 +0900 Subject: [PATCH 6/9] fix cache key --- .github/workflows/unit-tests.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c8de7d1..b51566c 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -28,7 +28,8 @@ jobs: uses: actions/cache/restore@v4 with: path: .cache - key: ${{ runner.os }}-build + key: ${{ runner.os }}-build-${{ hashFiles('.cache/**') }} + restore-keys: ${{ runner.os }}-build- - name: Try to restore bazelisk binary id: cache-bazelisk-bin uses: actions/cache/restore@v4 @@ -56,4 +57,4 @@ jobs: uses: actions/cache/save@v4 with: path: .cache - key: ${{ runner.os }}-build + key: ${{ runner.os }}-build-${{ hashFiles('.cache/**') }} From ded585f75361ac886512461a8eab5120da040dca Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 19:51:55 +0900 Subject: [PATCH 7/9] do not cache build --- .github/workflows/unit-tests.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index b51566c..c5e7bc2 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -24,12 +24,6 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - - name: Try to restore build cache - uses: actions/cache/restore@v4 - with: - path: .cache - key: ${{ runner.os }}-build-${{ hashFiles('.cache/**') }} - restore-keys: ${{ runner.os }}-build- - name: Try to restore bazelisk binary id: cache-bazelisk-bin uses: actions/cache/restore@v4 @@ -53,8 +47,3 @@ jobs: run: echo "${{ env.BAZELISK_BIN_DIR }}" >> "${GITHUB_PATH}" - name: Run unit tests run: ./execute_tests.bash - - name: Save build cache - uses: actions/cache/save@v4 - with: - path: .cache - key: ${{ runner.os }}-build-${{ hashFiles('.cache/**') }} From d6dcd8a85c2c9196ff04177e3e5b5b2e10f78756 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 20:00:51 +0900 Subject: [PATCH 8/9] change build cache key --- .github/workflows/unit-tests.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c5e7bc2..1ec422b 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -24,6 +24,17 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} + - name: Get build cache key + id: build-cache-key + run: | + echo "key=${{ runner.os }}-build-${{ hashFiles('**') }}" \ + >> "${GITHUB_OUTPUT}" + - name: Try to restore build cache + uses: actions/cache/restore@v4 + with: + path: .cache + key: ${{ steps.build-cache-key.outputs.key }} + restore-keys: ${{ runner.os }}-build- - name: Try to restore bazelisk binary id: cache-bazelisk-bin uses: actions/cache/restore@v4 @@ -47,3 +58,8 @@ jobs: run: echo "${{ env.BAZELISK_BIN_DIR }}" >> "${GITHUB_PATH}" - name: Run unit tests run: ./execute_tests.bash + - name: Save build cache + uses: actions/cache/save@v4 + with: + path: .cache + key: ${{ steps.build-cache-key.outputs.key }} From 9c9a9f4d834b21ee9dff65615890c9437db51038 Mon Sep 17 00:00:00 2001 From: yuyawk Date: Sun, 7 Apr 2024 20:04:57 +0900 Subject: [PATCH 9/9] try rerunning