From 3cacce0f4f7064c9fde3b9dc26d7f23190cdd71b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 1 Oct 2026 20:01:51 +0000 Subject: [PATCH 1/3] Fix failing tests and remove Claude Code Review workflow test_filename_poster_and_embed_snippet assumed Chromium can't read H.264 metadata, so the embed snippet would have no width/height. Newer Playwright Chromium builds can, so the test failed on every CI run since 2026-09-07. It now expects the size whenever the page detected it. test_github_repo_analysis called the live GitHub API unauthenticated, which fails intermittently once shared CI runners hit the rate limit. It now analyzes a mocked two-file repository. The Claude Code Review workflow has failed on every PR since July because its OAuth token expired. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_0139NfxSqowttMWdKwMQ7hYM --- .github/workflows/claude-code-review.yml | 78 ------------------------ tests/test_sloccount.py | 48 +++++++++------ tests/test_video_compressor.py | 11 ++-- 3 files changed, 38 insertions(+), 99 deletions(-) delete mode 100644 .github/workflows/claude-code-review.yml diff --git a/.github/workflows/claude-code-review.yml b/.github/workflows/claude-code-review.yml deleted file mode 100644 index 405ccd95..00000000 --- a/.github/workflows/claude-code-review.yml +++ /dev/null @@ -1,78 +0,0 @@ -name: Claude Code Review - -on: - pull_request: - types: [opened, synchronize] - # Optional: Only run on specific file changes - # paths: - # - "src/**/*.ts" - # - "src/**/*.tsx" - # - "src/**/*.js" - # - "src/**/*.jsx" - -jobs: - claude-review: - # Optional: Filter by PR author - # if: | - # github.event.pull_request.user.login == 'external-contributor' || - # github.event.pull_request.user.login == 'new-developer' || - # github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' - - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - issues: read - id-token: write - - steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 1 - - - name: Run Claude Code Review - id: claude-review - uses: anthropics/claude-code-action@beta - with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - - # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) - # model: "claude-opus-4-20250514" - - # Direct prompt for automated review (no @claude mention needed) - direct_prompt: | - Please review this pull request and provide feedback on: - - Code quality and best practices - - Potential bugs or issues - - Performance considerations - - Security concerns - - Test coverage - - Be constructive and helpful in your feedback. - - # Optional: Use sticky comments to make Claude reuse the same comment on subsequent pushes to the same PR - # use_sticky_comment: true - - # Optional: Customize review based on file types - # direct_prompt: | - # Review this PR focusing on: - # - For TypeScript files: Type safety and proper interface usage - # - For API endpoints: Security, input validation, and error handling - # - For React components: Performance, accessibility, and best practices - # - For tests: Coverage, edge cases, and test quality - - # Optional: Different prompts for different authors - # direct_prompt: | - # ${{ github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' && - # 'Welcome! Please review this PR from a first-time contributor. Be encouraging and provide detailed explanations for any suggestions.' || - # 'Please provide a thorough code review focusing on our coding standards and best practices.' }} - - # Optional: Add specific tools for running tests or linting - # allowed_tools: "Bash(npm run test),Bash(npm run lint),Bash(npm run typecheck)" - - # Optional: Skip review for certain conditions - # if: | - # !contains(github.event.pull_request.title, '[skip-review]') && - # !contains(github.event.pull_request.title, '[WIP]') - diff --git a/tests/test_sloccount.py b/tests/test_sloccount.py index 3222c115..9a077b42 100644 --- a/tests/test_sloccount.py +++ b/tests/test_sloccount.py @@ -246,8 +246,33 @@ def test_github_repo_validation(page: Page, unused_port_server): expect(status).to_contain_text("Invalid format") +MOCK_REPO_FILES = { + "src/hello.c": '#include \n\nint main(void) {\n printf("hello\\n");\n return 0;\n}\n', + "scripts/count.py": "import sys\n\n\ndef main():\n print(len(sys.argv))\n\n\nmain()\n", + "README.md": "# Not code\n", +} + + +def mock_github(route): + """Serve a tiny fake repository in place of the GitHub API and raw.githubusercontent.com, + whose unauthenticated rate limit is easily exhausted by shared CI runners.""" + url = route.request.url + headers = {"access-control-allow-origin": "*"} + if url == "https://api.github.com/repos/example/tiny": + return route.fulfill(json={"default_branch": "main"}, headers=headers) + if url == "https://api.github.com/repos/example/tiny/git/trees/main?recursive=1": + tree = [{"path": path, "type": "blob"} for path in MOCK_REPO_FILES] + return route.fulfill(json={"tree": tree, "truncated": False}, headers=headers) + prefix = "https://raw.githubusercontent.com/example/tiny/main/" + if url.startswith(prefix) and url[len(prefix):] in MOCK_REPO_FILES: + return route.fulfill(body=MOCK_REPO_FILES[url[len(prefix):]], headers=headers) + route.fulfill(status=404, headers=headers) + + def test_github_repo_analysis(page: Page, unused_port_server): """Test analyzing a small GitHub repository""" + page.route("https://api.github.com/**", mock_github) + page.route("https://raw.githubusercontent.com/**", mock_github) unused_port_server.start(root) page.goto(f"http://localhost:{unused_port_server.port}/sloccount.html") @@ -258,28 +283,17 @@ def test_github_repo_analysis(page: Page, unused_port_server): analyze_btn = page.locator("#analyze-repo-btn") expect(analyze_btn).to_have_text("Analyze Repository", timeout=30000) - # Use a small public repository for testing - # Using the sloccount repo itself as a test - page.locator("#repo-input").fill("https://github.com/licquia/sloccount") - - # Analyze (this may take a while) + page.locator("#repo-input").fill("https://github.com/example/tiny") analyze_btn.click() - # Wait for fetch to start - status = page.locator("#status") - expect(status).to_contain_text("Fetching", timeout=5000) - - # Wait for results (may take up to 60 seconds) + # Wait for results results = page.locator("#results") expect(results).to_have_class("visible", timeout=60000) - # Check that we got results - total_lines = page.locator("#total-lines") - expect(total_lines).not_to_have_text("0") - - total_languages = page.locator("#total-languages") - # Should have at least one language - expect(total_languages).not_to_have_text("0") + # Only the C and Python files count, not the README + expect(page.locator("#total-files")).to_have_text("2") + expect(page.locator("#total-languages")).to_have_text("2") + expect(page.locator("#total-lines")).not_to_have_text("0") def test_mobile_responsive(page: Page, unused_port_server): diff --git a/tests/test_video_compressor.py b/tests/test_video_compressor.py index 10efd78a..215d089f 100644 --- a/tests/test_video_compressor.py +++ b/tests/test_video_compressor.py @@ -145,8 +145,8 @@ def test_full_flow_encodes_compatible_mp4s(page: Page, unused_port_server): expect(page.locator("#status")).to_contain_text("Done: 3 versions") expect(page.locator("#error")).to_be_hidden() - # Playwright's Chromium has no H.264 decoder, so these details come from - # ffmpeg probing the file rather than from the