Skip to content

Commit

Permalink
Add an additional check in e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
ewjoachim committed Aug 6, 2023
1 parent 118e63e commit b799713
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
9 changes: 8 additions & 1 deletion tests/end_to_end/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def gh_other_username(gh_other):


@pytest.fixture
def git_repo(cd, git, action_ref, code_path):
def git_repo(cd, git, action_ref, code_path, subproject_id):
with cd("repo") as repo:
git("init", "-b", "main")
# Copy .github
Expand All @@ -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)

Expand All @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions tests/end_to_end/repo/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__
14 changes: 8 additions & 6 deletions tests/end_to_end/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -71,15 +72,11 @@ def test_public_repo(
assert number_of_svgs == 3

# Check that logs point to the branch that has the readme file.
data_branch_url = (
f"https://github.com/{repo_full_name}/tree/python-coverage-comment-action-data"
)
data_branch_url = f"https://github.com/{repo_full_name}/tree/python-coverage-comment-action-data-my-great-project"
assert data_branch_url in links

# Time to check the Readme contents
raw_url_prefix = (
f"https://github.com/{repo_full_name}/raw/python-coverage-comment-action-data"
)
raw_url_prefix = f"https://github.com/{repo_full_name}/raw/python-coverage-comment-action-data-my-great-project"

readme_url = f"{raw_url_prefix}/README.md"
response = client.get(readme_url, follow_redirects=True)
Expand Down Expand Up @@ -124,6 +121,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")
Expand Down

0 comments on commit b799713

Please sign in to comment.