chore: clean up #54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test and Coverage | |
| on: | |
| push: | |
| branches: [ master, develop ] | |
| pull_request: | |
| branches: [ master, develop ] | |
| # Allow GitHub Pages deployment | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_OPTIONS: --enable-source-maps | |
| strategy: | |
| matrix: | |
| node-version: [18.x, 20.x, 22.x] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| echo "=== Installed package versions ===" | |
| npm list mocha c8 @types/mocha --depth=0 | |
| - name: Run Node.js tests | |
| run: npm test | |
| - name: Run tests with coverage | |
| if: matrix.node-version == '22.x' | |
| run: npm run test:cover | |
| - name: Upload coverage artifacts | |
| if: matrix.node-version == '22.x' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/lcov-report/ | |
| browser-test-chromium: | |
| runs-on: ubuntu-latest | |
| name: Browser Tests (Chromium) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Chromium system dependencies | |
| run: npx playwright install-deps chromium | |
| - name: Install Playwright Chromium | |
| run: npx playwright install chromium | |
| - name: Run Chromium browser tests | |
| run: npm run test:browser:chromium | |
| browser-test-firefox: | |
| runs-on: ubuntu-latest | |
| name: Browser Tests (Firefox) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Firefox system dependencies | |
| run: npx playwright install-deps firefox | |
| - name: Install Playwright Firefox | |
| run: npx playwright install firefox | |
| - name: Run Firefox browser tests | |
| run: npm run test:browser:firefox | |
| browser-test-webkit: | |
| runs-on: ubuntu-latest | |
| name: Browser Tests (WebKit) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install WebKit system dependencies | |
| run: npx playwright install-deps webkit | |
| - name: Install Playwright WebKit | |
| run: npx playwright install webkit | |
| - name: Run WebKit browser tests | |
| run: npm run test:browser:webkit | |
| coverage-summary: | |
| runs-on: ubuntu-latest | |
| needs: [test, browser-test-chromium, browser-test-firefox, browser-test-webkit] | |
| if: | | |
| github.ref == 'refs/heads/master' && | |
| github.event_name == 'push' && | |
| needs.test.result == 'success' && | |
| needs.browser-test-chromium.result == 'success' && | |
| needs.browser-test-firefox.result == 'success' && | |
| needs.browser-test-webkit.result == 'success' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22.x' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests with coverage | |
| run: npm run test:cover | |
| - name: Generate coverage badge data | |
| run: bash scripts/test-ci-badge.sh | |
| - name: Prepare GitHub Pages content | |
| run: | | |
| # Create a temporary directory for GitHub Pages | |
| mkdir -p pages-content | |
| # Copy the lcov-report content to the root of pages-content | |
| cp -r coverage/lcov-report/* pages-content/ | |
| # Also make raw coverage files available in a subdirectory | |
| mkdir -p pages-content/raw | |
| cp coverage/lcov.info pages-content/raw/ | |
| cp coverage/coverage-summary.json pages-content/raw/ | |
| cp coverage/coverage-badge.json pages-content/raw/ | |
| cp coverage/coverage-details.json pages-content/raw/ | |
| # Create a simple index redirect if needed (lcov-report/index.html becomes the main page) | |
| echo "GitHub Pages content prepared:" | |
| ls -la pages-content/ | |
| - name: Upload coverage reports | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: pages-content/ | |
| deploy-pages: | |
| if: github.ref == 'refs/heads/master' | |
| needs: coverage-summary | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |