Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Foo committed Oct 8, 2024
0 parents commit cae1dd5
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
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
25 changes: 25 additions & 0 deletions .github/workflows/coverage-comment.yml
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"
18 changes: 18 additions & 0 deletions subdir/end_to_end_tests_repo/__init__.py
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)
13 changes: 13 additions & 0 deletions subdir/pyproject.toml
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]
9 changes: 9 additions & 0 deletions subdir/setup.cfg
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
2 changes: 2 additions & 0 deletions subdir/tests/cases.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
a,,,,a
a,b,,,a-b
17 changes: 17 additions & 0 deletions subdir/tests/test_f.py
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

0 comments on commit cae1dd5

Please sign in to comment.