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

workflows: add workflow to save gem cache #154676

Merged
merged 1 commit into from
Nov 17, 2023
Merged
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
87 changes: 87 additions & 0 deletions .github/workflows/cache.yml
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
Loading