Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve vcpkg cache hits #1033

Merged
merged 8 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ runs:
- name: macOS tools
if: runner.os == 'macOS'
shell: bash
run: brew install autoconf autoconf-archive automake pkg-config
run: |
brew install autoconf autoconf-archive automake pkg-config md5sha1sum
- name: simple build
run: echo "preset = ${{ inputs.preset }}"
Expand All @@ -39,16 +40,26 @@ runs:
# get baseline from vcpkg
vcpkgJsonGlob: './vcpkg.json'

- uses: actions/cache@v4
if: runner.os != 'Linux'
with:
key: deps-${{ inputs.preset }}-${{ hashFiles('./vcpkg.json') }}
path: ./vcpkg_cache
- name: get vcpkg cache key
id: get_vcpkg_cache_key
shell: bash
env:
DISTRO_LABEL: ${{ format('{0}-{1}', matrix.distro.name, matrix.distro.version) }}
KEY_PREFIX: vcpkg_cache-cmake-${{ inputs.preset }}
run: |
common_key="${KEY_PREFIX}-vcpkg_json_md5=$(md5sum ./vcpkg.json | awk '{ print $1 }')"
if [ "${RUNNER_OS}" != "Linux" ]; then
echo "key=${common_key}-ImageVersion=${ImageVersion}" | tee -a $GITHUB_OUTPUT
else
# ImageVersion is irrelevant since the build action runs in a container
# Express the vcpkg overlays, dockerfile, and entry point that the action will use as a single hash
build_action_hash="$(find ./.github/actions/openziti-tunnel-build-action/gh-release -type f -print | xargs md5sum | awk '{ print $1 }' | sort | md5sum | awk '{ print $1 }')"
echo "key=${common_key}-build_action_md5=${build_action_hash}" | tee -a $GITHUB_OUTPUT
fi
- uses: actions/cache@v4
if: runner.os == 'Linux'
with:
key: deps=${{ inputs.preset }}-${{ hashFiles('./vcpkg.json', '.github/actions/openziti-tunnel-build-action/gh-release/vcpkg-overlays/**/vcpkg.json') }}
key: ${{ steps.get_vcpkg_cache_key.outputs.key }}
path: ./vcpkg_cache

- uses: lukka/[email protected] # pin version to avoid failed glibc dependency on ubuntu 20 runners. go back to @latest when ubuntu 22+ is adopted for runner os.
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/cpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
shell: bash
run: |
dnf -y update
dnf -y install git
dnf -y install git findutils
git --version

- name: checkout workspace
Expand All @@ -93,9 +93,21 @@ jobs:
run: |
cp -vr ./.github/actions/openziti-tunnel-build-action/${DISTRO_LABEL}/* ./.github/actions/openziti-tunnel-build-action/

- name: get vcpkg cache key
id: get_vcpkg_cache_key
shell: bash
env:
DISTRO_LABEL: ${{ format('{0}-{1}', matrix.distro.name, matrix.distro.version) }}
KEY_PREFIX: vcpkg_cache-cpack-${{ matrix.arch.rpm }}-${{ matrix.distro.name }}-${{ matrix.distro.version }}
run: |
key_prefix="${KEY_PREFIX}-vcpkg_json_md5=$(md5sum ./vcpkg.json | awk '{ print $1 }')"
# Express the vcpkg overlays, dockerfile, and entry point that the action will use as a single hash
build_action_md5="$(find ./.github/actions/openziti-tunnel-build-action/${DISTRO_LABEL} -type f -print | xargs md5sum | awk '{ print $1 }' | sort | md5sum | awk '{ print $1 }')"
echo "key=${key_prefix}-build_action_md5=${build_action_md5}" | tee -a $GITHUB_OUTPUT

- uses: actions/cache@v4
with:
key: deps-cpack-${{ matrix.arch.rpm }}-${{ matrix.distro.name }}-${{ matrix.distro.version }}-${{ hashFiles('./vcpkg.json', './.github/actions/openziti-tunnel-build-action/vcpkg-overlays/**/vcpkg.json') }}
key: ${{ steps.get_vcpkg_cache_key.outputs.key }}
path: ./vcpkg_cache

# entrypoint.sh uses the value of arch to select the cmake preset
Expand Down
Loading