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 06c42ba..0000000 --- a/.github/workflows/check.yml +++ /dev/null @@ -1,87 +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 }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - py: - - "3.13" - - "3.12" - - "3.11" - - "3.10" - - "3.9" - - "3.8" - os: - - ubuntu-latest - - steps: - - name: Setup python for tox - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup python for test ${{ matrix.py }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.py }} - allow-prereleases: true - - name: Pick environment to run - run: | - import codecs; import os; import sys - env = "TOXENV=py{}{}\n".format(*sys.version_info[0:2]) - print("Picked:\n{}for{}".format(env, sys.version)) - with codecs.open(os.environ["GITHUB_ENV"], "a", "utf-8") as file_handler: - file_handler.write(env) - shell: python - - 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 }} - env: - CI_RUN: "yes" - - check: - name: ${{ matrix.tox_env }} - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: - - ubuntu-latest - tox_env: - - dev - - type - - readme - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Setup Python "3.12" - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install tox - run: python -m pip install tox-uv - - 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..4b8785a --- /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-env/${{ 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 3bd88d6..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Release to PyPI -on: - push: - tags: ["*"] - -jobs: - release: - runs-on: ubuntu-latest - environment: - name: release - url: https://pypi.org/p/pytest-env - permissions: - id-token: write - steps: - - name: Setup python to build package - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - name: Install build - run: python -m pip install build - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Build package - run: pyproject-build -s -w . -o dist - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.10.1 diff --git a/pyproject.toml b/pyproject.toml index 577b90d..c9e6514 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,10 +38,10 @@ dynamic = [ "version", ] dependencies = [ - "pytest>=8.3.2", + "pytest>=8.3.3", "tomli>=2.0.1; python_version<'3.11'", ] -optional-dependencies.test = [ +optional-dependencies.testing = [ "covdefaults>=2.3", "coverage>=7.6.1", "pytest-mock>=3.14", diff --git a/tox.ini b/tox.ini index 933e0b4..d27b30a 100644 --- a/tox.ini +++ b/tox.ini @@ -10,7 +10,7 @@ env_list = 3.10 3.9 type - readme + pkg_meta skip_missing_interpreters = true [testenv] @@ -18,7 +18,10 @@ description = run the tests with pytest package = wheel wheel_build_env = .pkg extras = - test + testing +pass_env = + DIFF_AGAINST + PYTES_* set_env = COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}{/}.coverage.{envname}} commands = @@ -34,7 +37,7 @@ commands = description = run static analysis and style check using flake8 skip_install = true deps = - pre-commit-uv>=4.1 + pre-commit-uv>=4.1.1 pass_env = HOMEPATH PROGRAMDATA @@ -49,22 +52,23 @@ 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 -change_dir = {toxinidir} + uv>=0.4.10 commands = - pyproject-build --installer uv -o {envtmpdir} . - twine check {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 package = editable extras = - test + testing commands = uv pip tree python -c 'import sys; print(sys.executable)'