Skip to content

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Nov 3, 2025

Summary

This PR adds comprehensive unit tests for Python package extraction functions in pkg/workflow/pip.go, which previously had only 25% coverage (2 out of 8 functions tested).

Changes Made

New Test File

pkg/workflow/pip_test.go - 350 lines with 4 test functions covering:

  1. TestExtractPipFromCommands (21 test cases)

    • Simple pip/pip3 install commands
    • Commands with version specifiers (==, @)
    • Commands with flags (--upgrade, --no-cache-dir, etc.)
    • Multiple packages on one line
    • Multiple pip commands across lines
    • Edge cases: semicolons, ampersands, pipes, empty strings
    • Environment variables and special characters
    • Script blocks with shebang and set commands
  2. TestExtractUvFromCommands (23 test cases)

    • uvx commands (simple, with version, with special chars)
    • uv pip install commands (simple, with flags, with version)
    • Multiple uv commands
    • Edge cases matching pip test coverage
    • Mixed uv/pip commands in same input
  3. TestExtractPipPackages (3 test cases)

    • No custom steps
    • Custom step with pip install
    • Multiple pip installs in custom steps
  4. TestExtractUvPackages (3 test cases)

    • No custom steps
    • Custom step with uvx
    • Custom step with uv pip install

Test Coverage Results

Function Before After Improvement
extractPipFromCommands() 100.0% 100.0% (maintained)
extractUvFromCommands() 0.0% 100.0% +100.0%
extractPipPackages() 100.0% 100.0% (maintained)
extractUvPackages() 0.0% 100.0% +100.0%
pkg/workflow/pip.go file 25.0% 50.0% +25.0%
Overall Repository 67.0% 67.1% +0.1%

Replicating the Test Coverage Measurements

# Install dependencies (if needed)
make deps

# Build the project
make build

# Run tests with coverage (before)
git checkout main
go test -count=1 -timeout=5m -coverprofile=coverage-before.out -covermode=atomic ./...
go tool cover -func=coverage-before.out | grep total
# Output: total: (statements) 67.0%

# Run tests with coverage (after)
git checkout test-coverage-pip-parser-1762137534
go test -count=1 -timeout=5m -coverprofile=coverage-after.out -covermode=atomic ./...
go tool cover -func=coverage-after.out | grep total  
# Output: total: (statements) 67.1%

# Compare pip.go specific coverage
echo "=== BEFORE ==="
go tool cover -func=coverage-before.out | grep "pip.go"
echo "=== AFTER ==="
go tool cover -func=coverage-after.out | grep "pip.go"

Expected output shows extractUvFromCommands and extractUvPackages improving from 0% to 100% coverage.

Problems Found

None - these are pure string parsing functions with straightforward logic.

Actions Taken

  1. Created comprehensive test cases for pip and uv package extraction
  2. Tested all code paths including edge cases
  3. Verified all tests pass successfully
  4. Formatted code with make fmt
  5. All tests pass with 100% coverage for the 2 newly-tested parser functions

Future Improvement Areas

Based on current coverage analysis, the remaining untested functions in pip.go are:

Zero Coverage Functions (0%):

  • validatePythonPackagesWithPip() - Requires pip command execution and network access
  • validatePipPackages() - Depends on pip command availability
  • validateUvPackages() - Depends on uv/pip command availability
  • validateUvPackagesWithPip() - Wrapper function requiring pip

These functions are integration-heavy and would require mocking exec.Command or integration tests with actual pip/uv commands available. The current PR focuses on the pure parsing logic which provides the most value with minimal test complexity.


📋 Full Command History

Bash Commands Run

# Phase determination
cd /home/runner/work/gh-aw/gh-aw
tail -1 coverage-summary.txt

# Create branch
git checkout -b test-coverage-pip-parser-1762137534

# Create test file
# pkg/workflow/pip_test.go created with 350 lines

# Run new tests
go test -v -run "^(TestExtractPipFromCommands|TestExtractUvFromCommands|TestExtractPipPackages|TestExtractUvPackages)$" ./pkg/workflow

# Generate coverage report
go test -count=1 -timeout=5m -coverprofile=coverage-new.out -covermode=atomic ./...
go tool cover -func=coverage-new.out | tail -1

# Compare before/after
go tool cover -func=coverage.out | grep "pip.go"
go tool cover -func=coverage-new.out | grep "pip.go"

# Format code
make fmt

# Commit changes
git add pkg/workflow/pip_test.go
git commit -m "test: add comprehensive tests for pip and uv package extraction (+25.0% function coverage, +0.1% overall)"

Web Searches Performed

None

Web Pages Fetched

None

AI generated by Daily Test Coverage Improver

AI generated by Daily Test Coverage Improver

@pelikhan
Copy link
Contributor

pelikhan commented Nov 4, 2025

@copilot merge main

Copy link
Contributor

Copilot AI commented Nov 4, 2025

@pelikhan I've opened a new pull request, #3159, to work on those changes. Once the pull request is ready, I'll request review from you.

@pelikhan pelikhan marked this pull request as ready for review November 4, 2025 17:09
Copilot AI review requested due to automatic review settings November 4, 2025 17:09
@pelikhan pelikhan enabled auto-merge (squash) November 4, 2025 17:09
@pelikhan pelikhan merged commit faf1abb into main Nov 4, 2025
15 checks passed
@pelikhan pelikhan deleted the test-coverage-pip-parser-1762137534-096b7afce090a92c branch November 4, 2025 17:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the Copilot GitHub secret from COPILOT_CLI_TOKEN to COPILOT_GITHUB_TOKEN while maintaining backward compatibility with the legacy name. The changes update documentation, test assertions, validation steps, environment variable references, and CLI configurations throughout the codebase.

Key changes:

  • Renamed primary secret from COPILOT_CLI_TOKEN to COPILOT_GITHUB_TOKEN with fallback support
  • Updated secret validation to check both new and legacy secret names
  • Modified environment variable usage to prefer COPILOT_GITHUB_TOKEN over deprecated GITHUB_TOKEN
  • Extracted JavaScript utility functions into reusable modules to reduce code duplication

Reviewed Changes

Copilot reviewed 115 out of 117 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/workflow/copilot_engine.go Updated secret name and environment variable usage with fallback logic
pkg/workflow/secret_validation_test.go Updated test assertions to validate both new and legacy secret names
pkg/workflow/redact_secrets_test.go Updated tests for secret redaction to include both secret names
pkg/workflow/js/sanitize_label_content.cjs Extracted label sanitization into reusable module
pkg/workflow/js/sanitize_workflow_name.cjs Extracted workflow name sanitization into reusable module
pkg/workflow/js/sanitize.cjs Added GitHub domain extraction for Enterprise support
pkg/workflow/js.go Added bundling support for new JavaScript modules
pkg/cli/trial_command.go Updated CLI to use new secret name with legacy support
docs/* Updated all documentation references to new secret name

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants