Skip to content

Commit

Permalink
ci: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ong committed Dec 26, 2023
1 parent d509be4 commit 964c666
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: lint

on:
pull_request:
push:
branches:
- main # Change this to your main branch name if it's different
Expand Down
23 changes: 18 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
name: test
name: test_and_coverage

on:
pull_request:
push:
branches:
- main # Change this to your main branch name if it's different
- main

jobs:
pre-commit:
name: Run tests & display coverage
runs-on: ubuntu-latest

permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for pushing data to the
# python-coverage-comment-action branch, and for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
Expand All @@ -22,4 +31,8 @@ jobs:
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run pre-commit on all files
run: pre-commit run --hook-stage pre-push
run: pre-commit run --hook-stage pre-push
- name: Coverage comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ github.token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ input.txt
/day20/vis/

/day10/big*.txt
.coverage
10 changes: 9 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,15 @@ repos:
name: pytest-check
stages: [pre-push]
types: [python]
entry: pytest -v
entry: pytest -v --color=yes
language: system
always_run: true
pass_filenames: false
- id: coverage-check # technically runs pytest again. oh well
name: coverage-check
stages: [pre-push]
types: [python]
entry: coverage run
language: system
always_run: true
pass_filenames: false
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ section-order = [
"first-party",
"local-folder",
]

[tool.coverage.run]
branch = true
command_line = '-m pytest'
source = ['.']
relative_files = true

[tool.coverage.report]
precision = 2
skip_covered = true
fail_under = 0
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
colorama==0.4.6
coverage==7.3.4
graphviz==0.20.1
matplotlib==3.8.2
mypy==1.8.0
Expand Down

0 comments on commit 964c666

Please sign in to comment.