diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c88bad7..3cf4b7b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -5,9 +5,6 @@ concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true -env: - CONDA_EXE: mamba - on: push: branches: @@ -18,6 +15,21 @@ on: jobs: + run-type-checking: + + name: Run tests for type-checking + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version-file: .python-version + allow-prereleases: true + cache: pip + - run: pip install tox-uv + - run: tox -e typing + run-tests: name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }} @@ -31,33 +43,29 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: conda-incubator/setup-miniconda@v2 + - uses: actions/setup-python@v5 with: - auto-update-conda: false python-version: ${{ matrix.python-version }} - channels: conda-forge,nodefaults - miniforge-variant: Mambaforge - - - name: Install core dependencies. - shell: bash -l {0} - run: mamba install -c conda-forge tox-conda coverage + cache: pip + allow-prereleases: true + - run: pip install tox-uv # Unit, integration, and end-to-end tests. - name: Run unit tests and doctests. shell: bash -l {0} - run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto + run: tox -e test -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto - - name: Upload coverage report for unit tests and doctests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F unit -c + - name: Upload unit test coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v4 + with: + flags: unit - name: Run end-to-end tests. shell: bash -l {0} - run: tox -e pytest -- -m end_to_end --cov=./ --cov-report=xml -n auto + run: tox -e test -- -m end_to_end --cov=./ --cov-report=xml -n auto - - name: Upload coverage reports of end-to-end tests. - if: runner.os == 'Linux' && matrix.python-version == '3.8' - shell: bash -l {0} - run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c + - name: Upload end_to_end test coverage reports to Codecov with GitHub Action + uses: codecov/codecov-action@v4 + with: + flags: end_to_end diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 326220f..143db7d 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -1,36 +1,91 @@ -name: PyPI +name: Publish Python 🐍 distribution 📦 to PyPI on: push jobs: - build-n-publish: - name: Build and publish Python 🐍 distributions 📦 to PyPI + build: + name: Build distribution 📦 runs-on: ubuntu-latest + steps: - uses: actions/checkout@v4 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python + uses: actions/setup-python@v5 with: - python-version: 3.8 - + python-version: "3.x" - name: Install pypa/build run: >- - python -m + python3 -m pip install build --user - - name: Build a binary wheel and a source tarball - run: >- - python -m - build - --sdist - --wheel - --outdir dist/ + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + publish-to-pypi: + name: Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pytask-stata + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ - name: Publish distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master + uses: pypa/gh-action-pypi-publish@release/v1 + + github-release: + name: >- + Sign the Python 🐍 distribution 📦 with Sigstore + and upload them to GitHub Release + needs: + - publish-to-pypi + runs-on: ubuntu-latest + + permissions: + contents: write # IMPORTANT: mandatory for making GitHub Releases + id-token: write # IMPORTANT: mandatory for sigstore + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Sign the dists with Sigstore + uses: sigstore/gh-action-sigstore-python@v2.1.1 with: - password: ${{ secrets.PYPI_API_TOKEN }} + inputs: >- + ./dist/*.tar.gz + ./dist/*.whl + - name: Create GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + run: >- + gh release create + '${{ github.ref_name }}' + --repo '${{ github.repository }}' + --notes "" + - name: Upload artifact signatures to GitHub Release + env: + GITHUB_TOKEN: ${{ github.token }} + # Upload to GitHub Release using the `gh` CLI. `dist/` contains the built + # packages, and the sigstore-produced signatures and certificates. + run: >- + gh release upload + '${{ github.ref_name }}' dist/** + --repo '${{ github.repository }}' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index babb3b3..1b3d6c9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,10 +24,6 @@ repos: - id: python-no-log-warn - id: python-use-type-annotations - id: text-unicode-replacement-char -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.5.0 - hooks: - - id: setup-cfg-fmt - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.4.4 hooks: diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..8531a3b --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.12.2 diff --git a/pyproject.toml b/pyproject.toml index 325a11b..ba0323d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,51 @@ requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"] build-backend = "setuptools.build_meta" +[project] +name = "pytask_stata" +description = "Execute do-files with Stata and pytask." +authors = [{ name = "Tobias Raabe", email = "raabe@posteo.de" }] +license = { text = "MIT" } +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", +] +requires-python = ">=3.8" +dependencies = ["click", "pytask>=0.3,<0.4"] +dynamic = ["version"] + +[project.readme] +file = "README.md" +content-type = "text/markdown" + +[project.optional-dependencies] +test = ["pytest", "pytest-cov", "pytest-xdist"] +typing = ["mypy"] + +[project.urls] +Homepage = "https://github.com/pytask-dev/pytask-stata" +Documentation = "https://github.com/pytask-dev/pytask-stata" +Github = "https://github.com/pytask-dev/pytask-stata" +Tracker = "https://github.com/pytask-dev/pytask-stata/issues" +Changelog = "https://github.com/pytask-dev/pytask-stata/blob/main/CHANGES.md" + +[project.entry-points] +pytask = { pytask_stata = "pytask_stata.plugin" } + +[tool.setuptools] +include-package-data = true +package-dir = { "" = "src" } +zip-safe = false +platforms = ["any"] +license-files = ["LICENSE"] + +[tool.setuptools.packages.find] +where = ["src"] +namespaces = false + [tool.setuptools_scm] write_to = "src/pytask_stata/_version.py" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 74d0861..0000000 --- a/setup.cfg +++ /dev/null @@ -1,43 +0,0 @@ -[metadata] -name = pytask_stata -description = Execute do-files with Stata and pytask. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/pytask-dev/pytask-stata -author = Tobias Raabe -author_email = raabe@posteo.de -license = MIT -license_files = LICENSE -platforms = any -classifiers = - Development Status :: 4 - Beta - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only -project_urls = - Documentation = https://github.com/pytask-dev/pytask-stata - Github = https://github.com/pytask-dev/pytask-stata - Tracker = https://github.com/pytask-dev/pytask-stata/issues - Changelog = https://github.com/pytask-dev/pytask-stata/blob/main/CHANGES.md - -[options] -packages = find: -install_requires = - click - pytask>=0.3 -python_requires = >=3.8 -include_package_data = True -package_dir = =src -zip_safe = False - -[options.packages.find] -where = src - -[options.entry_points] -pytask = - pytask_stata = pytask_stata.plugin - -[check-manifest] -ignore = - src/pytask_stata/_version.py diff --git a/tox.ini b/tox.ini index 0486889..9e987c9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,17 +1,14 @@ [tox] -envlist = pytest +requires = tox>=4 +envlist = docs, mypy [testenv] -usedevelop = true +package = editable -[testenv:pytest] -conda_channels = - conda-forge - nodefaults -conda_deps = - pytask =0.3 - pytest - pytest-cov - pytest-xdist -commands = - pytest {posargs} +[testenv:typing] +extras = typing +commands = - mypy + +[testenv:test] +extras = test +commands = pytest {posargs}