From 52fae72b119fc052bad24ad942ad110bcfa2e6bd Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Thu, 14 Dec 2023 18:01:58 -0700 Subject: [PATCH 01/10] chore: Update to new GHA artifacts process --- .github/workflows/checks.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index f263628b9..d783cc8f3 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -67,7 +67,7 @@ jobs: run: poetry run coverage xml -o coverage-${{ matrix.os }}-${{ matrix.python }}.xml - name: Store coverage report - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4.0.0 with: name: coverage-report path: coverage-${{ matrix.os }}-${{ matrix.python }}.xml @@ -78,12 +78,12 @@ jobs: steps: - uses: actions/checkout@v4.1.1 - name: Download coverage reports - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4.0.0 with: - name: coverage-report - - uses: codecov/codecov-action@v3 + path: coverage-report + - uses: codecov/codecov-action@v3.1.4 with: - files: "*.xml" + files: "coverage-report/**/*.xml" integration: name: Integration Tests From 123f5a437722a82680b6689816bf6a3c90138321 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Thu, 14 Dec 2023 18:04:51 -0700 Subject: [PATCH 02/10] ci: Unique artifact names per coverage report --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d783cc8f3..68b191792 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -69,7 +69,7 @@ jobs: - name: Store coverage report uses: actions/upload-artifact@v4.0.0 with: - name: coverage-report + name: coverage-${{ matrix.os }}-${{ matrix.python }} path: coverage-${{ matrix.os }}-${{ matrix.python }}.xml upload_coverage: From 1cb49f40bcf174921cd6ba9bd3f7e54f0d94472c Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Fri, 15 Dec 2023 09:54:05 -0700 Subject: [PATCH 03/10] ci: Swap off of codecov --- .github/workflows/checks.yml | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 68b191792..1f2cf2ac5 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -70,20 +70,39 @@ jobs: uses: actions/upload-artifact@v4.0.0 with: name: coverage-${{ matrix.os }}-${{ matrix.python }} - path: coverage-${{ matrix.os }}-${{ matrix.python }}.xml + path: .coverage - upload_coverage: + coverage: + name: Combine & check coverage needs: test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 + - uses: actions/setup-python@v4 + with: + python-version: "3.12" + - run: python -Im pip install --upgrade coverage[toml] - name: Download coverage reports uses: actions/download-artifact@v4.0.0 with: path: coverage-report - - uses: codecov/codecov-action@v3.1.4 + - name: Combine coverage & fail if it's <100%. + run: | + python -Im coverage combine --data-file coverage-report/**/* + python -Im coverage html --skip-covered --skip-empty + + # Report and write to summary. + python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY + + # Report again and fail if under 100%. + python -Im coverage report --fail-under=100 + + - name: Upload HTML report if check failed. + uses: actions/upload-artifact@v4.0.0 with: - files: "coverage-report/**/*.xml" + name: html-report + path: htmlcov + if: ${{ failure() }} integration: name: Integration Tests From 5ffbfb79fa6fbd1d141342984521ab22fc2a2697 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Fri, 15 Dec 2023 10:03:02 -0700 Subject: [PATCH 04/10] ci: Don't need coverage XML anymore --- .github/workflows/checks.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1f2cf2ac5..4a428bc6b 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -62,15 +62,12 @@ jobs: env: TASKIPY: true - - name: Generate coverage report - shell: bash - run: poetry run coverage xml -o coverage-${{ matrix.os }}-${{ matrix.python }}.xml - - name: Store coverage report uses: actions/upload-artifact@v4.0.0 with: name: coverage-${{ matrix.os }}-${{ matrix.python }} path: .coverage + if-no-files-found: error coverage: name: Combine & check coverage From edcca96ffeb392f7f74b30ab12fe1ab70f804319 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Fri, 15 Dec 2023 10:09:35 -0700 Subject: [PATCH 05/10] ci: Use `find` for combining coverage reports since globbing doesn't find .coverage --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 4a428bc6b..8d7127600 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -85,7 +85,7 @@ jobs: path: coverage-report - name: Combine coverage & fail if it's <100%. run: | - python -Im coverage combine --data-file coverage-report/**/* + find coverage-report -type f -name '.coverage' -exec coverage combine --data-file {} + python -Im coverage html --skip-covered --skip-empty # Report and write to summary. From 95e527d155b67a8c35b2c01be090d07985a2e830 Mon Sep 17 00:00:00 2001 From: Dylan Anthony Date: Fri, 15 Dec 2023 10:19:09 -0700 Subject: [PATCH 06/10] ci: Move combined coverage report to working dir --- .github/workflows/checks.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8d7127600..d368495d7 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -85,7 +85,12 @@ jobs: path: coverage-report - name: Combine coverage & fail if it's <100%. run: | + # Find all of the downloaded coverage reports and combine them find coverage-report -type f -name '.coverage' -exec coverage combine --data-file {} + + + # Move the combined report to the working directory + find coverage-report -type f -name '.coverage' -exec mv {} . \; + python -Im coverage html --skip-covered --skip-empty # Report and write to summary. From c079ae6b7792dc7c52b52eeb18a8c8e38ab84d53 Mon Sep 17 00:00:00 2001 From: Dylan Anthony <43723790+dbanty@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:51:12 +0000 Subject: [PATCH 07/10] Update to merge download --- .github/workflows/checks.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index d368495d7..b3cf89f45 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -61,12 +61,14 @@ jobs: run: poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp env: TASKIPY: true + + - run: mv .coverage .coverage.${{ matrix.os }}-${{ matrix.python }} - name: Store coverage report uses: actions/upload-artifact@v4.0.0 with: name: coverage-${{ matrix.os }}-${{ matrix.python }} - path: .coverage + path: .coverage.${{ matrix.os }}-${{ matrix.python }} if-no-files-found: error coverage: @@ -80,20 +82,19 @@ jobs: python-version: "3.12" - run: python -Im pip install --upgrade coverage[toml] - name: Download coverage reports - uses: actions/download-artifact@v4.0.0 + uses: actions/download-artifact@v4.1.0 with: - path: coverage-report + merge-multiple: true + - name: Combine coverage & fail if it's <100%. run: | # Find all of the downloaded coverage reports and combine them - find coverage-report -type f -name '.coverage' -exec coverage combine --data-file {} + - - # Move the combined report to the working directory - find coverage-report -type f -name '.coverage' -exec mv {} . \; + python -Im coverage combine + # Create html report python -Im coverage html --skip-covered --skip-empty - # Report and write to summary. + # Report in Markdown and write to summary. python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY # Report again and fail if under 100%. From b4f751e1c83d24a8fd88b0e6a4270894156971c4 Mon Sep 17 00:00:00 2001 From: Dylan Anthony <43723790+dbanty@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:01:36 +0000 Subject: [PATCH 08/10] Use a virtual env to try and fix paths --- .github/workflows/checks.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b3cf89f45..fcad1a648 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -80,25 +80,30 @@ jobs: - uses: actions/setup-python@v4 with: python-version: "3.12" - - run: python -Im pip install --upgrade coverage[toml] - name: Download coverage reports uses: actions/download-artifact@v4.1.0 with: merge-multiple: true + - name: Create Virtual Environment + run: python -m venv .venv + - name: Combine coverage & fail if it's <100%. run: | + # Install coverage + .venv/bin/pip install --upgrade coverage[toml] + # Find all of the downloaded coverage reports and combine them - python -Im coverage combine + .venv/bin/python -m coverage combine # Create html report - python -Im coverage html --skip-covered --skip-empty + .venv/bin/python -m coverage html --skip-covered --skip-empty # Report in Markdown and write to summary. - python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY + .venv/bin/python -m coverage report --format=markdown >> $GITHUB_STEP_SUMMARY # Report again and fail if under 100%. - python -Im coverage report --fail-under=100 + .venv/bin/python -m coverage report --fail-under=100 - name: Upload HTML report if check failed. uses: actions/upload-artifact@v4.0.0 From 61b560acd51be67aaf83cd40c9a5e9bfbc466b71 Mon Sep 17 00:00:00 2001 From: Dylan Anthony <43723790+dbanty@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:16:39 +0000 Subject: [PATCH 09/10] Only generate/store coverage for ubuntu --- .github/workflows/checks.yml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index fcad1a648..64ce025bd 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -57,18 +57,27 @@ jobs: - name: Lint run: poetry run ruff check . - - name: Run pytest + - name: Run pytest without coverage + if: matrix.os != 'ubuntu-latest' + run: poetry run pytest tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp + env: + TASKIPY: true + + - name: Run pytest with coverage + if: matrix.os == 'ubuntu-latest' run: poetry run pytest --cov=openapi_python_client --cov-report=term-missing tests end_to_end_tests/test_end_to_end.py --basetemp=tests/tmp env: TASKIPY: true - run: mv .coverage .coverage.${{ matrix.os }}-${{ matrix.python }} + if: matrix.os == 'ubuntu-latest' - name: Store coverage report uses: actions/upload-artifact@v4.0.0 + if: matrix.os == 'ubuntu-latest' with: - name: coverage-${{ matrix.os }}-${{ matrix.python }} - path: .coverage.${{ matrix.os }}-${{ matrix.python }} + name: coverage-${{ matrix.python }} + path: .coverage.${{ matrix.python }} if-no-files-found: error coverage: From ba8316529c31bf2c775c186b984764327d34bb6c Mon Sep 17 00:00:00 2001 From: Dylan Anthony <43723790+dbanty@users.noreply.github.com> Date: Tue, 26 Dec 2023 21:18:24 +0000 Subject: [PATCH 10/10] typo --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 64ce025bd..de924586e 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -69,7 +69,7 @@ jobs: env: TASKIPY: true - - run: mv .coverage .coverage.${{ matrix.os }}-${{ matrix.python }} + - run: mv .coverage .coverage.${{ matrix.python }} if: matrix.os == 'ubuntu-latest' - name: Store coverage report