Skip to content

Commit 3cf2758

Browse files
committed
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 <[email protected]>
1 parent 6e54a2e commit 3cf2758

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

.github/workflows/build-setools.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,23 @@ jobs:
2323
artifact-id: ${{ steps.upload-artifact.outputs.artifact-id }}
2424

2525
steps:
26-
- name: Download cached SETools
27-
uses: actions/cache@v4
28-
id: cache-setools
29-
with:
30-
path: "setools-*.whl"
31-
key: setools-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}
32-
3326
- name: Checkout setools
3427
uses: actions/checkout@v4
35-
if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }}
3628
with:
3729
repository: SELinuxProject/setools
3830
ref: "${{ inputs.version }}"
3931

32+
- name: Get the latest commit hash
33+
shell: bash
34+
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
35+
36+
- name: Download cached SETools
37+
uses: actions/cache@v4
38+
id: cache-setools
39+
with:
40+
path: "setools-*.whl"
41+
key: setools-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}
42+
4043
- name: Download userspace artifact
4144
uses: actions/download-artifact@v4
4245
if: ${{ steps.cache-setools.outputs.cache-hit != 'true' }}

.github/workflows/build-userspace.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,25 @@ jobs:
2727
binary-id: ${{ steps.upload-artifact.outputs.artifact-id }}
2828

2929
steps:
30-
- name: Download cached SELinux userspace
31-
uses: actions/cache@v4
32-
id: cache-userspace
33-
with:
34-
path: ${{ github.workspace }}/selinux.tar.gz
35-
key: selinux-${{ inputs.version }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}
36-
3730
- name: Checkout SELinux userspace tools and libs
3831
uses: actions/checkout@v4
39-
if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }}
4032
with:
4133
repository: SELinuxProject/selinux
4234
ref: "${{ inputs.version }}"
4335
path: "${{ env.SELINUX_SRC }}"
4436

37+
- name: Get the latest commit hash
38+
shell: bash
39+
run: echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
40+
working-directory: "${{ env.SELINUX_SRC }}"
41+
42+
- name: Download cached SELinux userspace
43+
uses: actions/cache@v4
44+
id: cache-userspace
45+
with:
46+
path: ${{ github.workspace }}/selinux.tar.gz
47+
key: selinux-${{ inputs.version }}-${{ env.COMMIT_HASH }}-${{ runner.os }}-${{ runner.arch }}-Python${{ inputs.python-version }}
48+
4549
- name: Set up Python
4650
uses: actions/setup-python@v5
4751
if: ${{ steps.cache-userspace.outputs.cache-hit != 'true' }}

0 commit comments

Comments
 (0)