feat: add RootRoute component for authentication handling and update …#6
feat: add RootRoute component for authentication handling and update …#6
Conversation
…App routing feat: add GitHub Actions Pipeline `ci.yml` file
Reviewer's GuideThis PR centralizes authentication logic by introducing a new RootRoute component and updating App routing to use it, and establishes a robust GitHub Actions CI pipeline (with linting, frontend/backend tests, security and Amplify validation) along with accompanying documentation. Sequence diagram for RootRoute authentication check on root pathsequenceDiagram
actor User
participant RootRoute
participant getLoggedUser
participant Dashboard
participant Navigate
User->>RootRoute: Accesses "/"
RootRoute->>getLoggedUser: Check if user is logged in
getLoggedUser-->>RootRoute: Return user or null
alt User is authenticated
RootRoute->>Dashboard: Render Dashboard
else User is not authenticated
RootRoute->>Navigate: Redirect to /landing
end
Class diagram for the new RootRoute componentclassDiagram
class RootRoute {
- checking: boolean
- isAuthenticated: boolean
+ useEffect()
+ render()
}
class Dashboard
class Navigate
class getLoggedUser
RootRoute --> Dashboard : renders if authenticated
RootRoute --> Navigate : redirects if not authenticated
RootRoute ..> getLoggedUser : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds authentication routing improvements and establishes a comprehensive CI/CD pipeline. The changes introduce a new RootRoute component to handle authentication-based navigation and implements a robust GitHub Actions workflow for continuous integration.
- Replace hardcoded protected route with dynamic authentication checking
- Add comprehensive CI pipeline with linting, testing, security scanning, and Amplify validation
- Include detailed documentation for the CI/CD workflow setup
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/components/RootRoute.js | New component that checks authentication status and redirects users appropriately |
| src/App.js | Updated root route to use RootRoute component instead of ProtectedRoute wrapper |
| .github/workflows/ci.yml | Comprehensive CI pipeline with parallel jobs for code quality, testing, and validation |
| .github/README.md | Detailed documentation explaining the CI pipeline configuration and usage |
| checkAuth(); | ||
| }, []); | ||
|
|
||
| if (checking) return null; |
There was a problem hiding this comment.
Returning null during authentication check provides no feedback to users with screen readers or those with slow connections. Consider showing a loading indicator or spinner component instead.
| if (checking) return null; | |
| if (checking) return <div className="loading-spinner">Loading...</div>; |
| echo "**ℹ️ Build & Deploy**: Gestiti automaticamente da AWS Amplify ad ogni push su \`main\`" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
|
|
||
| if [[ "${{ needs.lint.result }}" == "success" && "${{ needs.test-frontend.result }}" == "success" ]]; then | ||
| echo "✅ **Pipeline CI completata con successo!**" >> $GITHUB_STEP_SUMMARY | ||
| echo "🚀 **Codice pronto per il deploy automatico Amplify**" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "❌ **Pipeline CI fallita. Controlla i job sopra.**" >> $GITHUB_STEP_SUMMARY | ||
| echo "⚠️ **Il deploy Amplify potrebbe fallire se ci sono errori critici**" >> $GITHUB_STEP_SUMMARY |
There was a problem hiding this comment.
Mixed language in GitHub Actions summary. Consider using English: 'Managed automatically by AWS Amplify on every push to main'
| echo "**ℹ️ Build & Deploy**: Gestiti automaticamente da AWS Amplify ad ogni push su \`main\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ needs.lint.result }}" == "success" && "${{ needs.test-frontend.result }}" == "success" ]]; then | |
| echo "✅ **Pipeline CI completata con successo!**" >> $GITHUB_STEP_SUMMARY | |
| echo "🚀 **Codice pronto per il deploy automatico Amplify**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **Pipeline CI fallita. Controlla i job sopra.**" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Il deploy Amplify potrebbe fallire se ci sono errori critici**" >> $GITHUB_STEP_SUMMARY | |
| echo "**ℹ️ Build & Deploy**: Managed automatically by AWS Amplify on every push to \`main\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [[ "${{ needs.lint.result }}" == "success" && "${{ needs.test-frontend.result }}" == "success" ]]; then | |
| echo "✅ **CI Pipeline completed successfully!**" >> $GITHUB_STEP_SUMMARY | |
| echo "🚀 **Code ready for automatic Amplify deployment**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **CI Pipeline failed. Check the jobs above.**" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Amplify deployment might fail if there are critical errors**" >> $GITHUB_STEP_SUMMARY |
| echo "✅ **Pipeline CI completata con successo!**" >> $GITHUB_STEP_SUMMARY | ||
| echo "🚀 **Codice pronto per il deploy automatico Amplify**" >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "❌ **Pipeline CI fallita. Controlla i job sopra.**" >> $GITHUB_STEP_SUMMARY | ||
| echo "⚠️ **Il deploy Amplify potrebbe fallire se ci sono errori critici**" >> $GITHUB_STEP_SUMMARY |
There was a problem hiding this comment.
Mixed language in GitHub Actions summary. Consider using English: 'CI Pipeline completed successfully!'
| echo "✅ **Pipeline CI completata con successo!**" >> $GITHUB_STEP_SUMMARY | |
| echo "🚀 **Codice pronto per il deploy automatico Amplify**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **Pipeline CI fallita. Controlla i job sopra.**" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Il deploy Amplify potrebbe fallire se ci sono errori critici**" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ **CI Pipeline completed successfully!**" >> $GITHUB_STEP_SUMMARY | |
| echo "🚀 **Code ready for automatic Amplify deployment**" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ **CI Pipeline failed. Check the jobs above.**" >> $GITHUB_STEP_SUMMARY | |
| echo "⚠️ **Amplify deployment might fail if there are critical errors**" >> $GITHUB_STEP_SUMMARY |
…App routing
feat: add GitHub Actions Pipeline
ci.ymlfileSummary by Sourcery
Add RootRoute component for root-level authentication handling and update App routing to use it, and introduce a full-featured GitHub Actions CI pipeline along with accompanying documentation.
New Features:
CI:
Documentation: