www: show deployed commit hash in footer across production and staging builds#7258
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7258 +/- ##
==========================================
- Coverage 89.07% 89.07% -0.01%
==========================================
Files 538 538
Lines 41006 41020 +14
Branches 5557 5563 +6
==========================================
+ Hits 36526 36538 +12
- Misses 4472 4474 +2
Partials 8 8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
There was a problem hiding this comment.
Pull request overview
Adds deployment traceability to the www docs site by exposing the deployed git commit hash (short form) in the footer, and wires the deploy workflow to pass the commit SHA into the Vite build.
Changes:
- Add
getShortCommitHash()and conditionally render aCommit:line inFramewhenVITE_RECHARTS_COMMIT_HASHis present. - Wire the website deploy workflow to pass
GITHUB_SHAinto the website build asVITE_RECHARTS_COMMIT_HASH. - Add Vitest unit coverage for hash trimming/shortening and empty/undefined handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
www/src/layouts/Frame.tsx |
Adds commit-hash normalization helper and renders the deployed commit in the footer. |
www/test/layouts/Frame.spec.tsx |
Adds unit tests for commit hash trimming and 8-char truncation behavior. |
.github/workflows/deploy-website.yml |
Passes a commit SHA into the website build as a Vite env var for footer display. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function getShortCommitHash(commitHash: string | undefined): string | undefined { | ||
| const cleanedHash = commitHash?.trim(); | ||
|
|
||
| if (!cleanedHash) { | ||
| return undefined; | ||
| } | ||
|
|
||
| return cleanedHash.slice(0, 8); | ||
| } |
There was a problem hiding this comment.
getShortCommitHash is a pure string utility but it lives in Frame.tsx, which also has CSS side-effect imports and UI dependencies. This couples unit tests (and any future reuse) to the whole layout module and can slow/complicate testing/bundling. Consider moving this helper to a small utils module (e.g. www/src/utils/commitHash.ts) and importing it from both Frame and the test.
| <p> | ||
| Commit: <code title={fullCommitHash}>{shortCommitHash}</code> | ||
| </p> |
There was a problem hiding this comment.
The displayed hash is trimmed, but the tooltip uses the untrimmed fullCommitHash. If the env var ever includes surrounding whitespace, the tooltip and displayed value will disagree. Consider using the same cleaned value for the title (or trimming fullCommitHash before passing it through).
| - name: Build website | ||
| working-directory: www | ||
| run: VITE_RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` npm run build | ||
| run: VITE_RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` VITE_RECHARTS_COMMIT_HASH=${GITHUB_SHA} npm run build |
There was a problem hiding this comment.
VITE_RECHARTS_COMMIT_HASH=${GITHUB_SHA} may not always reflect the commit actually checked out/built (notably for workflow_run, where the desired revision is often github.event.workflow_run.head_sha, and more generally if the checkout ref changes). To guarantee the footer shows the deployed revision, consider deriving the hash from the checked-out repo (e.g. git rev-parse HEAD) or explicitly using the workflow_run head SHA.
| run: VITE_RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` VITE_RECHARTS_COMMIT_HASH=${GITHUB_SHA} npm run build | |
| run: VITE_RECHARTS_LATEST_VERSION=`curl -X GET "https://registry.npmjs.org/recharts/latest" | jq --raw-output '.version'` VITE_RECHARTS_COMMIT_HASH=$(git rev-parse HEAD) npm run build |
Bundle ReportBundle size has no change ✅ |
PavelVanecek
left a comment
There was a problem hiding this comment.
The staging deployment doesn't show the commit hash. Please check if there's one more CI script that needs an update.
Updated CI staging/canary website build to pass the commit hash env var too ( |
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
git rev-parse HEADwith${{ github.event.pull_request.head.sha || github.sha }}in the website build step so the displayed commit hash matches the PR branch tip, not the ephemeral merge commit