Repository navigation
Cache Azure Linux packages in CI #8196
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
Merged
Amaury Chamayou (achamayou)
merged 11 commits into
main
from
achamayou-tdnf-cache-experiment
Aug 25, 2026
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
995f354
Add TDNF cache experiment
achamayou fbf237b
Retain TDNF cache through configuration
achamayou cf8e673
Cache Azure Linux CI packages
achamayou 56487f0
Merge branch 'main' into achamayou-tdnf-cache-experiment
achamayou 3f2bfda
Merge branch 'main' into achamayou-tdnf-cache-experiment
achamayou 93077cb
Split Azure Linux dependency actions
achamayou 81a8077
Merge branch 'main' into achamayou-tdnf-cache-experiment
achamayou 63d2370
Merge package cache changes
achamayou c67348f
Simplify CI package caching
achamayou 5d54d3b
Refresh CI package caches weekly
achamayou ada0e43
Merge branch 'main' into achamayou-tdnf-cache-experiment
achamayou File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| name: Install Azure Linux CI dependencies | ||
| description: Restore and populate the Azure Linux package cache | ||
|
|
||
| runs: | ||
| using: composite | ||
| steps: | ||
| - name: Configure package cache | ||
| id: configure | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| source /etc/os-release | ||
| case "$VERSION_ID" in | ||
| 3.0) | ||
| package_manager=tdnf | ||
| setup_script=scripts/setup-ci.sh | ||
| cache_dir=/github/home/.ccf-package-cache/tdnf | ||
| config_file=/etc/tdnf/tdnf.conf | ||
| cache_option=cachedir | ||
| keepcache_value=1 | ||
| ;; | ||
| 4.0) | ||
| package_manager=dnf | ||
| setup_script=scripts/setup-ci-al4.sh | ||
| cache_dir=/github/home/.ccf-package-cache/dnf | ||
| config_file=/etc/dnf/dnf.conf | ||
| cache_option=system_cachedir | ||
| keepcache_value=True | ||
| ;; | ||
| *) | ||
| echo "Unsupported Azure Linux version: $VERSION_ID" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
|
|
||
| for attempt in 1 2 3; do | ||
| if "$package_manager" -y install tar zstd; then | ||
| break | ||
| fi | ||
| if (( attempt == 3 )); then | ||
| echo "Failed to install package cache tools" >&2 | ||
| exit 1 | ||
| fi | ||
| if (( attempt == 1 )); then | ||
| sleep 5 | ||
| else | ||
| sleep 30 | ||
| fi | ||
| done | ||
|
|
||
| set_config_option() { | ||
| local name=$1 | ||
| local value=$2 | ||
|
|
||
| if grep -q "^${name}=" "$config_file"; then | ||
| sed -i "s|^${name}=.*|${name}=${value}|" "$config_file" | ||
| else | ||
| sed -i "/^\[main\]/a ${name}=${value}" "$config_file" | ||
| fi | ||
| } | ||
|
|
||
| set_config_option "$cache_option" "$cache_dir" | ||
| set_config_option keepcache "$keepcache_value" | ||
| mkdir -p "$cache_dir" | ||
|
|
||
| day_of_week=$(date -u +%u) | ||
| days_since_sunday=$((day_of_week % 7)) | ||
| cache_week=$(date -u -d "$days_since_sunday days ago" +%Y-%m-%d) | ||
|
|
||
| echo "cache-dir=$cache_dir" >> "$GITHUB_OUTPUT" | ||
| echo "cache-week=$cache_week" >> "$GITHUB_OUTPUT" | ||
| echo "package-manager=$package_manager" >> "$GITHUB_OUTPUT" | ||
| echo "setup-script=$setup_script" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Restore package cache | ||
| continue-on-error: true | ||
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | ||
| with: | ||
| path: ${{ steps.configure.outputs.cache-dir }} | ||
| key: azure-linux-${{ steps.configure.outputs.package-manager }}-rpms-${{ runner.arch }}-${{ hashFiles('scripts/setup-ci*.sh') }}-${{ steps.configure.outputs.cache-week }} | ||
| restore-keys: | | ||
| azure-linux-${{ steps.configure.outputs.package-manager }}-rpms-${{ runner.arch }}-${{ hashFiles('scripts/setup-ci*.sh') }}- | ||
| azure-linux-${{ steps.configure.outputs.package-manager }}-rpms-${{ runner.arch }}- | ||
|
eddyashton marked this conversation as resolved.
Resolved
|
||
|
|
||
| - name: Install dependencies | ||
| shell: bash | ||
| env: | ||
| PACKAGE_MANAGER: ${{ steps.configure.outputs.package-manager }} | ||
| SETUP_SCRIPT: ${{ steps.configure.outputs.setup-script }} | ||
| run: | | ||
| set -euo pipefail | ||
| "$PACKAGE_MANAGER" clean metadata | ||
| bash "$SETUP_SCRIPT" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.