Skip to content

Commit c204e16

Browse files
Merge pull request #2 from johnburbridge/code-coverage
Code coverage
2 parents 6e4036a + 0bc7d88 commit c204e16

File tree

6 files changed

+63
-23
lines changed

6 files changed

+63
-23
lines changed

.coveragerc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
source = scraper
3+
omit =
4+
*/venv/*
5+
*/virtualenv/*
6+
*/tests/*
7+
*/site-packages/*
8+
9+
[report]
10+
exclude_lines =
11+
pragma: no cover
12+
def __repr__
13+
raise NotImplementedError
14+
if __name__ == .__main__.:
15+
pass
16+
raise ImportError
17+
18+
[html]
19+
directory = coverage_html_report

.github/workflows/python-package.yml

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,42 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: ["main"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111

1212
jobs:
1313
build:
14-
1514
runs-on: ubuntu-latest
1615
strategy:
1716
fail-fast: false
1817
matrix:
1918
python-version: ["3.11", "3.12"]
2019

2120
steps:
22-
- uses: actions/checkout@v4
23-
- name: Set up Python ${{ matrix.python-version }}
24-
uses: actions/setup-python@v3
25-
with:
26-
python-version: ${{ matrix.python-version }}
27-
- name: Install dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
python -m pip install flake8 pytest
31-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
32-
- name: Lint with flake8
33-
run: |
34-
# stop the build if there are Python syntax errors or undefined names
35-
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
36-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
37-
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
38-
- name: Test with pytest
39-
run: |
40-
pytest
21+
- uses: actions/checkout@v4
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v3
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install -r requirements-dev.txt
30+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest and coverage
38+
run: |
39+
pytest --cov=scraper --cov-report=xml --cov-report=term-missing --cov-fail-under=70
40+
- name: Upload coverage report to Codecov
41+
uses: codecov/codecov-action@v5
42+
with:
43+
file: ./coverage.xml
44+
fail_ci_if_error: true
45+
token: ${{ secrets.CODECOV_TOKEN }}
46+
verbose: true

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Scraper
22

3+
[![Python Tests](https://github.com/johnburbridge/scraper/actions/workflows/python-package.yml/badge.svg)](https://github.com/johnburbridge/scraper/actions/workflows/python-package.yml)
4+
[![Coverage](https://codecov.io/gh/johnburbridge/scraper/branch/main/graph/badge.svg)](https://codecov.io/gh/johnburbridge/scraper)
5+
36
## Objectives
47
* Given a URL, recursively crawl its links
58
* Store the response

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
import argparse
33
import logging
44
import sys

pytest.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[pytest]
2+
addopts = --cov=scraper --cov-report=term-missing
3+
testpaths = tests
4+
python_files = test_*.py
5+
python_classes = Test*
6+
python_functions = test_*

requirements-dev.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pytest>=7.0.0
2+
pytest-cov>=4.1.0
3+
pytest-asyncio>=0.21.0
4+
flake8>=6.0.0
5+
black>=23.0.0
6+
mypy>=1.0.0

0 commit comments

Comments
 (0)