From 445fb5522b78fbd6c9129f390cbda9f45242246f Mon Sep 17 00:00:00 2001 From: Joerg Herbel Date: Tue, 28 Nov 2023 12:38:01 +0100 Subject: [PATCH] RCC: add caching to GitHub actions workflow Since we want to use RCC in our system test, we need to build it every time the test runs. To speed this up, we cache. CMK-15334 --- .github/workflows/rcc.yaml | 52 +++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/.github/workflows/rcc.yaml b/.github/workflows/rcc.yaml index 5ccae8c9..fe1f2eca 100644 --- a/.github/workflows/rcc.yaml +++ b/.github/workflows/rcc.yaml @@ -2,30 +2,64 @@ name: "RCC" on: - workflow_call: {} + workflow_call: + {} + +env: + RCC_TAG: "v14.15.4" + GO_VERSION: "1.20.x" + RUBY_VERSION: "2.7" jobs: - build_and_test: + check_cache: runs-on: ubuntu-latest + outputs: + cache_hit: ${{ steps.restore-from-cache.outputs.cache-hit }} + steps: + - id: restore-from-cache + uses: actions/cache/restore@v3 + with: + key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }} + path: build + lookup-only: true + build_and_cache: + runs-on: ubuntu-latest + needs: + - check_cache + if: ${{ needs.check_cache.outputs.cache_hit != 'true' }} steps: - uses: actions/checkout@v4 with: repository: robocorp/rcc - ref: v14.15.4 - + ref: ${{ env.RCC_TAG }} - uses: actions/setup-go@v3 with: - go-version: '1.20.x' - + go-version: ${{ env.GO_VERSION }} - uses: ruby/setup-ruby@v1 with: - ruby-version: '2.7' - + ruby-version: ${{ env.RUBY_VERSION }} - run: rake build - - run: rake test + - uses: actions/cache/save@v3 + with: + key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }} + path: build + upload: + runs-on: ubuntu-latest + needs: + - build_and_cache + # See https://github.com/actions/runner/issues/491 for the following condition + if: | + always() && + (needs.build_and_cache.result == 'success' || needs.build_and_cache.result == 'skipped') + steps: + - uses: actions/cache/restore@v3 + with: + path: build + key: rcc-${{ env.RCC_TAG }}-${{ env.GO_VERSION }}-${{ env.RUBY_VERSION }} + fail-on-cache-miss: true - uses: actions/upload-artifact@v3 with: path: build