Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Commit 8c4f84f

Browse files
authored
Merge pull request #73 from per1234/coverage
libraries/*: check code coverage during CI workflow run
2 parents 116f495 + bbe983a commit 8c4f84f

File tree

15 files changed

+66
-24
lines changed

15 files changed

+66
-24
lines changed

.github/workflows/libraries_compile-examples.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ jobs:
3535
pip install --quiet pep8-naming
3636
flake8 --config "$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches/.flake8" --show-source "$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches"
3737
38-
- name: Run Python unit tests
38+
- name: Run Python unit tests and report code coverage
3939
run: |
4040
export PYTHONPATH="$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches"
41-
pytest "$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches/tests"
41+
coverage run --source="$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches" --module pytest "$GITHUB_WORKSPACE/libraries/compile-examples/compilesketches/tests"
42+
# Display code coverage report in workflow run log
43+
coverage report
44+
45+
- name: Upload coverage report to Codecov
46+
uses: codecov/codecov-action@v1
47+
with:
48+
fail_ci_if_error: true

.github/workflows/libraries_report-size-deltas.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ jobs:
3535
pip install --quiet pep8-naming
3636
flake8 --config "$GITHUB_WORKSPACE/libraries/report-size-deltas/.flake8" --show-source "$GITHUB_WORKSPACE/libraries/report-size-deltas"
3737
38-
- name: Run Python unit tests
38+
- name: Run Python unit tests and report code coverage
3939
run: |
4040
export PYTHONPATH="$GITHUB_WORKSPACE/libraries/report-size-deltas"
41-
pytest "$GITHUB_WORKSPACE/libraries/report-size-deltas/tests"
41+
coverage run --source="$GITHUB_WORKSPACE/libraries/report-size-deltas" --module pytest "$GITHUB_WORKSPACE/libraries/report-size-deltas/tests"
42+
# Display code coverage report in workflow run log
43+
coverage report
44+
45+
- name: Upload coverage report to Codecov
46+
uses: codecov/codecov-action@v1
47+
with:
48+
fail_ci_if_error: true

.github/workflows/libraries_report-size-trends.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ jobs:
3535
pip install --quiet pep8-naming
3636
flake8 --config "$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends/.flake8" --show-source "$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends"
3737
38-
- name: Run Python unit tests
38+
- name: Run Python unit tests and report code coverage
3939
run: |
4040
export PYTHONPATH="$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends"
41-
pytest "$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends/tests"
41+
coverage run --source="$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends" --module pytest "$GITHUB_WORKSPACE/libraries/report-size-trends/reportsizetrends/tests"
42+
# Display code coverage report in workflow run log
43+
coverage report
44+
45+
- name: Upload coverage report to Codecov
46+
uses: codecov/codecov-action@v1
47+
with:
48+
fail_ci_if_error: true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage:
2+
range: "100...100"
3+
status:
4+
project:
5+
default:
6+
threshold: 0%

libraries/compile-examples/compilesketches/compilesketches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1385,4 +1385,4 @@ def get_head_commit_hash():
13851385

13861386
# Only execute the following code if the script is run directly, not imported
13871387
if __name__ == "__main__":
1388-
main()
1388+
main() # pragma: no cover
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--requirement ../requirements.txt
2+
coverage==5.2.1
23
pytest==5.4.2
34
pytest-mock==3.1.0

libraries/compile-examples/compilesketches/tests/test_compilesketches.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def test_main(capsys,
104104

105105
class CompileSketches:
106106
def compile_sketches(self):
107-
pass
107+
pass # pragma: no cover
108108

109109
monkeypatch.setenv("INPUT_CLI-VERSION", cli_version)
110110
monkeypatch.setenv("INPUT_FQBN", fqbn_arg)
@@ -238,10 +238,10 @@ def __init__(self):
238238
self.base = self
239239

240240
def get_repo(self):
241-
pass
241+
pass # pragma: no cover
242242

243243
def get_pull(self, number):
244-
pass
244+
pass # pragma: no cover
245245

246246
github_api_object = Github()
247247
monkeypatch.setenv("GITHUB_EVENT_PATH", str(test_data_path.joinpath("githubevent.json")))
@@ -1228,7 +1228,7 @@ def __init__(self):
12281228
self.git = self
12291229

12301230
def checkout(self):
1231-
pass
1231+
pass # pragma: no cover
12321232

12331233
compile_sketches = get_compilesketches_object()
12341234

@@ -1519,10 +1519,10 @@ def __init__(self):
15191519
self.git = self
15201520

15211521
def fetch(self):
1522-
pass
1522+
pass # pragma: no cover
15231523

15241524
def checkout(self):
1525-
pass
1525+
pass # pragma: no cover
15261526

15271527
compile_sketches = get_compilesketches_object(enable_size_deltas_report="true", deltas_base_ref=deltas_base_ref)
15281528

@@ -2259,7 +2259,7 @@ def __init__(self):
22592259
self.git = self
22602260

22612261
def rev_parse(self):
2262-
pass
2262+
pass # pragma: no cover
22632263

22642264
monkeypatch.setenv("GITHUB_EVENT_NAME", github_event)
22652265
monkeypatch.setenv("GITHUB_EVENT_PATH", str(test_data_path.joinpath("githubevent.json")))
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage:
2+
range: "100...100"
3+
status:
4+
project:
5+
default:
6+
threshold: 0%

libraries/report-size-deltas/reportsizedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,4 @@ def generate_csv_table(row_list):
690690

691691
# Only execute the following code if the script is run directly, not imported
692692
if __name__ == "__main__":
693-
main()
693+
main() # pragma: no cover
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
coverage==5.2.1
12
pytest==5.4.2
23
pytest-mock==3.1.0

libraries/report-size-deltas/tests/test_reportsizedeltas.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ReportSizeDeltas:
102102

103103
def report_size_deltas(self):
104104
"""Stub"""
105-
pass
105+
pass # pragma: no cover
106106

107107
mocker.patch("reportsizedeltas.set_verbosity", autospec=True)
108108
mocker.patch("reportsizedeltas.ReportSizeDeltas", autospec=True, return_value=ReportSizeDeltas())
@@ -621,7 +621,7 @@ def test_get_sketches_reports(sketches_reports_path, expected_sketches_reports):
621621
try:
622622
distutils.dir_util.copy_tree(src=str(sketches_reports_path),
623623
dst=artifact_folder_object.name)
624-
except Exception:
624+
except Exception: # pragma: no cover
625625
artifact_folder_object.cleanup()
626626
raise
627627
sketches_reports = report_size_deltas.get_sketches_reports(artifact_folder_object=artifact_folder_object)
@@ -662,7 +662,7 @@ def test_generate_report():
662662
try:
663663
distutils.dir_util.copy_tree(src=str(sketches_report_path),
664664
dst=artifact_folder_object.name)
665-
except Exception:
665+
except Exception: # pragma: no cover
666666
artifact_folder_object.cleanup()
667667
raise
668668
sketches_reports = report_size_deltas.get_sketches_reports(artifact_folder_object=artifact_folder_object)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coverage:
2+
range: "100...100"
3+
status:
4+
project:
5+
default:
6+
threshold: 0%

libraries/report-size-trends/reportsizetrends/reportsizetrends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,4 +449,4 @@ def get_spreadsheet_column_letters_from_number(column_number):
449449

450450
# Only execute the following code if the script is run directly, not imported
451451
if __name__ == '__main__':
452-
main()
452+
main() # pragma: no cover
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
--requirement ../requirements.txt
2+
coverage==5.2.1
23
pytest==5.4.2
34
pytest-mock==3.1.0

libraries/report-size-trends/reportsizetrends/tests/test_reportsizetrends.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def values(self):
2525
return Service()
2626

2727
def get(self):
28-
pass
28+
pass # pragma: no cover
2929

3030
def update(self):
31-
pass
31+
pass # pragma: no cover
3232

3333
# noinspection PyPep8Naming
3434
def batchUpdate(self): # noqa: N802
35-
pass
35+
pass # pragma: no cover
3636

3737
def execute(self):
38-
pass
38+
pass # pragma: no cover
3939

4040

4141
reportsizetrends.set_verbosity(enable_verbosity=False)
@@ -113,7 +113,7 @@ def test_main(monkeypatch, mocker):
113113

114114
class ReportSizeTrends:
115115
def report_size_trends(self):
116-
pass
116+
pass # pragma: no cover
117117

118118
monkeypatch.setenv("INPUT_SKETCHES-REPORT-PATH", sketches_report_path)
119119
monkeypatch.setenv("INPUT_GOOGLE-KEY-FILE", google_key_file)

0 commit comments

Comments
 (0)