From acf2126ef81901f5980788e912597e8265880a46 Mon Sep 17 00:00:00 2001 From: DMG Date: Thu, 26 Dec 2024 15:00:24 -0800 Subject: [PATCH] Fix: Reduce Unauthenticated GitHub Access to Avoid Rate Limit Issue 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 --- .github/workflows/brew.yaml | 34 ++++++++++++++++++++++++---------- README.md | 2 +- homebrew/runformula.sh | 26 ++++++++++++++++++-------- meson.build | 17 ----------------- version.txt | 2 +- 5 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/brew.yaml b/.github/workflows/brew.yaml index 40014f6c..8d553ef6 100644 --- a/.github/workflows/brew.yaml +++ b/.github/workflows/brew.yaml @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022 Andrea Pappacoda +# SPDX-FileCopyrightText: 2024 Duncan Greatwood # # SPDX-License-Identifier: Apache-2.0 @@ -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' ] @@ -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 diff --git a/README.md b/README.md index 2c1964b9..107e1c6b 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/homebrew/runformula.sh b/homebrew/runformula.sh index 19c9f3cf..b18d8200 100755 --- a/homebrew/runformula.sh +++ b/homebrew/runformula.sh @@ -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 @@ -51,6 +52,9 @@ while getopts "$optspec" optchar; do skipaudit) skip_audit=true ;; + auditonly) + audit_only=true + ;; force) do_force=true ;; @@ -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 @@ -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 diff --git a/meson.build b/meson.build index c823ce2f..9fb540c3 100644 --- a/meson.build +++ b/meson.build @@ -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') ] diff --git a/version.txt b/version.txt index 495cb42c..fed3af26 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.4.27.20241223 +0.4.27.20241227