From c2cee79a570caf6a7c00c0c7db96cc16e50c9b80 Mon Sep 17 00:00:00 2001 From: benyissa Date: Tue, 16 Jul 2024 14:33:55 +0100 Subject: [PATCH 1/2] Add code coverage to workflow --- .github/workflows/pytest.yml | 54 +++++++++++++++++++----------------- tests/test-requirement.txt | 1 + 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 248bf32..2f0cfe7 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -1,4 +1,3 @@ ---- # This workflow use pytest: # - Install Python dependencies. # - Run pytest for each of the supported Python versions ["3.8", "3.9", "3.10"]. @@ -9,15 +8,14 @@ name: Pytest. on: push: branches: - - main + - main pull_request: branches: - - '*' - + - '*' concurrency: group: ${{ github.ref }} cancel-in-progress: true - + jobs: build: @@ -28,23 +26,29 @@ jobs: python-version: ["3.11"] steps: - - uses: actions/checkout@v2 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: Install Metasploit. - run: | - sudo snap install metasploit-framework - msfdb init - msfrpcd -P Ostorlab123 -p 55555 - - name: Install dependencies. - run: | - python -m pip install --upgrade pip - python -m pip install -e tools/pymetasploit3 - python -m pip install -r requirement.txt - python -m pip install -r tests/test-requirement.txt - - name: Running tests with pytest. - run: | - set -o pipefail - pytest -m "not docker" tests/ + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Metasploit. + run: | + sudo snap install metasploit-framework + msfdb init + msfrpcd -P Ostorlab123 -p 55555 + - name: Install dependencies. + run: | + python -m pip install --upgrade pip + python -m pip install -e tools/pymetasploit3 + python -m pip install -r requirement.txt + python -m pip install -r tests/test-requirement.txt + - name: Running tests with pytest. + run: | + set -o pipefail + pytest -m "not docker" --cov=./ --cov-report=xml:coverage.xml --cov-report=term-missing + - name: Upload coverage to Codecov. + uses: codecov/codecov-action@v4 + with: + verbose: true + token: ${{ secrets.CODECOV_TOKEN }} + file: coverage.xml diff --git a/tests/test-requirement.txt b/tests/test-requirement.txt index 34b28e8..f8b09c8 100644 --- a/tests/test-requirement.txt +++ b/tests/test-requirement.txt @@ -1,4 +1,5 @@ pytest +pytest-cov mypy pytest_mock # Typing requirements. From fa2233da9a2c6d4d1be8da8c3cff55388d222005 Mon Sep 17 00:00:00 2001 From: benyissa Date: Wed, 17 Jul 2024 11:45:06 +0100 Subject: [PATCH 2/2] specify tests --- .github/workflows/pytest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 2f0cfe7..2759f29 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -45,7 +45,7 @@ jobs: - name: Running tests with pytest. run: | set -o pipefail - pytest -m "not docker" --cov=./ --cov-report=xml:coverage.xml --cov-report=term-missing + pytest -m "not docker" tests/ --cov=./ --cov-report=xml:coverage.xml --cov-report=term-missing - name: Upload coverage to Codecov. uses: codecov/codecov-action@v4 with: