From 605d74dadada38c0634385ae0d6b57996f28576c Mon Sep 17 00:00:00 2001 From: Kostas Stamatakis Date: Tue, 13 Feb 2024 15:33:22 +0200 Subject: [PATCH] attempt to fix ga hernmit cache --- .github/actions/hermit/action.yml | 36 ++++++++++++++++++++++++++++++ .github/workflows/cloudbeat-ci.yml | 21 +++++------------ 2 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 .github/actions/hermit/action.yml diff --git a/.github/actions/hermit/action.yml b/.github/actions/hermit/action.yml new file mode 100644 index 0000000000..1578c2122b --- /dev/null +++ b/.github/actions/hermit/action.yml @@ -0,0 +1,36 @@ +name: 'Hermit Environment' +description: 'Activate hermit environment' +inputs: + cache: + description: 'Cache hermit files' + required: false + default: 'true' +runs: + using: composite + steps: + - if: ${{ inputs.cache == 'true' }} + id: hermit-hash + shell: bash + run: | + bin_hashes="${{ hashFiles('./bin/*') }}" + poetry_security_polices="${{ hashFiles('./security-policies/poetry.lock', './security-policies/pyproject.toml') }}" + poetry_tests="${{ hashFiles('./tests/poetry.lock', './tests/pyproject.toml') }}" + hash="$(echo "${bin_hashes} ${poetry_security_polices} ${poetry_tests}" | sha256sum | cut -d' ' -f1)" + echo "hash=$hash" >> "$GITHUB_OUTPUT" + - if: ${{ inputs.cache == 'true' }} + uses: actions/cache@v4 + with: + path: | + ~/.cache/hermit/pkg + ./.hermit + ~/.cache/go-build + ~/go/pkg/ + key: hermit-env-${{ runner.os }}-${{ steps.hermit-hash.outputs.hash }} + restore-keys: | + hermit-env-${{ runner.os }} + - shell: bash + run: ./bin/hermit env --raw >> "$GITHUB_ENV" + - shell: bash + run: hermit install + - shell: bash + run: go env diff --git a/.github/workflows/cloudbeat-ci.yml b/.github/workflows/cloudbeat-ci.yml index 3532c4e5da..356d827e1f 100644 --- a/.github/workflows/cloudbeat-ci.yml +++ b/.github/workflows/cloudbeat-ci.yml @@ -26,13 +26,8 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - - name: Set up GO (with caching) - uses: magnetikonline/action-golang-cache@v4 - with: - go-version-file: .go-version - - - name: Init Hermit - run: ./bin/hermit env -r >> $GITHUB_ENV + - name: Hermit Environment + uses: ./.github/actions/hermit - name: Install poetry run: | @@ -77,16 +72,12 @@ jobs: - name: Check out the repo uses: actions/checkout@v4 - - name: Setup GO (with caching) - uses: magnetikonline/action-golang-cache@v4 - with: - go-version-file: .go-version + - name: Hermit Environment + uses: ./.github/actions/hermit - name: build cloudbeat binary - uses: magefile/mage-action@v3 - with: - version: latest - args: build + shell: bash + run: mage build - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3