New staging deployment pipeline#6748
Conversation
WalkthroughCI workflow Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant GH as GitHub Actions
participant Build as build_test_pack
participant VR as vr_tests
participant Art as Artifact Storage
participant Pages as gh-pages branch
participant PR as Pull Request (comments)
GH->>Build: start build_test_pack (calc BASE_URL)
Build->>Build: build website with BASE_URL
Build->>Art: upload website-build artifact
GH->>VR: run vr_tests
VR->>Art: upload VR report artifact
GH->>Pages: start deploy_staging (checkout gh-pages)
Pages->>Art: download website-build + VR artifacts
Pages->>Pages: cleanup old PR deployments
Pages->>Pages: create/overwrite pr-<n> or canary directories with artifacts
Pages->>Pages: commit & push changes to gh-pages
Pages->>PR: post comment with staging URLs
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45–60 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (3)**/*.{ts,tsx}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{js,ts,tsx}📄 CodeRabbit inference engine (CONTRIBUTING.md)
Files:
**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (DEVELOPING.md)
Files:
🧠 Learnings (1)📓 Common learnings⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
.github/workflows/ci.yml(2 hunks).github/workflows/deploy-staging.yml(0 hunks)
💤 Files with no reviewable changes (1)
- .github/workflows/deploy-staging.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build, Test, Pack
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
.github/workflows/ci.yml (3)
89-102: BASE_URL calculation and propagation looks good.The conditional logic correctly differentiates PR and canary deployments, and the environment variable is properly scoped to the website build. This will align with the deploy_staging step's directory structure.
253-266: VR test artifact and failure handling is well-structured.The
continue-on-errorpattern combined with unconditional artifact upload and explicit job failure ensures reports are captured while preventing failed VR tests from proceeding. The workflow correctly gates on test failures.
104-109: Remove this concern—artifact retention and deployment cleanup operate independently.The website artifact is downloaded and deployed to the
gh-pagesbranch during the same workflow run (thedeploy_stagingjob runs immediately afterbuild_test_packcompletes). The cleanup script at line 298-299 removes old directories from thegh-pagesrepository using filesystem operations (find . -mtime +30), not GitHub artifacts. Since deployment occurs within the artifact's 14-day window, and the files persist in the git repository after deployment, there is no risk of missing artifacts when the 30-day cleanup runs.
| deploy_staging: | ||
| name: Deploy to Staging | ||
| needs: [build_test_pack, vr_tests] | ||
| if: needs.build_test_pack.result == 'success' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| steps: |
There was a problem hiding this comment.
Critical: deploy_staging condition doesn't gate on VR test failures.
The job depends on vr_tests (line 270) but the condition (line 271) only checks needs.build_test_pack.result == 'success'. When VR tests fail, the vr_tests job outcome is 'failure', but this is not checked in the condition, so deploy_staging will still run and deploy sites with failed tests.
Update the condition to explicitly check both jobs:
- if: needs.build_test_pack.result == 'success'
+ if: needs.build_test_pack.result == 'success' && needs.vr_tests.result == 'success'Alternatively, if deployments should proceed regardless of VR test status, remove the vr_tests dependency and clarify the intent in a comment.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| deploy_staging: | |
| name: Deploy to Staging | |
| needs: [build_test_pack, vr_tests] | |
| if: needs.build_test_pack.result == 'success' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| deploy_staging: | |
| name: Deploy to Staging | |
| needs: [build_test_pack, vr_tests] | |
| if: needs.build_test_pack.result == 'success' && needs.vr_tests.result == 'success' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: |
🤖 Prompt for AI Agents
.github/workflows/ci.yml around lines 268 to 276: the deploy_staging job
currently only gates on needs.build_test_pack.result == 'success' while still
declaring a dependency on vr_tests, so deployments can proceed even if VR tests
failed; update the if condition to explicitly require both successes (e.g.,
needs.build_test_pack.result == 'success' && needs.vr_tests.result == 'success')
so deploy_staging only runs when both jobs pass, or if the intent is to deploy
regardless, remove vr_tests from the needs array and add a comment clarifying
that VR failures should not block deployment.
There was a problem hiding this comment.
This is intentional. Failed VR tests will still produce the HTML report that we want to upload.
There was a problem hiding this comment.
@PavelVanecek, thank you for clarifying the intention! I understand you want to deploy the staging site with the VR report even when tests fail, so the report can be reviewed.
However, there's a subtle issue with the current implementation. In GitHub Actions, when a job in the needs array fails, dependent jobs are skipped by default, even if the if condition doesn't explicitly check that job's result. Since the vr_tests job will fail when tests fail (due to the "Fail workflow if tests failed" step on line 263), the deploy_staging job will be skipped.
To achieve your intended behavior, you need to explicitly allow deploy_staging to run when vr_tests fails:
if: always() && needs.build_test_pack.result == 'success' && (needs.vr_tests.result == 'success' || needs.vr_tests.result == 'failure')This ensures:
- The job always evaluates the condition (via
always()) - It only runs if the build succeeds
- It runs regardless of whether VR tests pass or fail
- It still skips if vr_tests is cancelled or skipped
Would you like me to create an issue to track this fix?
✏️ Learnings added
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6748
File: .github/workflows/ci.yml:268-276
Timestamp: 2025-12-07T01:38:46.677Z
Learning: In the recharts/recharts repository, the staging deployment pipeline should deploy the website and VR test report even when VR tests fail, so that the HTML report can be reviewed. This requires using `if: always() && needs.build_test_pack.result == 'success' && (needs.vr_tests.result == 'success' || needs.vr_tests.result == 'failure')` in the deploy_staging job condition.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
🧠 Learnings used
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-06T03:36:59.377Z
Learning: Applies to test-vr/__snapshots__/** : Visual regression test snapshots should be committed to the repository
| - name: Comment on PR | ||
| if: github.event_name == 'pull_request' | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| PR_NUMBER=${{ github.event.pull_request.number }} | ||
| WEBSITE_URL="https://recharts.github.io/recharts/pr-$PR_NUMBER/www/" | ||
| REPORT_URL="https://recharts.github.io/recharts/pr-$PR_NUMBER/vr-tests/" | ||
|
|
||
| COMMENT_BODY=$(cat <<EOF | ||
| **Staging Deployment Details** | ||
|
|
||
| - **Website:** $WEBSITE_URL | ||
| - **Test Report:** $REPORT_URL | ||
|
|
||
| *These deployments will remain available for 30 days.* | ||
| EOF | ||
| ) | ||
| gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" | ||
|
|
||
| - name: Fail workflow if tests failed | ||
| # This step ensures that the entire job fails if the VR tests have failed. | ||
| # This is necessary because of `continue-on-error: true` in the test step. | ||
| # A failing job will block the PR from being merged. | ||
| if: steps.vr_test_step.outcome == 'failure' | ||
| run: exit 1 | ||
|
|
There was a problem hiding this comment.
PR comment assumes successful deployment.
The "Comment on PR" step posts staging URLs unconditionally, but it runs after the deploy step. If the deploy step fails (git push, etc.), the comment will still post URLs pointing to non-existent or stale deployments, creating a poor user experience.
Add a condition to only comment if the deploy step succeeded, or add a check within the script:
- name: Comment on PR
if: github.event_name == 'pull_request'
+ # Add a condition to ensure deploy succeeded before commentingAlternatively, validate that the deployment completed before posting the URLs.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
.github/workflows/ci.yml around lines 327 to 345: the "Comment on PR" step posts
staging URLs unconditionally even when the deploy may have failed; modify the
job so the comment runs only on successful deploy (e.g., add an if: ${{
success() }} or if: ${{ needs.deploy_job.result == 'success' }} conditioned on
the deploy job name), or add a lightweight runtime check before posting (curl
the WEBSITE_URL/REPORT_URL or verify the deploy job outputs a success
flag/artifact and only proceed if the check passes); update the step to bail out
(or post a failure note) when the deployment verification fails.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6748 +/- ##
==========================================
- Coverage 93.96% 93.90% -0.06%
==========================================
Files 504 512 +8
Lines 42177 42462 +285
Branches 4925 4974 +49
==========================================
+ Hits 39633 39876 +243
- Misses 2539 2581 +42
Partials 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bundle ReportChanges will increase total bundle size by 24.11kB (0.91%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: recharts/bundle-es6Assets Changed:
view changes for bundle: recharts/bundle-cjsAssets Changed:
view changes for bundle: recharts/bundle-umdAssets Changed:
|
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
|
Almost there |
|
Staging Deployment Details
These deployments will remain available for 30 days. To update snapshots: Comment |
Motivation and Context
This way we get VR test results, and the website deployed on every PR.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.