Skip to content

feat: add RootRoute component for authentication handling and update …#6

Merged
aintnier merged 1 commit intomainfrom
responsive
Jul 24, 2025
Merged

feat: add RootRoute component for authentication handling and update …#6
aintnier merged 1 commit intomainfrom
responsive

Conversation

@aintnier
Copy link
Copy Markdown
Owner

@aintnier aintnier commented Jul 24, 2025

…App routing

feat: add GitHub Actions Pipeline ci.yml file

Summary 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:

  • Add RootRoute component that checks user authentication and redirects to Dashboard or landing page
  • Replace root route in App.js to use RootRoute for handling authentication logic at '/' path
  • Introduce a comprehensive GitHub Actions CI pipeline (ci.yml) with setup, lint, frontend/backend tests, security scans, Amplify validation, and summary

CI:

  • Add GitHub Actions workflow configuration for continuous integration

Documentation:

  • Add .github/README.md with detailed documentation of the CI pipeline workflow

…App routing

feat: add GitHub Actions Pipeline `ci.yml` file
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Jul 24, 2025

Reviewer's Guide

This 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 path

sequenceDiagram
  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
Loading

Class diagram for the new RootRoute component

classDiagram
  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
Loading

File-Level Changes

Change Details Files
Introduce RootRoute component for authentication handling and update App routing
  • Create RootRoute that checks the logged-in user, tracks loading state, and redirects or renders Dashboard accordingly
  • Replace the root "/" route in App.js to use instead of wrapping Dashboard in ProtectedRoute
  • Import RootRoute and remove unnecessary ProtectedRoute wrapper for the root path
src/components/RootRoute.js
src/App.js
Add GitHub Actions CI pipeline and documentation
  • Add .github/workflows/ci.yml defining setup, lint, frontend/backend tests, security scan, Amplify validation, and summary jobs
  • Configure Node.js and pnpm setup, caching, ESLint, Prettier, Jest tests with coverage upload, npm audit, trufflehog scanning, and Amplify project checks
  • Include .github/README.md detailing pipeline triggers, job descriptions, artifacts, troubleshooting, and future extensions
.github/workflows/ci.yml
.github/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@aintnier aintnier requested a review from Copilot July 24, 2025 16:31
Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

Copy link
Copy Markdown

Copilot AI left a comment

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 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;
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
if (checking) return null;
if (checking) return <div className="loading-spinner">Loading...</div>;

Copilot uses AI. Check for mistakes.
Comment on lines +328 to +336
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
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

Mixed language in GitHub Actions summary. Consider using English: 'Managed automatically by AWS Amplify on every push to main'

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines +332 to +336
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
Copy link

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

Mixed language in GitHub Actions summary. Consider using English: 'CI Pipeline completed successfully!'

Suggested change
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

Copilot uses AI. Check for mistakes.
@aintnier aintnier merged commit 9a7e9fe into main Jul 24, 2025
6 of 7 checks passed
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