Skip to content

fix: make homepage metrics deployment reliable - #71

Merged
loverustfs merged 1 commit into
mainfrom
codex/fix-homepage-stats
Aug 2, 2026
Merged

fix: make homepage metrics deployment reliable#71
loverustfs merged 1 commit into
mainfrom
codex/fix-homepage-stats

Conversation

@loverustfs

Copy link
Copy Markdown
Contributor

fix: make homepage metrics deployment reliable

Copilot AI review requested due to automatic review settings August 2, 2026 00:54
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
rustfs-com 1ea3bfc Commit Preview URL

Branch Preview URL
Aug 01 2026, 05:18 PM

@vercel

vercel Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rustfs-com Ready Ready Preview Aug 2, 2026 12:54am

@loverustfs
loverustfs merged commit 573ed51 into main Aug 2, 2026
4 checks passed
@loverustfs
loverustfs deleted the codex/fix-homepage-stats branch August 2, 2026 00:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make homepage metrics collection more reliable during deployments by injecting pre-fetched GitHub/Docker metrics into the build, increasing fetch timeouts, and optionally failing the build if live metrics cannot be obtained.

Changes:

  • Add a CI script to fetch GitHub + Docker Hub metrics and export them via GITHUB_ENV.
  • Allow lib/github.ts and lib/docker.ts to consume injected metrics from environment variables, with updated fallback behavior and stricter failure mode when required.
  • Update the deploy workflow to fetch metrics before building and enforce live-metrics requirements during the build step.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
scripts/fetch-homepage-metrics.sh New script to fetch metrics from GitHub GraphQL + Docker Hub API and inject them into subsequent workflow steps.
lib/github.ts Adds injected-metrics support and a shared fallback; can hard-fail when live metrics are required.
lib/docker.ts Adds injected-metrics support, fallback constants, longer timeouts, and optional hard-fail behavior.
.github/workflows/deploy.yml Runs the metrics fetch step before build and sets REQUIRE_LIVE_HOMEPAGE_METRICS during the build.
Suppressed comments (1)

scripts/fetch-homepage-metrics.sh:27

  • These jq guards treat a metric value of 0 as invalid ("> 0"), but 0 is a valid count for stars/forks/commits/pulls (e.g., a new repo). This can cause the workflow to fail unnecessarily.
stars="$(jq -er '.data.repository.stargazerCount | if type == "number" and . > 0 then . else error("invalid stars") end' <<<"${github_metrics}")"
forks="$(jq -er '.data.repository.forkCount | if type == "number" and . > 0 then . else error("invalid forks") end' <<<"${github_metrics}")"
commits="$(jq -er '.data.repository.defaultBranchRef.target.history.totalCount | if type == "number" and . > 0 then . else error("invalid commits") end' <<<"${github_metrics}")"
docker_pulls="$(jq -er '.results[] | select(.name == "rustfs") | .pull_count | if type == "number" and . > 0 then . else error("invalid Docker pulls") end' <<<"${docker_metrics}")"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +11 to +14
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "User-Agent: RustFS-Website" \
--data-binary '{"query":"query { repository(owner: \"rustfs\", name: \"rustfs\") { stargazerCount forkCount defaultBranchRef { target { ... on Commit { history { totalCount } } } } } }"}' \
Comment thread lib/docker.ts
Comment on lines +13 to +16
const injectedPulls = Number(injectedPullsValue);
if (Number.isInteger(injectedPulls) && injectedPulls > 0) {
return injectedPulls;
}
Comment thread lib/github.ts
commits: Number(injectedMetricValues[2]),
};

if (Object.values(injectedMetrics).every((value) => Number.isInteger(value) && value > 0)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants