From 3cf27584101708182be7c99dea5b73c4e5097e86 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Fri, 22 Nov 2024 09:52:04 -0500 Subject: [PATCH] build-userspace/setools.yml: Add commit hash to cache ID. The jobs use the git reference to cheeckout the sources. Additional commits may have added since the cache was created, so add the commit ID to the cache's key. Signed-off-by: Chris PeBenito --- .github/workflows/build-setools.yml | 19 +++++++++++-------- .github/workflows/build-userspace.yml | 20 ++++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build-setools.yml b/.github/workflows/build-setools.yml index 1ea08fd061..a7a88a289b 100644 --- a/.github/workflows/build-setools.yml +++ b/.github/workflows/build-setools.yml @@ -23,20 +23,23 @@ jobs: artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }} steps: - - name: Download cached SETools - uses: actions/cache@v4 - id: cache-setools - with: - path: "setools-*.whl" - key: setools-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }} - - name: Checkout setools uses: actions/checkout@v4 - if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }} with: repository: SELinuxProject/setools ref: "${{ inputs.version }}" + - name: Get the latest commit hash + shell: bash + run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV + + - name: Download cached SETools + uses: actions/cache@v4 + id: cache-setools + with: + path: "setools-*.whl" + key: setools-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }} + - name: Download userspace artifact uses: actions/download-artifact@v4 if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }} diff --git a/.github/workflows/build-userspace.yml b/.github/workflows/build-userspace.yml index db01097e88..897fa1aa47 100644 --- a/.github/workflows/build-userspace.yml +++ b/.github/workflows/build-userspace.yml @@ -27,21 +27,25 @@ jobs: binary-id: ${{ steps.upload-artifact.outputs.artifact-id }} steps: - - name: Download cached SELinux userspace - uses: actions/cache@v4 - id: cache-userspace - with: - path: ${{ github.workspace }}/selinux.tar.gz - key: selinux-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }} - - name: Checkout SELinux userspace tools and libs uses: actions/checkout@v4 - if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }} with: repository: SELinuxProject/selinux ref: "${{ inputs.version }}" path: "${{ env.SELINUX_SRC }}" + - name: Get the latest commit hash + shell: bash + run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV + working-directory: "${{ env.SELINUX_SRC }}" + + - name: Download cached SELinux userspace + uses: actions/cache@v4 + id: cache-userspace + with: + path: ${{ github.workspace }}/selinux.tar.gz + key: selinux-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }} + - name: Set up Python uses: actions/setup-python@v5 if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }}