-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run pytest on PR/push. Fix main run test. Add coverage/license/build pass badges to README Create pytest comment on PR --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c3c766d
commit 4010f15
Showing
10 changed files
with
112 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: pytest-coverage-comment | ||
on: | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python_version: ["3.8", "3.9", "3.10", "3.11"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python_version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
if [ -f requirements_dev.txt ]; then pip3 install -r requirements_dev.txt; fi | ||
- name: Build coverage file | ||
run: | | ||
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered | tee pytest-coverage.txt | ||
- name: Pytest coverage comment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
pytest-coverage-path: ./pytest-coverage.txt | ||
junitxml-path: ./pytest.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# From: https://github.com/marketplace/actions/pytest-coverage-comment | ||
name: Update Coverage in Readme | ||
on: | ||
push: | ||
jobs: | ||
update-coverage-on-readme: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token | ||
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo | ||
|
||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.11 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
if [ -f requirements_dev.txt ]; then pip3 install -r requirements_dev.txt; fi | ||
- name: Build coverage file | ||
run: | | ||
pytest --junitxml=pytest.xml --cov | tee data/pytest-coverage.txt | ||
- name: Pytest coverage comment | ||
id: coverageComment | ||
uses: MishaKav/pytest-coverage-comment@main | ||
with: | ||
hide-comment: true | ||
pytest-coverage-path: ./data/pytest-coverage.txt | ||
|
||
- name: Update Readme with Coverage Html | ||
run: | | ||
sed -i '/<!-- Pytest Coverage Comment:Begin -->/,/<!-- Pytest Coverage Comment:End -->/c\![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/p-rintz/netbox-dnsmasq/pytest-push.yml)![GitHub](https://img.shields.io/github/license/p-rintz/netbox-dnsmasq?color=brightgreen&style=flat)<!-- Pytest Coverage Comment:Begin -->\n\${{ steps.coverageComment.outputs.coverageHtml }}\n<!-- Pytest Coverage Comment:End -->' ./README.md | ||
- name: Commit & Push changes to Readme | ||
uses: actions-js/push@master | ||
with: | ||
message: Update coverage on Readme | ||
branch: ${{ github.ref_name }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ dhcphosts.conf | |
dnsmasq.hosts | ||
/Dockerfile-* # Test Dockerfiles | ||
.coverage | ||
|
||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
============================= test session starts ============================== | ||
platform linux -- Python 3.11.2, pytest-7.2.1, pluggy-1.0.0 | ||
rootdir: /home/runner/work/netbox-dnsmasq/netbox-dnsmasq | ||
plugins: cov-4.0.0, recording-0.12.2 | ||
collected 14 items | ||
|
||
tests/test_netbox-dnsmasq.py .............. [100%] | ||
|
||
- generated xml file: /home/runner/work/netbox-dnsmasq/netbox-dnsmasq/pytest.xml - | ||
|
||
---------- coverage: platform linux, python 3.11.2-final-0 ----------- | ||
Name Stmts Miss Cover | ||
-------------------------------------------------- | ||
netbox_dnsmasq.py 180 8 96% | ||
tests/__init__.py 0 0 100% | ||
tests/conftest.py 29 0 100% | ||
tests/test_netbox-dnsmasq.py 76 0 100% | ||
-------------------------------------------------- | ||
TOTAL 285 8 97% | ||
|
||
============================== 14 passed in 1.36s ============================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="14" time="1.379" timestamp="2023-02-27T04:10:58.426150" hostname="fv-az399-857"><testcase classname="tests.test_netbox-dnsmasq" name="test_format_dns" time="0.014" /><testcase classname="tests.test_netbox-dnsmasq" name="test_format_dns_merged" time="0.012" /><testcase classname="tests.test_netbox-dnsmasq" name="test_format_dhcp" time="0.013" /><testcase classname="tests.test_netbox-dnsmasq" name="test_write_config" time="0.014" /><testcase classname="tests.test_netbox-dnsmasq" name="test_write_config_denied" time="0.013" /><testcase classname="tests.test_netbox-dnsmasq" name="test_get_ip_data" time="0.190" /><testcase classname="tests.test_netbox-dnsmasq" name="test_check_duplicates" time="0.013" /><testcase classname="tests.test_netbox-dnsmasq" name="test_check_duplicates_no_remove" time="0.013" /><testcase classname="tests.test_netbox-dnsmasq" name="test_import_config[True]" time="0.012" /><testcase classname="tests.test_netbox-dnsmasq" name="test_import_config[False]" time="0.012" /><testcase classname="tests.test_netbox-dnsmasq" name="test_import_config_missing_env" time="0.012" /><testcase classname="tests.test_netbox-dnsmasq" name="test_main_help[-h]" time="0.015" /><testcase classname="tests.test_netbox-dnsmasq" name="test_main_help[--help]" time="0.013" /><testcase classname="tests.test_netbox-dnsmasq" name="test_main_run" time="0.190" /></testsuite></testsuites> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
pytest~=7.2.1 | ||
coverage==7.2.1 | ||
pytest-cov~=4.0.0 | ||
pynetbox~=7.0.1 | ||
vcrpy~=4.2.1 | ||
pytest-recording~=0.12.2 | ||
loguru~=0.6.0 | ||
loguru~=0.6.0 | ||
flake8~=6.0.0 | ||
black~=23.1.0 | ||
isort~=5.12.0 | ||
mypy~=1.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters