From 9b3f37e17259aeaa0b9acdb29ef171cd53811b5b Mon Sep 17 00:00:00 2001 From: Normann Date: Sat, 22 Aug 2026 00:09:22 +0200 Subject: [PATCH] test: clean up git and artifact warnings (#1244) * initialize the temporary Git repository in test_workflow_git with --initial-branch=main * avoid Git's default-branch advisory in pytest logs without changing global Git configuration or suppressing stderr * upload generated optimization result artifacts only when the test job fails * use the actual nested tests/testdata/**/new_optimize_result* paths * ignore the no-files case so unrelated test failures do not produce an artifact warning --- .github/workflows/pytest.yml | 4 +++- tests/test_version.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 8558211f..c3496fca 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -35,7 +35,9 @@ jobs: uv run pytest --finalize --check-config-side-effect -vs --cov src --cov-report term-missing - name: Upload test artifacts + if: failure() uses: actions/upload-artifact@v7 with: name: optimize-results - path: tests/testdata/new_optimize_result* + path: tests/testdata/**/new_optimize_result* + if-no-files-found: ignore diff --git a/tests/test_version.py b/tests/test_version.py index 152d1757..872ce1a9 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -339,7 +339,7 @@ def test_bump_dev_version_appends_dev(tmp_path): # --- 4️⃣ Full workflow simulation with git --- def test_workflow_git(tmp_path): # Create git repo - subprocess.run(["git", "init"], cwd=tmp_path, check=True) + subprocess.run(["git", "init", "--initial-branch=main"], cwd=tmp_path, check=True) subprocess.run(["git", "config", "user.name", "test"], cwd=tmp_path, check=True) subprocess.run(["git", "config", "user.email", "test@test.com"], cwd=tmp_path, check=True)