-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154676 from Homebrew/cache
workflows: add workflow to save gem cache
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,87 @@ | ||
name: Populate gem cache | ||
|
||
on: | ||
push: | ||
paths: | ||
- .github/workflows/cache.yml | ||
schedule: | ||
- cron: '30 19/6 * * *' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
|
||
env: | ||
HOMEBREW_DEVELOPER: 1 | ||
HOMEBREW_NO_AUTO_UPDATE: 1 | ||
|
||
concurrency: | ||
group: cache | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
determine-runners: | ||
if: github.repository_owner == 'Homebrew' | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
runners: ${{ steps.determine-runners.outputs.runners }} | ||
steps: | ||
- name: Set up Homebrew | ||
id: set-up-homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
with: | ||
core: false | ||
cask: false | ||
test-bot: false | ||
|
||
- name: Determine runners to use for this job | ||
id: determine-runners | ||
env: | ||
HOMEBREW_MACOS_BUILD_ON_GITHUB_RUNNER: true | ||
HOMEBREW_MACOS_TIMEOUT: 30 | ||
run: brew determine-test-runners --all-supported | ||
|
||
cache: | ||
needs: determine-runners | ||
strategy: | ||
matrix: | ||
include: ${{ fromJson(needs.determine-runners.outputs.runners) }} | ||
fail-fast: false | ||
name: ${{ matrix.name }} | ||
runs-on: ${{ matrix.runner }} | ||
timeout-minutes: ${{ matrix.timeout }} | ||
steps: | ||
- name: Set up Homebrew | ||
id: set-up-homebrew | ||
uses: Homebrew/actions/setup-homebrew@master | ||
with: | ||
core: false | ||
cask: false | ||
test-bot: true | ||
|
||
- name: Cleanup runner | ||
if: matrix.cleanup | ||
working-directory: ${{ runner.temp }} | ||
run: brew test-bot --only-cleanup-before | ||
|
||
- name: Get cache key | ||
id: cache-key | ||
run: | | ||
cache_key_prefix="${{ runner.os }}" | ||
if [ "${{ runner.os }}" = macOS ] | ||
then | ||
macos_version="$(sw_vers -productVersion)" | ||
cache_key_prefix="${macos_version%%.*}-$(uname -m)" | ||
fi | ||
echo "prefix=${cache_key_prefix}" >> "${GITHUB_OUTPUT}" | ||
- name: Cache Homebrew Bundler gems | ||
uses: actions/cache@v3 | ||
with: | ||
path: ${{ steps.set-up-homebrew.outputs.gems-path }} | ||
key: ${{ steps.cache-key.outputs.prefix }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }} | ||
restore-keys: ${{ steps.cache-key.outputs.prefix }}-rubygems- | ||
|
||
- name: Setup Homebrew test environment | ||
working-directory: ${{ runner.temp }} | ||
run: brew test-bot --only-setup |