Skip to content

Commit

Permalink
build-userspace/setools.yml: Add commit hash to cache ID.
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
pebenito committed Nov 22, 2024
1 parent 6e54a2e commit 3cf2758
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/build-setools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/build-userspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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' }}
Expand Down

0 comments on commit 3cf2758

Please sign in to comment.