Skip to content

Commit

Permalink
feat: add analytics report to CI
Browse files Browse the repository at this point in the history
Co-authored-by: Carlo Cabrera <[email protected]>
  • Loading branch information
SMillerDev and carlocab committed Jul 17, 2024
1 parent 6d6cafd commit 99e01c0
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,41 @@ jobs:
TESTING_FORMULAE: ${{ steps.formulae-detect.outputs.formulae_to_fetch }}
run: brew test-bot --only-bottles-fetch --testing-formulae="$TESTING_FORMULAE"

report_analytics:
runs-on: ubuntu-latest
needs: formulae_detect
steps:
- name: Publish Analytics to Summary
env:
TESTING_FORMULAE: ${{needs.formulae_detect.outputs.testing_formulae}}
run: |
if [[ -z "$TESTING_FORMULAE" ]]
then
exit 0
fi
{
DATA_30="$(curl -s https://formulae.brew.sh/api/analytics/install/homebrew-core/30d.json)"
DATA_90="$(curl -s https://formulae.brew.sh/api/analytics/install/homebrew-core/90d.json)"
DATA_1="$(curl -s https://formulae.brew.sh/api/analytics/install/homebrew-core/365d.json)"
ERROR_DATA="$(curl -s https://formulae.brew.sh/api/analytics/build-error/30d.json)"
echo "### Analytics about: ${TESTING_FORMULAE}"
echo "<details><summary>Click to expand</summary>"
echo ""
echo "| Formula | Errors | 30d | 90d | 356d |"
echo "|---|---|---|---|---|"
for formula in ${TESTING_FORMULAE//,/ }
do
FORMULA_30="$(echo "$DATA_30" | jq -r ".formulae[\"$formula\"][0].count")"
FORMULA_90="$(echo "$DATA_90" | jq -r ".formulae[\"$formula\"][0].count")"
FORMULA_1="$(echo "$DATA_1" | jq -r ".formulae[\"$formula\"][0].count")"
FORMULA_ERROR="$(echo "$ERROR_DATA" | jq -r ".items[] | select(.formula == \"$formula\").count")"
echo "| $formula | $FORMULA_ERROR | $FORMULA_30 | $FORMULA_90 | $FORMULA_1 |"
done
echo "</details>"
} >> "$GITHUB_STEP_SUMMARY"
setup_tests:
permissions:
pull-requests: read
Expand Down

0 comments on commit 99e01c0

Please sign in to comment.