Skip to content

Fix test_positional_arg_invalid_commit failing in CI environments#373

Merged
shenxianpeng merged 2 commits intodependabot/github_actions/CodSpeedHQ/action-4.10.5from
copilot/fix-positional-arg-test-failure
Feb 14, 2026
Merged

Fix test_positional_arg_invalid_commit failing in CI environments#373
shenxianpeng merged 2 commits intodependabot/github_actions/CodSpeedHQ/action-4.10.5from
copilot/fix-positional-arg-test-failure

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

Test was returning 0 (pass) instead of 1 (fail) when run in CI because the git author (copilot[bot]) was in the ignore_authors configuration list, causing validation to be skipped.

Changes

  • Mock get_commit_info in test_positional_arg_invalid_commit to return "test-author" instead of the actual CI author
  • Ensures validation runs instead of being skipped due to ignore list

This aligns with the existing pattern used in test_message_validation_with_invalid_commit.

@pytest.mark.benchmark
def test_positional_arg_invalid_commit(self, mocker):
    """Test that positional argument correctly rejects invalid commits."""
    # Mock git author to ensure it's not in any ignore list
    mocker.patch("commit_check.engine.get_commit_info", return_value="test-author")
    
    with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
        f.write("invalid commit message without type")
        f.flush()

        try:
            sys.argv = ["commit-check", f.name]
            result = main()
            assert result == 1  # Should fail validation
        finally:
            os.unlink(f.name)
Original prompt

This section details on the original issue you should resolve

<issue_title>FAILED tests/main_test.py::TestPositionalArgumentFeature::test_positional_arg_invalid_commit - assert 0 == 1</issue_title>
<issue_description>```bash
Run CodSpeedHQ/action@9a74b6b
Run RUNNER_VERSION=""
Run actions/cache@0057852
Cache not found for input keys: codspeed-instruments-simulation-Linux-X64-6.14.0-1017-azure-4.10.5, codspeed-instruments-simulation-Linux-X64-6.14.0-1017-azure-
Run # Validate required inputs


/ / / // / ____ ___ ___ / /
/ / / __ \ / __ / _
\ / __ \ / _ \ / _ \ / __ /
/ /
/ /
/ // /
/ / / // // // __// __// // /
_
/ _
/ _,/ /// ./ _/ _/ _,/
https://codspeed.io/ /
/ runner v4.10.5

Installing packages: /tmp/valgrind-codspeed.deb
Installation completed successfully
Running the benchmarks
============================= test session starts ==============================
platform linux -- Python 3.13.12, pytest-9.0.2, pluggy-1.6.0
codspeed: 4.3.0 (enabled, mode: simulation, callgraph: enabled)
rootdir: /home/runner/work/commit-check/commit-check
configfile: pyproject.toml
plugins: mock-3.15.1, codspeed-4.3.0
collected 237 items / 67 deselected / 170 selected

tests/config_test.py .................. [ 10%]
tests/engine_test.py ................................................... [ 40%]
................. [ 50%]
tests/main_test.py ......................................F. [ 74%]
tests/rule_builder_test.py ............. [ 81%]
tests/util_test.py ............................... [100%]
=============================== 170 benchmarked ================================

=================================== FAILURES ===================================
_______ TestPositionalArgumentFeature.test_positional_arg_invalid_commit _______

self = <main_test.TestPositionalArgumentFeature object at 0x7196bf0>

  @pytest.mark.benchmark
  def test_positional_arg_invalid_commit(self):
      """Test that positional argument correctly rejects invalid commits."""
      with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
          f.write("invalid commit message without type")
          f.flush()
  
          try:
              # Use positional argument with invalid message
              sys.argv = ["commit-check", f.name]
              result = main()
          assert result == 1  # Should fail validation
              ^^^^^^^^^^^^^^^^^^

E assert 0 == 1

tests/main_test.py:547: AssertionError
=========================== short test summary info ============================
FAILED tests/main_test.py::TestPositionalArgumentFeature::test_positional_arg_invalid_commit - assert 0 == 1
=========== 1 failed, 169 passed, 67 deselected in 295.40s (0:04:55) ===========
Error: Error: failed to execute the benchmark process, exit code: 1
Error: Process completed with exit code 1.


## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@netlify
Copy link

netlify bot commented Feb 14, 2026

Deploy Preview for commit-check ready!

Name Link
🔨 Latest commit e2f8162
🔍 Latest deploy log https://app.netlify.com/projects/commit-check/deploys/6990bfc2e0c4fb0008247e1a
😎 Deploy Preview https://deploy-preview-373--commit-check.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI changed the title [WIP] Fix positional argument test failure in main_test.py Fix test_positional_arg_invalid_commit failing in CI environments Feb 14, 2026
Copilot AI requested a review from shenxianpeng February 14, 2026 18:01
@github-actions github-actions bot added the bug Something isn't working label Feb 14, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 14, 2026

Merging this PR will improve performance by 22.1%

⚡ 1 improved benchmark
✅ 169 untouched benchmarks
⏩ 108 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_positional_arg_invalid_commit 4.2 ms 3.5 ms +22.1%

Comparing copilot/fix-positional-arg-test-failure (e2f8162) with main (c682971)2

Open in CodSpeed

Footnotes

  1. 108 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on dependabot/github_actions/CodSpeedHQ/action-4.10.5 (c682971) during the generation of this report, so main (c682971) was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@shenxianpeng shenxianpeng changed the base branch from main to dependabot/github_actions/CodSpeedHQ/action-4.10.5 February 14, 2026 18:32
Copilot AI and others added 2 commits February 14, 2026 20:32
The test was failing in CI because the git author (copilot[bot]) was in the
ignore_authors list, causing validation to be skipped and return 0 instead
of 1. Added mocker parameter and mock to ensure the author is not ignored.

Co-authored-by: shenxianpeng <[email protected]>
@shenxianpeng shenxianpeng force-pushed the copilot/fix-positional-arg-test-failure branch from e2f8162 to 1220d9b Compare February 14, 2026 18:32
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dependabot/github_actions/CodSpeedHQ/action-4.10.5@bc6cffc). Learn more about missing BASE report.

Additional details and impacted files
@@                                  Coverage Diff                                  @@
##             dependabot/github_actions/CodSpeedHQ/action-4.10.5     #373   +/-   ##
=====================================================================================
  Coverage                                                      ?   94.65%           
=====================================================================================
  Files                                                         ?        9           
  Lines                                                         ?      805           
  Branches                                                      ?        0           
=====================================================================================
  Hits                                                          ?      762           
  Misses                                                        ?       43           
  Partials                                                      ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shenxianpeng shenxianpeng marked this pull request as ready for review February 14, 2026 18:38
@shenxianpeng shenxianpeng requested a review from a team as a code owner February 14, 2026 18:38
@shenxianpeng shenxianpeng merged commit 0544028 into dependabot/github_actions/CodSpeedHQ/action-4.10.5 Feb 14, 2026
26 checks passed
@shenxianpeng shenxianpeng deleted the copilot/fix-positional-arg-test-failure branch February 14, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FAILED tests/main_test.py::TestPositionalArgumentFeature::test_positional_arg_invalid_commit - assert 0 == 1

2 participants

Comments