From 71ac6ccf90b582c1c3fa64b6260a847357008264 Mon Sep 17 00:00:00 2001 From: yuyawk <46620009+yuyawk@users.noreply.github.com> Date: Thu, 7 Nov 2024 02:17:55 +0900 Subject: [PATCH] Use cache for non-scheduled jobs (#85) --- .github/workflows/tests.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0e0ce7c..bf0babd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,13 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} + - name: Look up cache if it's not a scheduled job + if: ${{ github.event_name != 'schedule' }} + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.cache + key: ${{ github.repository }}-${{ github.job }}-${{ matrix.bazel-version }}-${{ runner.os }}-${{ hashFiles('.bazelrc', 'WORKSPACE', 'MODULE.bazel') }} + restore-keys: ${{ github.repository }}-${{ github.job }}-${{ matrix.bazel-version }}-${{ runner.os }}- - name: Set up uses: ./.github/actions/setup with: @@ -63,6 +70,13 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} + - name: Look up cache if it's not a scheduled job + if: ${{ github.event_name != 'schedule' }} + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/examples/.cache + key: ${{ github.repository }}-${{ github.job }}-${{ matrix.bazel-version }}-${{ runner.os }}-${{ hashFiles('.bazelrc', 'WORKSPACE', 'MODULE.bazel', 'examples/.bazelrc', 'examples/WORKSPACE', 'examples/MODULE.bazel') }} + restore-keys: ${{ github.repository }}-${{ github.job }}-${{ matrix.bazel-version }}-${{ runner.os }}- - name: Set up uses: ./.github/actions/setup with: @@ -73,15 +87,24 @@ jobs: style-check: runs-on: ubuntu-latest + env: + bazel-version: 7.x steps: - name: Checkout uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} + - name: Look up cache if it's not a scheduled job + if: ${{ github.event_name != 'schedule' }} + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}/.cache + key: ${{ github.repository }}-${{ github.job }}-${{ env.bazel-version }}-${{ runner.os }}-${{ hashFiles('.bazelrc', 'WORKSPACE', 'MODULE.bazel') }} + restore-keys: ${{ github.repository }}-${{ github.job }}-${{ env.bazel-version }}-${{ runner.os }}- - name: Set up uses: ./.github/actions/setup with: - bazel-version: 7.x + bazel-version: ${{ env.bazel-version }} - name: Run formatters and linters shell: bash run: ./development/cli/style_check.bash