name: Flaky Test Detector on: pull_request: branches: [main] paths: - 'tests/**/*.spec.ts' permissions: contents: read pull-requests: write issues: write checks: write jobs: detect-flaky-tests: name: Detect Flaky Tests runs-on: ubuntu-24.04 timeout-minutes: 60 steps: - name: Checkout code uses: actions/checkout@v6 with: fetch-depth: 0 # Need full history to compare with main - name: Setup Node.js uses: actions/setup-node@v5 with: node-version-file: '.nvmrc' cache: 'npm' - name: Install system dependencies run: | sudo apt-get update sudo apt-get --no-install-recommends install -y \ libglib2.0-0 libnss3 libdbus-1-3 libatk1.0-0 libatk-bridge2.0-0 \ libcups2 libgtk-3-0 libasound2t64 xvfb - name: Install npm dependencies run: | npm ci --legacy-peer-deps sudo chown root /home/runner/work/bruno/bruno/node_modules/electron/dist/chrome-sandbox sudo chmod 4755 /home/runner/work/bruno/bruno/node_modules/electron/dist/chrome-sandbox - name: Install test collection dependencies run: npm ci --prefix packages/bruno-tests/collection - name: Build libraries run: | npm run build:graphql-docs npm run build:bruno-query npm run build:bruno-common npm run sandbox:bundle-libraries --workspace=packages/bruno-js npm run build:bruno-converters npm run build:bruno-requests npm run build:schema-types npm run build:bruno-filestore - name: Run Playwright tests run: xvfb-run npm run test:e2e continue-on-error: true # Continue even if tests fail - name: Detect flaky tests id: detect run: node .github/scripts/detect-flaky-tests.js continue-on-error: true # Don't fail workflow if flaky tests found - name: Check modified flaky tests id: check-modified run: node .github/scripts/comment-on-flaky-tests.js continue-on-error: true - name: Post PR comment if: hashFiles('pr-comment.md') != '' uses: actions/github-script@v7 with: script: | const fs = require('fs'); const comment = fs.readFileSync('pr-comment.md', 'utf8'); // Check if we already commented const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number }); const botComment = comments.find(c => c.user.type === 'Bot' && c.body.includes('Warning: You modified flaky/failed test files') ); if (botComment) { // Update existing comment await github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: botComment.id, body: comment }); } else { // Create new comment await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, body: comment }); } - name: Upload flaky test artifacts if: always() uses: actions/upload-artifact@v6 with: name: flaky-test-results path: | flaky-tests.json flaky-report.md playwright-report/ retention-days: 30