Skip to content

Commit

Permalink
Fix: Reduce Unauthenticated GitHub Access to Avoid Rate Limit Issue
Browse files Browse the repository at this point in the history
brew.yaml was commonly hitting a GitHub rate limit by doing
unauthenticated GitHub access.

We have reduced unauthenticated access in brew.yaml in two ways:
  1/ For brew install and test phases, we are providing an access
  token to brew via the HOMEBREW_GITHUB_API_TOKEN environment
  variable. We use a fine-grained personal access token restricted to
  a single repository and with all permissions left on "No Access".
and
  2/ For the final phase, the brew audit, we have to unset the above
  access token since the brew audit objects to it. We now perform the
  audit phase solely for the most recent macOS, not for all the macOS
  being tested.
Taken together, these measures seem to be enough to avoid the rate
limit issue.

homebrew/runformula.sh: Added the "--auditonly" option for the benefit
of brew.yaml, since brew.yaml now needs to run install+test phases,
and audit phase, separately.

Also: Update README to Reflect Stable PPA Versions
  • Loading branch information
dgreatwood committed Dec 28, 2024
1 parent 9caa159 commit acf2126
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 37 deletions.
34 changes: 24 additions & 10 deletions .github/workflows/brew.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Andrea Pappacoda
# SPDX-FileCopyrightText: 2024 Duncan Greatwood
#
# SPDX-License-Identifier: Apache-2.0

Expand Down Expand Up @@ -31,6 +31,9 @@ jobs:
strategy:
fail-fast: false
matrix:
# Note: If you change the list of OS by adding a newer one,
# PLEASE UPDATE THE AUDIT PHASE to use the most recent macOS
# (See "runformula.sh --auditonly ..." later in this file)
os: [ 'macos-13', 'macos-14', 'macos-15' ]
compiler: [ 'clang' ]
sanitizer: [ 'none' ]
Expand Down Expand Up @@ -76,16 +79,27 @@ jobs:
export CC
echo "CXX is $CXX; CC is $CC"
# Note - if you get the GitHub error:
# GitHub API Error: API rate limit exceeded for aa.bb.cc.dd...
# Then try rerunning the job in 20-25 minutes
# This is a fine-grained personal access token restricted to a
# single repository and with all permissions left on "No
# Access". We set this token to avoid being blocked by the
# GitHub access rate limit for unauthenticated access
# (i.e. the rate limit for access with no token).
export HOMEBREW_GITHUB_API_TOKEN=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
homebrew/runformula.sh -y --force --HEAD
# -y Say "yes" to doing the brew audit
# --force Run even if pistache brew formula unchanged
# --HEAD Test with head of pistacheio/pistache master branch
homebrew/runformula.sh --skipaudit --force --HEAD
# --skipaudit Say "yes" to doing the brew audit
# --force Run even if pistache brew formula unchanged
# --HEAD Test with head of pistacheio/pistache master
# branch
# Do audit only once, again to avoid rate limit issues
if [[ ${{ matrix.os }} == 'macos-15' ]]; then
# We unset the token again, otherwise audit will object to it
unset HOMEBREW_GITHUB_API_TOKEN
homebrew/runformula.sh --auditonly --force --HEAD
fi
# if brew list pistache &>/dev/null; then brew remove pistache; fi
# # Use release (not HEAD), do audit (-y), and force even if pistache
# # formula unchanged
## Use release (not HEAD), do audit (-y), and force even if pistache
## formula unchanged
# homebrew/runformula.sh -y --force
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ $ sudo apt install libpistache-dev

### Ubuntu PPA (Stable)

Currently there are no stable release of Pistache published into the [stable](https://launchpad.net/~pistache+team/+archive/ubuntu/stable) PPA. However, when that time comes, run the following to install a stable package:
From time to time, the project transfers release packages into the [stable](https://launchpad.net/~pistache+team/+archive/ubuntu/stable) PPA. Run the following to install a stable package:

```sh
$ sudo add-apt-repository ppa:pistache+team/stable
Expand Down
26 changes: 18 additions & 8 deletions homebrew/runformula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ do_yes=false
do_usage=false
use_head=false
skip_audit=false
audit_only=false
do_force=false
optspec=":hfy-:"
while getopts "$optspec" optchar; do
Expand All @@ -51,6 +52,9 @@ while getopts "$optspec" optchar; do
skipaudit)
skip_audit=true
;;
auditonly)
audit_only=true
;;
force)
do_force=true
;;
Expand Down Expand Up @@ -87,6 +91,7 @@ if [ "$do_usage" = true ]; then
echo " -f, --force Test even if forumla already up-to-date"
echo " -y Answer yes to questions (i.e. do audit)"
echo " --skipaudit Skips brew audit; overrides -y for audit question"
echo " --auditonly Skips brew install, does audit"
if [ "$do_yes" = true ] || [ "$do_head" = true ]; then
echo "Error: Usage requested with other options"
do_error=true
Expand Down Expand Up @@ -161,19 +166,24 @@ else
echo "Copying $MY_SCRIPT_DIR/pistache.rb to $pist_form_file"
fi

# Drop copyright + license SPDX message when adding forumla to homebrew/core
sed '1,6d' "$MY_SCRIPT_DIR/pistache.rb" >"$pist_form_file"
if [ "$audit_only" != true ]; then
# Drop copyright + license SPDX message when adding forumla to homebrew/core
sed '1,6d' "$MY_SCRIPT_DIR/pistache.rb" >"$pist_form_file"

if brew list pistache &>/dev/null; then brew remove pistache; fi
if [ "$use_head" = true ]; then
brew install --HEAD pistache
else
brew install --build-from-source pistache
if brew list pistache &>/dev/null; then brew remove pistache; fi
if [ "$use_head" = true ]; then
brew install --HEAD pistache
else
brew install --build-from-source pistache
fi
brew test --verbose pistache
fi
brew test --verbose pistache

if [ "$skip_audit" != true ]; then
do_audit=$do_yes
if [ "$do_audit" != true ]; then
do_audit=$audit_only
fi
if [ "$do_audit" != true ]; then
read -e -p 'brew audit? [y/N]> '
if [[ "$REPLY" == [Yy]* ]]; then
Expand Down
17 changes: 0 additions & 17 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ if get_option('b_coverage')
add_project_arguments(compiler.get_supported_arguments(['-fstack-protector-all', '--param=ssp-buffer-size=4']), language: 'cpp')
endif

# howardhinnant/date has several names - look for them, from the most
# to the least explicit name.
# In Meson 0.60.0, this can be replaced with a simpler:
#
# dependency('howardhinnant-date', 'hinnant-date', 'date')
#
date_dep = dependency('howard-hinnant-date', required: false)
if not date_dep.found()
date_dep = dependency('howardhinnant-date', required: false)
endif
if not date_dep.found()
date_dep = dependency('hinnant-date', required: false)
endif
if not date_dep.found()
date_dep = dependency('date', fallback: ['hinnant-date', 'date_dep'])
endif

deps_libpistache = [
dependency('threads')
]
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.27.20241223
0.4.27.20241227

0 comments on commit acf2126

Please sign in to comment.