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/.github/workflows/claude.yml b/.github/workflows/claude.yml deleted file mode 100644 index d7e0f94e..00000000 --- a/.github/workflows/claude.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Claude Code - -on: - issue_comment: - types: [created] - pull_request_review_comment: - types: [created] - issues: - types: [opened, assigned] - pull_request_review: - types: [submitted] - -jobs: - claude: - if: | - (github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) || - (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) || - (github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) || - (github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude'))) - runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: read - issues: read - id-token: write - actions: read # Required for Claude to read CI results on PRs - steps: - - name: Checkout repository - uses: actions/checkout@v7 - with: - fetch-depth: 1 - - - name: Run Claude Code - id: claude - uses: anthropics/claude-code-action@beta - with: - claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} - - # This is an optional setting that allows Claude to read CI results on PRs - additional_permissions: | - actions: read - - # Optional: Specify model (defaults to Claude Sonnet 4, uncomment for Claude Opus 4) - # model: "claude-opus-4-20250514" - - # Optional: Customize the trigger phrase (default: @claude) - # trigger_phrase: "/claude" - - # Optional: Trigger when specific user is assigned to an issue - # assignee_trigger: "claude-bot" - - # Optional: Allow Claude to run specific commands - # allowed_tools: "Bash(npm install),Bash(npm run build),Bash(npm run test:*),Bash(npm run lint:*)" - - # Optional: Add custom instructions for Claude to customize its behavior for your project - # custom_instructions: | - # Follow our coding standards - # Ensure all new code has tests - # Use TypeScript for new files - - # Optional: Custom environment variables for Claude - # claude_env: | - # NODE_ENV: test - 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 70332e5b..ada695e2 100644 --- a/tests/test_video_compressor.py +++ b/tests/test_video_compressor.py @@ -182,8 +182,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