Skip to content

Commit ae2334f

Browse files
authored
Update CI. (#37)
1 parent ca53e5b commit ae2334f

7 files changed

+159
-100
lines changed

.github/workflows/main.yml

+29-21
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ concurrency:
55
group: ${{ github.head_ref || github.run_id }}
66
cancel-in-progress: true
77

8-
env:
9-
CONDA_EXE: mamba
10-
118
on:
129
push:
1310
branches:
@@ -18,6 +15,21 @@ on:
1815

1916
jobs:
2017

18+
run-type-checking:
19+
20+
name: Run tests for type-checking
21+
runs-on: ubuntu-latest
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-python@v5
26+
with:
27+
python-version-file: .python-version
28+
allow-prereleases: true
29+
cache: pip
30+
- run: pip install tox-uv
31+
- run: tox -e typing
32+
2133
run-tests:
2234

2335
name: Run tests for ${{ matrix.os }} on ${{ matrix.python-version }}
@@ -31,33 +43,29 @@ jobs:
3143

3244
steps:
3345
- uses: actions/checkout@v4
34-
- uses: conda-incubator/setup-miniconda@v2
46+
- uses: actions/setup-python@v5
3547
with:
36-
auto-update-conda: false
3748
python-version: ${{ matrix.python-version }}
38-
channels: conda-forge,nodefaults
39-
miniforge-variant: Mambaforge
40-
41-
- name: Install core dependencies.
42-
shell: bash -l {0}
43-
run: mamba install -c conda-forge tox-conda coverage
49+
cache: pip
50+
allow-prereleases: true
51+
- run: pip install tox-uv
4452

4553
# Unit, integration, and end-to-end tests.
4654

4755
- name: Run unit tests and doctests.
4856
shell: bash -l {0}
49-
run: tox -e pytest -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
57+
run: tox -e test -- -m "unit or (not integration and not end_to_end)" --cov=./ --cov-report=xml -n auto
5058

51-
- name: Upload coverage report for unit tests and doctests.
52-
if: runner.os == 'Linux' && matrix.python-version == '3.8'
53-
shell: bash -l {0}
54-
run: bash <(curl -s https://codecov.io/bash) -F unit -c
59+
- name: Upload unit test coverage reports to Codecov with GitHub Action
60+
uses: codecov/codecov-action@v4
61+
with:
62+
flags: unit
5563

5664
- name: Run end-to-end tests.
5765
shell: bash -l {0}
58-
run: tox -e pytest -- -m end_to_end --cov=./ --cov-report=xml -n auto
66+
run: tox -e test -- -m end_to_end --cov=./ --cov-report=xml -n auto
5967

60-
- name: Upload coverage reports of end-to-end tests.
61-
if: runner.os == 'Linux' && matrix.python-version == '3.8'
62-
shell: bash -l {0}
63-
run: bash <(curl -s https://codecov.io/bash) -F end_to_end -c
68+
- name: Upload end_to_end test coverage reports to Codecov with GitHub Action
69+
uses: codecov/codecov-action@v4
70+
with:
71+
flags: end_to_end

.github/workflows/publish-to-pypi.yml

+74-19
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,91 @@
1-
name: PyPI
1+
name: Publish Python 🐍 distribution 📦 to PyPI
22

33
on: push
44

55
jobs:
6-
build-n-publish:
7-
name: Build and publish Python 🐍 distributions 📦 to PyPI
6+
build:
7+
name: Build distribution 📦
88
runs-on: ubuntu-latest
9+
910
steps:
1011
- uses: actions/checkout@v4
11-
12-
- name: Set up Python 3.8
13-
uses: actions/setup-python@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
1414
with:
15-
python-version: 3.8
16-
15+
python-version: "3.x"
1716
- name: Install pypa/build
1817
run: >-
19-
python -m
18+
python3 -m
2019
pip install
2120
build
2221
--user
23-
2422
- name: Build a binary wheel and a source tarball
25-
run: >-
26-
python -m
27-
build
28-
--sdist
29-
--wheel
30-
--outdir dist/
23+
run: python3 -m build
24+
- name: Store the distribution packages
25+
uses: actions/upload-artifact@v4
26+
with:
27+
name: python-package-distributions
28+
path: dist/
3129

30+
publish-to-pypi:
31+
name: Publish Python 🐍 distribution 📦 to PyPI
32+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
33+
needs:
34+
- build
35+
runs-on: ubuntu-latest
36+
environment:
37+
name: pypi
38+
url: https://pypi.org/p/pytask-stata
39+
permissions:
40+
id-token: write # IMPORTANT: mandatory for trusted publishing
41+
42+
steps:
43+
- name: Download all the dists
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: python-package-distributions
47+
path: dist/
3248
- name: Publish distribution 📦 to PyPI
33-
if: startsWith(github.ref, 'refs/tags')
34-
uses: pypa/gh-action-pypi-publish@master
49+
uses: pypa/gh-action-pypi-publish@release/v1
50+
51+
github-release:
52+
name: >-
53+
Sign the Python 🐍 distribution 📦 with Sigstore
54+
and upload them to GitHub Release
55+
needs:
56+
- publish-to-pypi
57+
runs-on: ubuntu-latest
58+
59+
permissions:
60+
contents: write # IMPORTANT: mandatory for making GitHub Releases
61+
id-token: write # IMPORTANT: mandatory for sigstore
62+
63+
steps:
64+
- name: Download all the dists
65+
uses: actions/download-artifact@v4
66+
with:
67+
name: python-package-distributions
68+
path: dist/
69+
- name: Sign the dists with Sigstore
70+
uses: sigstore/[email protected]
3571
with:
36-
password: ${{ secrets.PYPI_API_TOKEN }}
72+
inputs: >-
73+
./dist/*.tar.gz
74+
./dist/*.whl
75+
- name: Create GitHub Release
76+
env:
77+
GITHUB_TOKEN: ${{ github.token }}
78+
run: >-
79+
gh release create
80+
'${{ github.ref_name }}'
81+
--repo '${{ github.repository }}'
82+
--notes ""
83+
- name: Upload artifact signatures to GitHub Release
84+
env:
85+
GITHUB_TOKEN: ${{ github.token }}
86+
# Upload to GitHub Release using the `gh` CLI. `dist/` contains the built
87+
# packages, and the sigstore-produced signatures and certificates.
88+
run: >-
89+
gh release upload
90+
'${{ github.ref_name }}' dist/**
91+
--repo '${{ github.repository }}'

.pre-commit-config.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ repos:
2424
- id: python-no-log-warn
2525
- id: python-use-type-annotations
2626
- id: text-unicode-replacement-char
27-
- repo: https://github.com/asottile/setup-cfg-fmt
28-
rev: v2.5.0
29-
hooks:
30-
- id: setup-cfg-fmt
3127
- repo: https://github.com/astral-sh/ruff-pre-commit
3228
rev: v0.4.4
3329
hooks:

.python-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12.2

pyproject.toml

+45
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,51 @@
22
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
33
build-backend = "setuptools.build_meta"
44

5+
[project]
6+
name = "pytask_stata"
7+
description = "Execute do-files with Stata and pytask."
8+
authors = [{ name = "Tobias Raabe", email = "[email protected]" }]
9+
license = { text = "MIT" }
10+
classifiers = [
11+
"Development Status :: 4 - Beta",
12+
"License :: OSI Approved :: MIT License",
13+
"Operating System :: OS Independent",
14+
"Programming Language :: Python :: 3",
15+
"Programming Language :: Python :: 3 :: Only",
16+
]
17+
requires-python = ">=3.8"
18+
dependencies = ["click", "pytask>=0.3,<0.4"]
19+
dynamic = ["version"]
20+
21+
[project.readme]
22+
file = "README.md"
23+
content-type = "text/markdown"
24+
25+
[project.optional-dependencies]
26+
test = ["pytest", "pytest-cov", "pytest-xdist"]
27+
typing = ["mypy"]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/pytask-dev/pytask-stata"
31+
Documentation = "https://github.com/pytask-dev/pytask-stata"
32+
Github = "https://github.com/pytask-dev/pytask-stata"
33+
Tracker = "https://github.com/pytask-dev/pytask-stata/issues"
34+
Changelog = "https://github.com/pytask-dev/pytask-stata/blob/main/CHANGES.md"
35+
36+
[project.entry-points]
37+
pytask = { pytask_stata = "pytask_stata.plugin" }
38+
39+
[tool.setuptools]
40+
include-package-data = true
41+
package-dir = { "" = "src" }
42+
zip-safe = false
43+
platforms = ["any"]
44+
license-files = ["LICENSE"]
45+
46+
[tool.setuptools.packages.find]
47+
where = ["src"]
48+
namespaces = false
49+
550
[tool.setuptools_scm]
651
write_to = "src/pytask_stata/_version.py"
752

setup.cfg

-43
This file was deleted.

tox.ini

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
[tox]
2-
envlist = pytest
2+
requires = tox>=4
3+
envlist = docs, mypy
34

45
[testenv]
5-
usedevelop = true
6+
package = editable
67

7-
[testenv:pytest]
8-
conda_channels =
9-
conda-forge
10-
nodefaults
11-
conda_deps =
12-
pytask =0.3
13-
pytest
14-
pytest-cov
15-
pytest-xdist
16-
commands =
17-
pytest {posargs}
8+
[testenv:typing]
9+
extras = typing
10+
commands = - mypy
11+
12+
[testenv:test]
13+
extras = test
14+
commands = pytest {posargs}

0 commit comments

Comments
 (0)