-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Foo
committed
Oct 8, 2024
0 parents
commit cae1dd5
Showing
7 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
concurrency: | ||
group: CI | ||
|
||
jobs: | ||
test: | ||
name: Run tests & display/prepare coverage | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.12" | ||
|
||
- run: pip install -e . | ||
working-directory: subdir | ||
|
||
- run: pytest | ||
working-directory: subdir | ||
|
||
- name: Coverage comment | ||
id: coverage_comment | ||
uses: py-cov-action/python-coverage-comment-action@032f1914e3f12a555f8ca8322f949c24a829072e | ||
with: | ||
GITHUB_TOKEN: ${{ github.token }} | ||
ANNOTATE_MISSING_LINES: true | ||
ANNOTATION_TYPE: notice | ||
COVERAGE_PATH: subdir | ||
SUBPROJECT_ID: "my-great-project" | ||
|
||
- name: Store Pull Request comment to be posted | ||
uses: actions/upload-artifact@v4 | ||
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true' | ||
with: | ||
name: python-coverage-comment-action | ||
path: python-coverage-comment-action*.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Post coverage comment | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
test: | ||
name: Publish coverage Comment | ||
runs-on: ubuntu-latest | ||
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' | ||
permissions: | ||
actions: read | ||
pull-requests: write | ||
contents: write | ||
steps: | ||
- name: Post comment | ||
uses: py-cov-action/python-coverage-comment-action@032f1914e3f12a555f8ca8322f949c24a829072e | ||
with: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }} | ||
COVERAGE_PATH: subdir | ||
SUBPROJECT_ID: "my-great-project" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from __future__ import annotations | ||
|
||
|
||
def f(a="", b="", c="", d=""): | ||
elements = [] | ||
if a: | ||
elements.append(a) | ||
|
||
if b: | ||
elements.append(b) | ||
|
||
if c: | ||
elements.append(c) | ||
|
||
if d: | ||
elements.append(d) | ||
|
||
return "-".join(elements) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "end-to-end-tests" | ||
version = "0.0.0" | ||
dependencies = [ | ||
"pytest", | ||
"pytest-cov", | ||
] | ||
|
||
[tool.setuptools.packages.find] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[coverage:run] | ||
relative_files = true | ||
|
||
[tool:pytest] | ||
addopts = | ||
--cov-report term-missing --cov-branch --cov-report html | ||
--cov=end_to_end_tests_repo -vv --strict-markers -rfE | ||
testpaths = | ||
tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
a,,,,a | ||
a,b,,,a-b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from __future__ import annotations | ||
|
||
import csv | ||
import pathlib | ||
|
||
import end_to_end_tests_repo | ||
import pytest | ||
|
||
|
||
def load_csv(): | ||
file = pathlib.Path(__file__).parent / "cases.csv" | ||
return list(csv.reader(file.read_text().splitlines())) | ||
|
||
|
||
@pytest.mark.parametrize("a, b, c, d, expected", load_csv()) | ||
def test_f(a, b, c, d, expected): | ||
assert end_to_end_tests_repo.f(a=a, b=b, c=c, d=d) == expected |