From 5ca78310e863c8ae96a294d466b25c32c8a3a62a Mon Sep 17 00:00:00 2001 From: Ryan Frederich Date: Sat, 17 Aug 2024 18:29:31 -0700 Subject: [PATCH 1/2] pytest coverage badge! --- .github/workflows/pytest.yml | 64 +++++++++++++++++++++--------------- README.md | 1 + 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 9af7722..1e684ec 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -12,36 +12,46 @@ defaults: jobs: test: + name: Run tests and collect coverage strategy: matrix: os: [ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v4 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: '3.10' - - - name: Prepare environment file - run: cp .env.example .env - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install poetry - poetry config installer.max-workers 10 - poetry install --no-interaction --no-ansi - - - name: Test with pytest - run: | - poetry run python -m pytest --junitxml=pytest.xml --cov-report=term-missing --cov=src tests/ | tee pytest-coverage.txt - - - name: Pytest coverage comment - if: matrix.os == 'ubuntu-latest' - continue-on-error: true - uses: MishaKav/pytest-coverage-comment@v1.1.47 - with: - pytest-coverage-path: ./pytest-coverage.txt - junitxml-path: ./pytest.xml + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Prepare environment file + run: cp .env.example .env + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install poetry + poetry config installer.max-workers 10 + poetry install --no-interaction --no-ansi + + - name: Run tests + run: | + poetry run python -m pytest --junitxml=pytest.xml --cov-report=term-missing --cov=src tests/ | tee pytest-coverage.txt + + - name: Upload results to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + + - name: Pytest coverage comment + if: matrix.os == 'ubuntu-latest' + continue-on-error: true + uses: MishaKav/pytest-coverage-comment@v1.1.47 + with: + pytest-coverage-path: ./pytest-coverage.txt + junitxml-path: ./pytest.xml \ No newline at end of file diff --git a/README.md b/README.md index 3fc7c34..8af63f1 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ ![pytest](https://github.com/ryansurf/cli-surf/actions/workflows/pytest.yml/badge.svg) ![linter](https://github.com/ryansurf/cli-surf/actions/workflows/linter.yml/badge.svg) +[![codecov](https://codecov.io/github/ryansurf/cli-surf/graph/badge.svg?token=N8CAIUXMJG)](https://codecov.io/github/ryansurf/cli-surf)

From 0d7024cce4881aa3c186321c194a48614caa60f5 Mon Sep 17 00:00:00 2001 From: Ryan Frederich Date: Mon, 19 Aug 2024 12:23:14 -0700 Subject: [PATCH 2/2] pytest changes test --- .github/workflows/pytest.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index 1e684ec..8b4947a 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -39,19 +39,22 @@ jobs: poetry config installer.max-workers 10 poetry install --no-interaction --no-ansi - - name: Run tests - run: | - poetry run python -m pytest --junitxml=pytest.xml --cov-report=term-missing --cov=src tests/ | tee pytest-coverage.txt + # - name: Run tests + # run: | + # poetry run python -m pytest --junitxml=pytest.xml --cov-report=term-missing --cov=src tests/ | tee pytest-coverage.txt + + - name: Run tests and collect coverage + run: poetry run pytest --cov=./src --cov-report=xml - name: Upload results to Codecov uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - - name: Pytest coverage comment - if: matrix.os == 'ubuntu-latest' - continue-on-error: true - uses: MishaKav/pytest-coverage-comment@v1.1.47 - with: - pytest-coverage-path: ./pytest-coverage.txt - junitxml-path: ./pytest.xml \ No newline at end of file + # - name: Pytest coverage comment + # if: matrix.os == 'ubuntu-latest' + # continue-on-error: true + # uses: MishaKav/pytest-coverage-comment@v1.1.47 + # with: + # pytest-coverage-path: ./pytest-coverage.txt + # junitxml-path: ./pytest.xml \ No newline at end of file