Skip to content

Commit cd79462

Browse files
authored
Merge pull request #2065 from Homebrew/cache_and_cleanup
2 parents 3cc4c68 + b9c3170 commit cd79462

File tree

7 files changed

+42
-57
lines changed

7 files changed

+42
-57
lines changed

.github/workflows/tests.yml

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ jobs:
3636
core: false
3737
cask: true
3838

39-
- name: Update data for homebrew/cask
40-
run: /usr/bin/rake casks
39+
- run: brew generate-cask-api
4140
env:
4241
HOMEBREW_DEVELOPER: 1
4342

@@ -72,8 +71,7 @@ jobs:
7271
core: true
7372
cask: false
7473

75-
- name: Update data for homebrew/core
76-
run: /usr/bin/rake formulae
74+
- run: brew generate-formula-api
7775
env:
7876
HOMEBREW_DEVELOPER: 1
7977

@@ -126,8 +124,36 @@ jobs:
126124
- name: Create directories
127125
run: mkdir -p _data/analytics api/analytics
128126

127+
- name: Determine analytics cache date
128+
id: analytics-cache-date
129+
run: echo "date=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
130+
131+
- name: Cache analytics data
132+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
133+
with:
134+
path: |
135+
_data/analytics
136+
api/analytics
137+
key: analytics-data-${{ steps.analytics-cache-date.outputs.date }}
138+
restore-keys: analytics-data-
139+
129140
- name: Update analytics data
130-
run: /usr/bin/rake analytics
141+
run: |
142+
set -euo pipefail
143+
144+
analytics_backup_path="$(mktemp -d)"
145+
mv -v "_data/analytics" "${analytics_backup_path}/data_analytics"
146+
mv -v "api/analytics" "${analytics_backup_path}/api_analytics"
147+
148+
if brew generate-analytics-api; then
149+
exit 0
150+
fi
151+
152+
rm -rf "_data/analytics" "api/analytics"
153+
mv -v "${analytics_backup_path}/data_analytics" "_data/analytics"
154+
mv -v "${analytics_backup_path}/api_analytics" "api/analytics"
155+
156+
echo "::notice title=Analytics fallback::Restored cached analytics data after brew generate-analytics-api failure."
131157
if: github.ref_name == 'main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]')
132158
env:
133159
HOMEBREW_INFLUXDB_TOKEN: ${{ secrets.HOMEBREW_INFLUXDB_READ_TOKEN }}
@@ -183,9 +209,9 @@ jobs:
183209
run: |
184210
GENERATE_SAMPLES="${{ github.ref_name == 'main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false && github.event.pull_request.user.login != 'dependabot[bot]') }}"
185211
if [ "$GENERATE_SAMPLES" = "true" ]; then
186-
/usr/bin/rake "api_samples"
212+
ruby script/generate-api-samples.rb
187213
else
188-
/usr/bin/rake "api_samples[template]"
214+
ruby script/generate-api-samples.rb --template
189215
fi
190216
191217
- name: Build site
@@ -224,14 +250,7 @@ jobs:
224250

225251
deploy-issue:
226252
name: Open/close deploy issues
227-
needs:
228-
[
229-
generate-cask,
230-
generate-core,
231-
generate-analytics,
232-
build,
233-
deploy,
234-
]
253+
needs: [generate-cask, generate-core, generate-analytics, build, deploy]
235254
if: ${{ always() && github.ref_name == 'main' }}
236255
env:
237256
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

Brewfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# frozen_string_literal: true
2+
3+
brew "ruby", version_file: ".ruby-version"
4+
brew "xz"

Gemfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ gem "jekyll-redirect-from"
1010
gem "jekyll-remote-theme"
1111
gem "jekyll-seo-tag"
1212
gem "jekyll-sitemap"
13-
gem "rake"
1413

1514
group :test do
1615
gem "html-proofer"

Gemfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ DEPENDENCIES
205205
jekyll-seo-tag
206206
jekyll-sitemap
207207
mdl
208-
rake
209208

210209
RUBY VERSION
211210
ruby 3.4.7p58

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ To instead run the site locally, run:
2626
```bash
2727
git clone https://github.com/Homebrew/formulae.brew.sh
2828
cd formulae.brew.sh
29-
rake generate
29+
brew generate-formula-api
30+
brew generate-cask-api
31+
brew generate-analytics-api
32+
ruby script/generate-api-samples.rb
3033
bundle install
3134
bundle exec jekyll serve
3235
```

Rakefile

Lines changed: 0 additions & 38 deletions
This file was deleted.

_config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ exclude:
88
- script
99
- CNAME
1010
- LICENSE.txt
11-
- Rakefile
1211
- README.md
1312
- Gemfile*
1413
- vendor

0 commit comments

Comments
 (0)