From 6f42fbfa8a5dfa0595a42070ad273db93b839931 Mon Sep 17 00:00:00 2001 From: Vibhu Prashar Date: Sun, 15 Oct 2023 23:25:46 +0530 Subject: [PATCH] feat(ci): add support to cache tools in CI Signed-off-by: Vibhu Prashar --- .github/publish-images/action.yaml | 3 +++ .github/tools-cache/action.yaml | 21 +++++++++++++++++++++ .github/workflows/pr-checks.yaml | 9 ++++++++- .github/workflows/release.yaml | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/tools-cache/action.yaml diff --git a/.github/publish-images/action.yaml b/.github/publish-images/action.yaml index efd1d590..c3386529 100644 --- a/.github/publish-images/action.yaml +++ b/.github/publish-images/action.yaml @@ -38,6 +38,9 @@ runs: username: ${{ inputs.registry_login }} password: ${{ inputs.registry_token }} + - name: Install all tools + uses: ./.github/tools-cache + - name: Build Operator shell: bash run: | diff --git a/.github/tools-cache/action.yaml b/.github/tools-cache/action.yaml new file mode 100644 index 00000000..d61f8245 --- /dev/null +++ b/.github/tools-cache/action.yaml @@ -0,0 +1,21 @@ +--- +name: tools-cache +description: Caches development tools +runs: + using: composite + steps: + - uses: actions/cache@v3 + id: tools-cache + with: + path: ./tmp/bin + key: ${{ runner.os }}-tools-${{ hashFiles('./hack/tools.sh') }} + + - name: Install Dependencies + if: steps.tools-cache.outputs.cache-hit != 'true' + shell: bash + run: make tools + + - name: Show version info of tools + shell: bash + run: | + ls ./tmp/bin diff --git a/.github/workflows/pr-checks.yaml b/.github/workflows/pr-checks.yaml index d0514d72..0432e974 100644 --- a/.github/workflows/pr-checks.yaml +++ b/.github/workflows/pr-checks.yaml @@ -78,6 +78,9 @@ jobs: - uses: actions/setup-go@main with: go-version-file: go.mod + - name: Install all tools + uses: ./.github/tools-cache + - name: bundle run: | make generate manifests bundle @@ -101,6 +104,9 @@ jobs: run: | echo "result=$(git rev-parse --short HEAD),v1alpha1" >> $GITHUB_OUTPUT + - name: Install all tools + uses: ./.github/tools-cache + - name: build images for PR checks uses: ./.github/publish-images with: @@ -128,7 +134,8 @@ jobs: go-version-file: go.mod - name: Install all tools - run: make tools + uses: ./.github/tools-cache + - name: use kepler action for kind cluster build uses: sustainable-computing-io/kepler-action@v0.0.2 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c6c4b936..ddca80ca 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -47,6 +47,9 @@ jobs: env: VERSION: ${{ github.event.inputs.tag }} + - name: Install all tools + uses: ./.github/tools-cache + - name: Build Operator run: | make operator-build