Skip to content

Commit d56e601

Browse files
authored
Add codecov and coverage threshold, hoist test requirements to setup.py (#348)
1 parent fd1709c commit d56e601

File tree

3 files changed

+66
-12
lines changed

3 files changed

+66
-12
lines changed

.github/workflows/tests.yml

Lines changed: 56 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: continuous-integration
22

33
on: [push, pull_request]
44

5+
env:
6+
COVERAGE_THRESHOLD: 62
7+
58
jobs:
69

710
lint:
@@ -24,12 +27,29 @@ jobs:
2427
with:
2528
node-version: '10.x'
2629

30+
- name: Cache python wheels
31+
uses: actions/cache@v2
32+
with:
33+
path: ~/.cache/pip
34+
key: |
35+
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }}
36+
restore-keys: |
37+
${{ runner.os }}-pip-${{ matrix.python-version }}-
38+
${{ runner.os }}-pip-
39+
40+
- name: Cache node_modules
41+
uses: actions/cache@v2
42+
with:
43+
path: 'node_modules'
44+
key: |
45+
${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }}
46+
2747
- name: Install dependencies
2848
run: |
29-
python -m pip install --upgrade pip
49+
python -m pip install --upgrade pip setuptools wheel
3050
python -m pip install --upgrade pre-commit
31-
pip install -e .
32-
yarn
51+
python -m pip install -e .
52+
yarn --frozen-lockfile
3353
3454
- name: Lint
3555
run: |
@@ -50,21 +70,35 @@ jobs:
5070
uses: actions/setup-python@v1
5171
with:
5272
python-version: ${{ matrix.python-version }}
73+
74+
- name: Cache python wheels
75+
uses: actions/cache@v2
76+
with:
77+
path: ~/.cache/pip
78+
key: |
79+
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }}
80+
restore-keys: |
81+
${{ runner.os }}-pip-${{ matrix.python-version }}-
82+
${{ runner.os }}-pip-
83+
5384
- name: Install dependencies
5485
run: |
55-
python -m pip install --upgrade pip
56-
pip install -e .
57-
pip install -r docs/requirements.txt
86+
python -m pip install --upgrade pip setuptools wheel
87+
python -m pip install -e .[coverage]
5888
5989
# Build the docs
6090
- name: Build docs to store
6191
run: |
6292
export PATH="$HOME/miniconda/bin:$PATH"
6393
sphinx-build -b html docs/ docs/_build/html -W --keep-going
6494
65-
# Run tests
95+
# Run tests under coverage
6696
- name: Run the tests
67-
run: pytest
97+
run: pytest --cov pydata_sphinx_theme --cov-report term-missing:skip-covered --cov-fail-under ${{ env.COVERAGE_THRESHOLD }}
98+
99+
- name: Upload coverage
100+
if: ${{ always() }}
101+
run: codecov
68102

69103
# Run local Lighthouse audit against built site
70104
audit:
@@ -86,11 +120,21 @@ jobs:
86120
uses: actions/setup-python@v1
87121
with:
88122
python-version: ${{ matrix.python-version }}
123+
124+
- name: Cache python wheels
125+
uses: actions/cache@v2
126+
with:
127+
path: ~/.cache/pip
128+
key: |
129+
${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('setup.py', 'docs/requirements.txt') }}
130+
restore-keys: |
131+
${{ runner.os }}-pip-${{ matrix.python-version }}-
132+
${{ runner.os }}-pip-
133+
89134
- name: Install dependencies
90135
run: |
91-
python -m pip install --upgrade pip
92-
pip install -e .
93-
pip install -r docs/requirements.txt
136+
python -m pip install --upgrade pip wheel setuptools
137+
python -m pip install -e .[coverage]
94138
95139
# Build the docs
96140
- name: Build docs to store
@@ -154,7 +198,7 @@ jobs:
154198
python-version: 3.7
155199
- name: Build package
156200
run: |
157-
pip install wheel
201+
python -m pip install -U pip setuptools wheel
158202
python setup.py sdist bdist_wheel
159203
- name: Publish
160204
uses: pypa/[email protected]

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include MANIFEST.in
22
include LICENSE
33
include README.md
44
include setup.py
5+
include docs/requirements.txt
56

67
graft pydata_sphinx_theme
78

setup.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def find_version(*file_paths):
2727
with open(os.path.join(HERE, "README.md"), encoding="utf-8") as f:
2828
long_description = f.read()
2929

30+
tests_require = [
31+
line.strip()
32+
for line in read("docs", "requirements.txt").splitlines()
33+
if not line.strip().startswith("#")
34+
]
3035

3136
setup(
3237
name="pydata-sphinx-theme",
@@ -44,6 +49,10 @@ def find_version(*file_paths):
4449
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
4550
entry_points={"sphinx.html_themes": ["pydata_sphinx_theme = pydata_sphinx_theme"]},
4651
install_requires=["sphinx", "beautifulsoup4"],
52+
extras_require={
53+
"test": tests_require,
54+
"coverage": ["pytest-cov", "codecov", *tests_require],
55+
},
4756
python_requires=">=3.5",
4857
classifiers=[
4958
"Development Status :: 4 - Beta",

0 commit comments

Comments
 (0)