Overview
The Product Distribution Dashboard uses GitHub Actions for automated testing, code quality analysis, and validation. The CI/CD pipeline is organized into PR validation workflows and main branch workflows.PR Validation Orchestrator
The main PR validation workflow (pr-validation.yml) orchestrates all checks when a pull request is created or updated.
Change Detection
The workflow uses path filtering to run only relevant checks:- Only runs workflows affected by changes
- Reduces CI time and resource usage
- Provides faster feedback to developers
PR Gate
The PR gate job ensures all required workflows pass before allowing merge:Frontend Analysis Workflow
File:.github/workflows/pr-frontend-analysis.yml
Trigger: Called by PR validation workflow when frontend changes detected
Steps
-
Environment Setup
- Checkout code
- Set up Node.js 20
- Cache npm dependencies based on
package-lock.json
-
Dependency Installation
-
Code Quality Checks
- ESLint:
npm run lint - Prettier:
npm run format:check
- ESLint:
-
Build Verification
./frontend
Backend Test & Sonar Workflow
File:.github/workflows/pr-backend-test-and-sonar.yml
Trigger: Called by PR validation workflow when backend changes detected
Job 1: Backend Tests
Runs unit and integration tests with code coverage:- Java 17 (Temurin distribution)
- Maven cache enabled
- Working directory:
./backend
- JaCoCo coverage reports uploaded to
jacoco-coverage - Retained for 1 day
- Path:
backend/target/site/jacoco/
Job 2: Backend Sonar Analysis
Performs static code analysis using SonarCloud: Prerequisites:- Requires
backend-testsjob to complete - Downloads JaCoCo coverage reports
- Checkout with full git history (
fetch-depth: 0) - Set up Java 17
- Cache Sonar packages
- Run Sonar scanner:
GITHUB_TOKEN: Automatic GitHub tokenSONAR_TOKEN: SonarCloud authentication (secret)
Data Validation Workflow
File:.github/workflows/pr-data-validation.yml
Trigger: Called by PR validation workflow when data changes detected
Validates the structure and integrity of JSON data files across three environments:
Job 1: Validate Current Folder
Required Files:products.jsonwarehouses.jsonstores.json
- Exactly 3 files present
- All required files exist
- Valid JSON syntax
Job 2: Validate Test Folder
Same validations as current folder fordata/test/ directory.
Job 3: Validate Archive Folder
Special Requirements:- Must contain multiple of 3 files
- Files must follow naming pattern:
{base}_v{number}.json - Versions must be consecutive starting from v1
- Valid JSON syntax for all files
Main Branch Workflows
Backend Sonar Analysis
File:.github/workflows/main-backend-sonar.yml
Triggers:
- Push to
mainbranch - Changes to:
backend/**.github/workflows/main-backend-sonar.ymlrender.yaml
- Manual workflow dispatch
- Full git history fetch for accurate blame information
- Java 17 with Maven cache
- Sonar package caching
- Combined test execution and analysis
- Maintains code quality metrics on main branch
- Tracks quality trends over time
- Provides baseline for PR comparisons
Workflow Triggers Summary
| Workflow | Trigger | Path Filters |
|---|---|---|
| PR Validation | pull_request | All paths |
| Frontend Analysis | workflow_call | frontend/** |
| Backend Test & Sonar | workflow_call | backend/** |
| Data Validation | workflow_call | data/** |
| Main Backend Sonar | push to main | backend/**, render.yaml |
Required Secrets
Configure these secrets in GitHub repository settings:SONAR_TOKEN: SonarCloud authentication token- Generate from SonarCloud account settings
- Required for both PR and main branch analysis
Manual Workflow Execution
All workflows support manual triggering viaworkflow_dispatch:
- Go to Actions tab in GitHub
- Select workflow from left sidebar
- Click Run workflow button
- Select branch and confirm
Best Practices
For Developers
- Run locally first: Execute
npm run lintandmvn verifybefore pushing - Check workflow results: Review failed checks and fix issues promptly
- Keep PRs focused: Smaller PRs trigger fewer workflows and get faster feedback
For Maintainers
- Monitor workflow duration: Optimize if workflows take too long
- Update dependencies: Keep actions and tools up to date
- Review failed workflows: Investigate and fix flaky tests
- Cache effectively: Ensure dependency caching is working
Troubleshooting
Workflow Not Triggered
Issue: PR created but workflows not running Solutions:- Check if changes match path filters
- Verify workflow files are in
.github/workflows/ - Ensure GitHub Actions is enabled for repository
SonarCloud Analysis Failed
Issue: Backend Sonar job fails Solutions:- Verify
SONAR_TOKENsecret is configured - Check SonarCloud organization and project key in
pom.xml - Ensure JaCoCo reports are generated
Data Validation Failed
Issue: JSON validation errors Solutions:- Validate JSON syntax using
python3 -m json.tool file.json - Check file names match expected patterns
- Verify archive versions are consecutive
Frontend Build Failed
Issue: Angular build errors Solutions:- Run
npm cilocally to ensure clean install - Check for TypeScript compilation errors
- Verify all dependencies are in
package.json