diff --git a/tests/end_to_end/conftest.py b/tests/end_to_end/conftest.py index 07e2f794..65dceec3 100644 --- a/tests/end_to_end/conftest.py +++ b/tests/end_to_end/conftest.py @@ -213,6 +213,7 @@ def git_repo(cd, git, action_ref, code_path): file.read_text() .replace("__ACTION_REF__", action_ref) .replace("__ACTION_COVERAGE_PATH__", str(code_path)) + .replace("__ACTION_SUBPROJECT_ID__", str(subproject_id)) ) file.write_text(content) @@ -239,6 +240,12 @@ def code_path(request): return pathlib.Path(*mark.args) if mark else pathlib.Path(".") +@pytest.fixture +def subproject_id(request): + mark = request.node.get_closest_marker("subproject_id") + return mark.args[0] if mark else None + + @pytest.fixture def repo_full_name(repo_name, gh_me_username): return f"{gh_me_username}/{repo_name}" diff --git a/tests/end_to_end/repo/.github/workflows/ci.yml b/tests/end_to_end/repo/.github/workflows/ci.yml index 5d64e222..49b95415 100644 --- a/tests/end_to_end/repo/.github/workflows/ci.yml +++ b/tests/end_to_end/repo/.github/workflows/ci.yml @@ -41,6 +41,7 @@ jobs: ANNOTATE_MISSING_LINES: true ANNOTATION_TYPE: notice COVERAGE_PATH: __ACTION_COVERAGE_PATH__ + SUBPROJECT_ID: __ACTION_SUBPROJECT_ID__ - name: Store Pull Request comment to be posted uses: actions/upload-artifact@v3 diff --git a/tests/end_to_end/repo/.github/workflows/coverage-comment.yml b/tests/end_to_end/repo/.github/workflows/coverage-comment.yml index 9db6642d..26668d71 100644 --- a/tests/end_to_end/repo/.github/workflows/coverage-comment.yml +++ b/tests/end_to_end/repo/.github/workflows/coverage-comment.yml @@ -22,3 +22,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} COVERAGE_PATH: __ACTION_COVERAGE_PATH__ + SUBPROJECT_ID: __ACTION_SUBPROJECT_ID__ diff --git a/tests/end_to_end/test_all.py b/tests/end_to_end/test_all.py index 4b445295..7648362d 100644 --- a/tests/end_to_end/test_all.py +++ b/tests/end_to_end/test_all.py @@ -6,6 +6,7 @@ @pytest.mark.repo_suffix("public") @pytest.mark.code_path("subdir") +@pytest.mark.subproject_id("my-great-project") def test_public_repo( gh_create_repo, wait_for_run_to_start, @@ -124,6 +125,11 @@ def test_public_repo( fail_value="\n", ) assert ":arrow_up:" in comment + assert "## Coverage report (my-great-project)" in comment + assert ( + "This comment was produced by python-coverage-comment-action (my-great-project)" + in comment + ) # Let's merge the PR and see if everything works fine gh_me("pr", "merge", "1", "--merge")