Skip to content

Conversation

jhodapp
Copy link
Member

@jhodapp jhodapp commented Sep 19, 2025

Description

Restructure frontend GitHub Actions workflows to match the sophisticated backend architecture, implementing a 3-stage pipeline with advanced caching strategies, quality gates, and enhanced security features while removing ARM64
builds.

This change transforms our frontend CI/CD from basic single-job architecture to the proven backend pattern of lint → test → docker with dependency gates, significantly improving build performance and developer experience.

GitHub Issue: None

Changes

  • Restructured Non-Production Workflow: Implemented 3-stage pipeline (linttestdocker) with quality gates
  • Enhanced Production Workflow: Added build/test validation before Docker operations with quality gates
  • Advanced Multi-Layer Caching:
    • Job-specific node_modules caching with intelligent fallback chains
    • Next.js build cache for incremental builds
    • Playwright browser binary caching
    • Docker layer caching with job-specific scopes
  • Removed ARM64 Support: Now builds only for linux/amd64 architecture
  • Enhanced Security & Metadata:
    • Comprehensive OCI labels for container traceability
    • Dual tagging for non-production (latest + {git-sha})
    • Production Cosign signing and SBOM generation
  • Fixed ESLint Integration: Corrected Next.js lint command (removed invalid --cache flag)

Screenshots / Videos Showing UI Changes (if applicable)

N/A - Infrastructure changes only

Testing Strategy

  • ✅ Verify workflows run successfully in GitHub Actions
  • ✅ Confirm lint job provides fast feedback (~2 minutes vs ~10 minutes)
  • ✅ Validate test job completes with cached dependencies
  • ✅ Ensure Docker job only runs after successful lint + test validation
  • ✅ Check container images are properly tagged and signed (production)
  • ✅ Verify cache performance improvements in subsequent runs

Concerns

  • Cache Strategy: New multi-layer caching approach may require monitoring for cache hit rates and storage usage

@jhodapp jhodapp added this to the 1.0.0-beta2 milestone Sep 19, 2025
@jhodapp jhodapp self-assigned this Sep 19, 2025
@jhodapp jhodapp added the enhancement Improves existing functionality or feature label Sep 19, 2025
@jhodapp jhodapp added the infrastructure DevOps related label Sep 19, 2025
@jhodapp jhodapp moved this to 🏗 In progress in Refactor Coaching Platform Sep 19, 2025
@jhodapp jhodapp requested a review from lmcdonough September 19, 2025 14:48
@jhodapp jhodapp marked this pull request as ready for review September 19, 2025 14:54
- Add .dockerignore to reduce Docker build context size
- Optimize cache keys to exclude generated files and target source files only
- Add separate cache scopes for lint/test/production isolation
- Add cross-job cache fallback strategies for better hit rates

Expected improvements:
- Workflow-only changes should now hit ~90% cache
- Docker builds exclude unnecessary .github/, .next/, coverage/ files
- Cache keys focus on src/ files instead of all JS/TS files
- Better cache isolation prevents cross-contamination
- Use official Next.js GitHub Actions caching recommendations
- Cache ~/.npm and .next/cache paths as per Vercel guidelines
- Upgrade to actions/cache@v4 for better performance
- Simplify cache keys to match official patterns
- Remove separate node_modules caching in favor of npm cache
- Maintain cross-job fallback strategies for cache efficiency

This follows the exact caching strategy recommended in:
https://nextjs.org/docs/app/guides/ci-build-caching#github-actions
- Use .next/cache path instead of ${{ github.workspace }}/.next/cache
- Remove ~/.npm caching (redundant with setup-node cache: 'npm')
- Use shared cache key across jobs for better efficiency
- Next.js requires exact .next/cache path relative to working directory

This should resolve the 'No build cache found' warning and enable
proper incremental builds in CI.
Resolves cache conflicts between parallel lint and test jobs by:
- Adding job-specific prefixes: nextjs-lint, nextjs-test, nextjs-prod
- Maintaining fallback chains for cache sharing across job types
- Prevents "Unable to reserve cache" errors during parallel execution

Cache keys now unique per job while preserving cross-job optimization.
- Remove .github/workflows/node.js.yml (redundant with modern workflow)
- Fix npm run ci → npm ci in production workflow
- Eliminates duplicate CI jobs and cache conflicts
- Modern workflow provides linting, caching, and Docker deployment
Copy link
Contributor

@lmcdonough lmcdonough left a comment

Choose a reason for hiding this comment

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

Looks good! I just added a couple small comments to bump actions versions, adjust remove unused caching, and add concurrency cancelation which is standard best practice.

- Update GitHub Actions workflows to use Node.js 24.x
- Upgrade actions/setup-node from v3 to v5 for latest features
- Update Dockerfile from node:22-alpine3.19 to node:24-alpine
- Add .nvmrc file for local development consistency
- Update @types/node to ^24.0.0 in package.json

Ensures compatibility with GitHub's Node.js 20 deprecation timeline.
ESLint only analyzes source code and doesn't use .next/cache build output.
Keeps cache in test job where npm run build actually runs.

Co-authored-by: lmcdonough
Updates to latest stable version for improved security and compatibility
with current Docker registry APIs.
Prevents resource waste by cancelling outdated CI runs when new commits
are pushed to the same branch/PR. Improves CI efficiency and reduces
queue times for latest changes.

Co-authored-by: lmcdonough
Ensures npm cache properly invalidates when package-lock.json changes
by explicitly specifying the lockfile path instead of relying on
auto-detection heuristics.

Co-authored-by: lmcdonough
Keeps eslint-config-next synchronized with Next.js 15.4.7 for
optimal compatibility while maintaining stable ESLint 8.57.1.
@jhodapp
Copy link
Member Author

jhodapp commented Sep 21, 2025

@lmcdonough Thanks for your review. All changes have been made and it's working even better thanks to your excellent suggestions.

Ready for a last quick look and approval if it looks good to you.

@jhodapp jhodapp moved this from 🏗 In progress to Review in Refactor Coaching Platform Sep 21, 2025
Copy link
Contributor

@lmcdonough lmcdonough left a comment

Choose a reason for hiding this comment

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

Looks good, great job man!

@jhodapp jhodapp changed the title Remove amd64 builds since we don't need them currently Remove arm64 builds since we don't need them currently Sep 21, 2025
@jhodapp jhodapp changed the title Remove arm64 builds since we don't need them currently Remove arm64 builds Sep 21, 2025
@jhodapp jhodapp merged commit 163e25a into main Sep 21, 2025
6 checks passed
@jhodapp jhodapp deleted the remove_arm64_builds branch September 21, 2025 20:33
@github-project-automation github-project-automation bot moved this from Review to ✅ Done in Refactor Coaching Platform Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improves existing functionality or feature infrastructure DevOps related
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants