# Railtrack Pro - Gitea Actions CI/CD Workflow # Runs automated tests on push to main and pull requests # Follows TDD approach for quality assurance name: Railtrack Pro Tests on: push: branches: - main pull_request: branches: - main jobs: test: name: Run Test Suite runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install Dependencies run: npm ci - name: Install Playwright Browsers run: npx playwright install --with-deps chromium - name: Run Jest Unit Tests run: npm run test:unit - name: Run Playwright E2E Tests run: npm run test:e2e timeout-minutes: 10 - name: Generate Coverage Report run: npm run test:coverage - name: Upload Coverage Report uses: actions/upload-artifact@v4 if: always() with: name: coverage-report path: coverage/ retention-days: 30 - name: Upload Test Results uses: actions/upload-artifact@v4 if: always() with: name: playwright-report path: playwright-report/ retention-days: 30 lint: name: Code Quality Check runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install Dependencies run: npm ci - name: Verify Code Structure run: | echo "Verifying project structure..." test -f index.html || exit 1 test -d js/ || exit 1 test -d css/ || exit 1 test -d test/ || exit 1 echo "✓ Project structure valid" coverage: name: Code Coverage Check runs-on: ubuntu-latest steps: - name: Checkout Repository uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' cache: 'npm' - name: Install Dependencies run: npm ci - name: Generate Coverage run: npm run test:coverage - name: Display Coverage Summary run: | echo "# Code Coverage Summary" >> $GITHUB_STEP_SUMMARY echo "" >> $GITHUB_STEP_SUMMARY cat coverage/coverage-summary.json | grep -E '"total"' | awk -F'[,}]' '{print "### "$1": "$NF"%"}' >> $GITHUB_STEP_SUMMARY - name: Fail if Coverage Below Threshold run: | COVERAGE=$(cat coverage/coverage-summary.json | grep -o '"statements": [0-9.]*' | grep -o '[0-9.]*') if (( $(echo "$COVERAGE < 80" | bc -l) )); then echo "❌ Coverage below 80% threshold: ${COVERAGE}%" exit 1 fi echo "✅ Coverage above 80% threshold: ${COVERAGE}%"