Skip to content

Commit

Permalink
Merge pull request Homebrew#941 from Homebrew/improve_analytics_testing
Browse files Browse the repository at this point in the history
Improve analytics generation testing
  • Loading branch information
MikeMcQuaid committed Jul 19, 2023
2 parents a5765f2 + 0271548 commit ab277a4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/scheduled.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ jobs:
with:
ruby-version: "2.6"

- name: Set up analytics
env:
ANALYTICS_JSON_KEY: ${{ secrets.HOMEBREW_FORMULAE_BREW_SH_ANALYTICS_JSON_KEY }}
run: echo "$ANALYTICS_JSON_KEY" > ~/.homebrew_analytics.json

- name: Update analytics data
run: /usr/bin/rake analytics
env:
Expand Down
22 changes: 18 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: false
core: true
cask: true
test-bot: false

- name: Set up Ruby
Expand All @@ -30,7 +30,21 @@ jobs:
ruby-version: "2.6"
bundler-cache: true

- name: Generate site
run: /usr/bin/rake formulae casks
- name: Generate formulae, casks and API samples
run: /usr/bin/rake formulae casks api_samples
env:
HOMEBREW_DEVELOPER: 1

- name: Generate analytics
if: github.event.pull_request.head.repo.fork == false && (github.event_name == 'pull_request' && github.event.pull_request.user.login != 'dependabot[bot]')
run: |
brew tap Homebrew/formula-analytics
brew formula-analytics --install --json --days-ago=2
env:
HOMEBREW_INFLUXDB_TOKEN: ${{ secrets.HOMEBREW_INFLUXDB_READ_TOKEN }}

- name: Build site
run: bundle exec jekyll build

- name: Validate build
run: ./script/validate-build.rb
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ _site/
bin/
vendor/
.jekyll-metadata
.homebrew_analytics.json
.sass-cache/
Gemfile.lock
_data/
api/cask/
api/cask-source/
api/formula/
api/analytics/
api/*_tap_migrations.json
_includes/api-samples/
cask/
formula/
17 changes: 1 addition & 16 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,13 @@ task :casks do
end
CLOBBER.include FileList[%w[_data/cask api/cask api/cask-source cask]]

def setup_analytics_credentials
ga_credentials = ".homebrew_analytics.json"
return unless File.exist?(ga_credentials)

ga_credentials_home = File.expand_path("~/#{ga_credentials}")
return if File.exist?(ga_credentials_home)

FileUtils.cp ga_credentials, ga_credentials_home
end

def setup_formula_analytics_cmd
def setup_analytics
ENV["HOMEBREW_NO_AUTO_UPDATE"] = "1"
return if `brew tap`.include?("homebrew/formula-analytics")

sh "brew", "tap", "Homebrew/formula-analytics"
end

def setup_analytics
setup_analytics_credentials
setup_formula_analytics_cmd
end

desc "Dump analytics data"
task :analytics do
setup_analytics
Expand Down

0 comments on commit ab277a4

Please sign in to comment.