From 9479b45e016202b8dca9872cc7f6daed16ef8843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Tue, 17 Sep 2024 16:55:51 -0700 Subject: [PATCH] Improve the CI (#123) --- .github/workflows/check.yaml | 52 ++++++++++++++++++++++++ .github/workflows/check.yml | 72 ---------------------------------- .github/workflows/release.yaml | 48 +++++++++++++++++++++++ .github/workflows/release.yml | 29 -------------- README.md | 7 +--- tox.ini | 18 ++++----- 6 files changed, 111 insertions(+), 115 deletions(-) create mode 100644 .github/workflows/check.yaml delete mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/release.yaml delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..5ec2ba9 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,52 @@ +name: check +on: + workflow_dispatch: + push: + branches: ["main"] + tags-ignore: ["**"] + pull_request: + schedule: + - cron: "0 8 * * *" + +concurrency: + group: check-${{ github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + env: + - "3.13" + - "3.12" + - "3.11" + - "3.10" + - "3.9" + - "3.8" + - type + - dev + - pkg_meta + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: "pyproject.toml" + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Install tox + run: uv tool install --python-preference only-managed --python 3.13 tox --with tox-uv + - name: Install Python + if: startsWith(matrix.env, '3.') && matrix.env != '3.13' + run: uv python install --python-preference only-managed ${{ matrix.env }} + - name: Setup test suite + run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.env }} + - name: Run test suite + run: tox run --skip-pkg-install -e ${{ matrix.env }} + env: + PYTEST_ADDOPTS: "-vv --durations=20" + DIFF_AGAINST: HEAD diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml deleted file mode 100644 index 5da3bb1..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,72 +0,0 @@ -name: check -on: - workflow_dispatch: - push: - branches: ["main"] - tags-ignore: ["**"] - pull_request: - schedule: - - cron: "0 8 * * *" - -concurrency: - group: check-${{ github.ref }} - cancel-in-progress: true - -jobs: - test: - name: test ${{ matrix.py }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - py: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - - "3.9" - - "3.8" - steps: - - name: setup uv for tox - uses: yezz123/setup-uv@v4 - - name: setup python for tox - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: install tox - run: uv pip install tox tox-uv --system - - uses: actions/checkout@v4 - - name: setup python for test ${{ matrix.py }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.py }} - allow-prereleases: true - - name: setup test suite - run: tox run -vv --notest --skip-missing-interpreters false -e ${{ matrix.py }} - - name: run test suite - run: tox run --skip-pkg-install -e ${{ matrix.py }} - - check: - name: tox env ${{ matrix.tox_env }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tox_env: - - type - - dev - - readme - steps: - - name: setup uv for tox - uses: yezz123/setup-uv@v4 - - uses: actions/checkout@v4 - - name: setup Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: install tox - run: uv pip install tox tox-uv --system - - name: Setup test suite - run: tox -vv --notest --skip-missing-interpreters false -e ${{ matrix.tox_env }} - - name: Run test suite - run: tox --skip-pkg-install -e ${{ matrix.tox_env }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..769ab06 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,48 @@ +name: Release to PyPI +on: + push: + tags: ["*"] + +env: + dists-artifact-name: python-package-distributions + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Install the latest version of uv + uses: astral-sh/setup-uv@v3 + with: + enable-cache: true + cache-dependency-glob: "pyproject.toml" + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Build package + run: uv build --python 3.13 --python-preference only-managed --sdist --wheel . --out-dir dist + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: ${{ env.dists-artifact-name }} + path: dist/* + + release: + needs: + - build + runs-on: ubuntu-latest + environment: + name: release + url: https://pypi.org/project/pytest-print/${{ github.ref_name }} + permissions: + id-token: write + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: ${{ env.dists-artifact-name }} + path: dist/ + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@v1.10.1 + with: + attestations: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index bcac60f..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Release to PyPI -on: - push: - tags: ["*"] - -jobs: - release: - runs-on: ubuntu-latest - environment: - name: release - url: https://pypi.org/p/pytest-print - permissions: - id-token: write - steps: - - name: Setup python to build package - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: setup uv for tox - uses: yezz123/setup-uv@v4 - - name: Install build - run: uv pip install build[uv] --system - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build package - run: pyproject-build --installer uv --sdist --wheel . --outdir dist - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/README.md b/README.md index d969aff..a504f56 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,7 @@ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pytest-print?style=flat-square)](https://pypi.org/project/pytest-print) [![Downloads](https://static.pepy.tech/badge/pytest-print/month)](https://pepy.tech/project/pytest-print) [![PyPI - License](https://img.shields.io/pypi/l/pytest-print?style=flat-square)](https://opensource.org/licenses/MIT) -[![check](https://github.com/pytest-dev/pytest-print/workflows/check/badge.svg)](https://github.com/pytest-dev/pytest-print/actions?query=workflow%3Acheck) -[![Code style: -black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black) +[![check](https://github.com/pytest-dev/pytest-print/actions/workflows/check.yaml/badge.svg)](https://github.com/pytest-dev/pytest-print/actions/workflows/check.yaml) Allows to print extra content onto the PyTest reporting. This can be used for example to report sub-steps for long running tests, or to print debug information in your tests when you cannot debug the code. @@ -31,8 +29,7 @@ The plugin provides ability to print information during the tests runs. ### sub-step reporting -For tests that are long running this can provide a feedback to the end-user that what is just happening in the -background. +For tests that are long running this can provide feedback to the end-user that what is just happening in the background. ```python def test_server_parallel_requests(printer, tmpdir): diff --git a/tox.ini b/tox.ini index 7c57197..d16441d 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ env_list = 3.9 3.8 type - readme + pkg_meta skip_missing_interpreters = true [testenv] @@ -20,15 +20,15 @@ wheel_build_env = .pkg extras = test set_env = - COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}{/}.coverage.{envname}} + COVERAGE_FILE = {env:COVERAGE_FILE:{work_dir}{/}.coverage.{env_name}} commands = coverage erase coverage run -m pytest {tty:--color=yes} \ - --junitxml {toxworkdir}{/}junit.{envname}.xml \ + --junitxml {work_dir}{/}junit.{env_name}.xml \ {posargs:tests} coverage combine coverage report - coverage html -d {envtmpdir}{/}htmlcov + coverage html -d {env_tmp_dir}{/}htmlcov [testenv:fix] description = run static analysis and style check using flake8 @@ -49,17 +49,17 @@ commands = mypy --strict src mypy --strict tests -[testenv:readme] +[testenv:pkg_meta] description = check that the long description is valid skip_install = true deps = - build[uv]>=1.2.2 check-wheel-contents>=0.6 twine>=5.1.1 + uv>=0.4.10 commands = - pyproject-build --installer uv --outdir {envtmpdir} --sdist --wheel . - twine check {envtmpdir}{/}* - check-wheel-contents --no-config {envtmpdir} + uv build --sdist --wheel --out-dir {env_tmp_dir} . + twine check {env_tmp_dir}{/}* + check-wheel-contents --no-config {env_tmp_dir} [testenv:dev] description = generate a DEV environment