feat: Add XML and console output test result parsers #21
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: CI | |
| on: | |
| push: | |
| branches: [master] | |
| pull_request: | |
| branches: [master] | |
| permissions: | |
| contents: write | |
| jobs: | |
| test: | |
| name: Test & Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests with coverage | |
| run: npx vitest run --coverage | |
| - name: Generate Coverage Badge | |
| run: | | |
| if [ ! -f coverage/coverage-summary.json ]; then | |
| echo "Error: coverage/coverage-summary.json not found" | |
| echo "Coverage report was not generated by vitest" | |
| exit 1 | |
| fi | |
| COVERAGE=$(node -e " | |
| const summary = require('./coverage/coverage-summary.json'); | |
| let pct = summary.total.lines.pct; | |
| if (pct <= 1) pct = pct * 100; | |
| console.log(pct.toFixed(2)); | |
| ") | |
| echo "Coverage: ${COVERAGE}%" | |
| COLOR="red" | |
| if (( $(echo "$COVERAGE >= 90" | bc -l) )); then COLOR="brightgreen" | |
| elif (( $(echo "$COVERAGE >= 80" | bc -l) )); then COLOR="green" | |
| elif (( $(echo "$COVERAGE >= 70" | bc -l) )); then COLOR="yellowgreen" | |
| elif (( $(echo "$COVERAGE >= 60" | bc -l) )); then COLOR="yellow" | |
| elif (( $(echo "$COVERAGE >= 50" | bc -l) )); then COLOR="orange" | |
| fi | |
| mkdir -p .badges | |
| cat > .badges/coverage.json << EOF | |
| { | |
| "schemaVersion": 1, | |
| "label": "Coverage", | |
| "message": "${COVERAGE}%", | |
| "color": "${COLOR}" | |
| } | |
| EOF | |
| - name: Verify badge files exist | |
| run: | | |
| echo "Checking badge files..." | |
| ls -la .badges/ | |
| test -f .badges/coverage.json | |
| echo "All badge files present" | |
| - name: Upload badges | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: badges | |
| path: .badges | |
| if-no-files-found: error | |
| include-hidden-files: true | |
| - name: Upload coverage report | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: coverage/ | |
| e2e-test: | |
| name: E2E Tests | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| build-tool: [gradle, maven] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: npm | |
| - name: Set up Java 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: '21' | |
| - name: Cache Gradle | |
| if: matrix.build-tool == 'gradle' | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| sample/sample-project/.gradle | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('sample/sample-project/**/*.gradle*') }} | |
| restore-keys: ${{ runner.os }}-gradle- | |
| - name: Cache Maven | |
| if: matrix.build-tool == 'maven' | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.m2/repository | |
| key: ${{ runner.os }}-maven-${{ hashFiles('sample/sample-maven-project/**/pom.xml') }} | |
| restore-keys: ${{ runner.os }}-maven- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Compile extension | |
| run: npm run compile | |
| - name: Compile E2E tests | |
| run: npm run compile:e2e | |
| - name: Warm build cache (Gradle) | |
| if: matrix.build-tool == 'gradle' | |
| working-directory: sample/sample-project | |
| run: ./gradlew build -x test --no-daemon || true | |
| - name: Warm build cache (Maven) | |
| if: matrix.build-tool == 'maven' | |
| working-directory: sample/sample-maven-project | |
| run: ./mvnw compile -q || true | |
| - name: Run Extension Host E2E tests | |
| env: | |
| E2E_BUILD_TOOL: ${{ matrix.build-tool }} | |
| run: xvfb-run --auto-servernum npm run test:e2e:host | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps chromium | |
| - name: Run Playwright UI E2E tests | |
| env: | |
| E2E_BUILD_TOOL: ${{ matrix.build-tool }} | |
| run: xvfb-run --auto-servernum npm run test:e2e:ui | |
| - name: Upload Playwright report | |
| if: failure() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: playwright-report-${{ matrix.build-tool }} | |
| path: playwright-report/ | |
| update-badges: | |
| name: Update Coverage Badges | |
| needs: [test] | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/master' && github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Switch to badges branch | |
| run: | | |
| git checkout badges 2>/dev/null || git checkout --orphan badges | |
| git rm -rf . 2>/dev/null || true | |
| mkdir -p .badges | |
| - name: Download badges | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: badges | |
| path: .badges/ | |
| continue-on-error: false | |
| - name: Verify downloaded badges | |
| run: | | |
| echo "Listing downloaded badges..." | |
| ls -la .badges/ | |
| echo "Badge files downloaded successfully" | |
| - name: Push badges | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add .badges/ | |
| git diff --cached --quiet && echo "No badge changes" || { | |
| git commit -m "Update coverage badges [skip ci]" | |
| git push origin badges | |
| } |