summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGaige B Paulsen <gaige@cluetrust.com>2025-01-25 12:47:55 -0500
committerGitHub <noreply@github.com>2025-01-25 12:47:55 -0500
commitfda50fe09d21b365264c6213bc5883201c460a29 (patch)
treece4124381fdcf3617e56e9640aef6889ee6e9ace
parentaab4d38f6cd41eb9a94b34c256f26d55d1e71654 (diff)
downloadvyos.vyos-fda50fe09d21b365264c6213bc5883201c460a29.tar.gz
vyos.vyos-fda50fe09d21b365264c6213bc5883201c460a29.zip
T7088:Code coverage fix (#376)
* Update codecoverage.yml * fix: badge for Coverage
-rw-r--r--.github/workflows/codecoverage.yml62
-rw-r--r--README.md2
-rw-r--r--changelogs/fragments/T7088-codecoverage.yml3
3 files changed, 62 insertions, 5 deletions
diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml
index 458878c..a8a3d65 100644
--- a/.github/workflows/codecoverage.yml
+++ b/.github/workflows/codecoverage.yml
@@ -1,5 +1,7 @@
---
name: Code Coverage
+# cloned from ansible-network/github_actions/.github/workflows/coverage_network_devices.yml@main
+# in order to deal with token issue in codecov
on: # yamllint disable-line rule:truthy
push:
@@ -7,10 +9,62 @@ on: # yamllint disable-line rule:truthy
branches: [main]
jobs:
codecoverage:
- uses: ansible-network/github_actions/.github/workflows/coverage_network_devices.yml@main
- with:
+ env:
+ PY_COLORS: "1"
+ source_directory: "./source"
+ python_version: "3.10"
+ ansible_version: "latest"
+ os: "ubuntu-latest"
collection_pre_install: >-
git+https://github.com/ansible-collections/ansible.utils.git
git+https://github.com/ansible-collections/ansible.netcommon.git
- secrets:
- token: ${{ secrets.CODECOV_TOKEN }}
+ runs-on: ubuntu-latest
+ name: "Code Coverage | Python 3.10"
+ steps:
+ - name: Checkout the collection repository
+ uses: ansible-network/github_actions/.github/actions/checkout_dependency@main
+ with:
+ path: ${{ env.source_directory }}
+ ref: ${{ github.event.pull_request.head.sha }}
+ fetch-depth: "0"
+
+ - name: Set up Python ${{ env.python_version }}
+ uses: actions/setup-python@v4
+ with:
+ python-version: ${{ env.python_version }}
+
+ - name: Install ansible-core (${{ env.ansible-version }})
+ run: python3 -m pip install ansible-core pytest pytest-cov pytest-ansible-units pytest-forked pytest-xdist
+
+ - name: Read collection metadata from galaxy.yml
+ id: identify
+ uses: ansible-network/github_actions/.github/actions/identify_collection@main
+ with:
+ source_path: ${{ env.source_directory }}
+
+ - name: Build and install the collection
+ uses: ansible-network/github_actions/.github/actions/build_install_collection@main
+ with:
+ install_python_dependencies: true
+ source_path: ${{ env.source_directory }}
+ collection_path: ${{ steps.identify.outputs.collection_path }}
+ tar_file: ${{ steps.identify.outputs.tar_file }}
+
+ - name: Print the ansible version
+ run: ansible --version
+
+ - name: Print the python dependencies
+ run: python3 -m pip list
+
+ - name: Run Coverage tests
+ run: |
+ pytest tests/unit -v --cov-report xml --cov=./
+ working-directory: ${{ steps.identify.outputs.collection_path }}
+
+ - name: Upload coverage report to Codecov
+ uses: codecov/codecov-action@v4
+ with:
+ directory: ${{ steps.identify.outputs.collection_path }}
+ fail_ci_if_error: false
+ env:
+ CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
diff --git a/README.md b/README.md
index c3f8d0b..52c9e9e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# VyOS Collection
-[![Codecov](https://codecov.io/gh/vyos/vyos.vyos/branch/main/graph/badge.svg)](https://codecov.io/gh/ansible-collections/vyos.vyos)
+[![codecov](https://codecov.io/gh/vyos/vyos.vyos/graph/badge.svg?token=J217GFD69W)](https://codecov.io/gh/vyos/vyos.vyos)
[![CI](https://github.com/vyos/vyos.vyos/actions/workflows/tests.yml/badge.svg?branch=main&event=schedule)](https://github.com/vyos/vyos.vyos/actions/workflows/tests.yml)
The Ansible VyOS collection includes a variety of Ansible content to help automate the management of VyOS network appliances.
diff --git a/changelogs/fragments/T7088-codecoverage.yml b/changelogs/fragments/T7088-codecoverage.yml
new file mode 100644
index 0000000..6925c85
--- /dev/null
+++ b/changelogs/fragments/T7088-codecoverage.yml
@@ -0,0 +1,3 @@
+---
+trivial:
+ - use our own code coverage