Skip to content

Commit

Permalink
Add rye. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasraabe authored Apr 24, 2024
1 parent 997776b commit ea266be
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 119 deletions.
58 changes: 30 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
CONDA_EXE: mamba

on:
push:
branches:
Expand All @@ -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 }}
Expand All @@ -33,18 +45,12 @@ jobs:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-tinytex@v2
if: runner.os != 'Windows'
- uses: mamba-org/setup-micromamba@v1
- uses: actions/setup-python@v5
with:
environment-name: gha-testing
condarc: |
channels:
- nodefaults
- conda-forge
create-args: >-
python=${{ matrix.python-version }}
mamba
tox-conda
cache-environment: true
python-version: ${{ matrix.python-version }}
cache: pip
allow-prereleases: true
- run: pip install tox-uv

- name: Install MacOS dependencies.
if: runner.os == 'macOS'
Expand All @@ -56,26 +62,22 @@ jobs:
shell: bash -l {0}
run: tlmgr install import epstopdf biblatex biber

- name: Install core dependencies.
shell: bash -l {0}
run: conda install -c conda-forge tox-conda coverage

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

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

- name: Upload coverage report for unit tests and doctests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
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 -- src tests -m end_to_end --cov=./ --cov-report=xml -n auto
run: tox -e test -- src tests -m end_to_end --cov=./ --cov-report=xml

- name: Upload coverage reports of end-to-end tests.
if: runner.os == 'Linux' && matrix.python-version == '3.10'
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
91 changes: 73 additions & 18 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -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
- 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/latex-dependency-scanner
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 }}'
13 changes: 7 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ repos:
hooks:
- id: check-added-large-files
args: ['--maxkb=25']
- id: check-case-conflict
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: no-commit-to-branch
args: [--branch, main]
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
Expand Down Expand Up @@ -36,12 +43,6 @@ repos:
rev: v2.2.6
hooks:
- id: codespell
- repo: https://github.com/mgedmin/check-manifest
rev: "0.49"
hooks:
- id: check-manifest
args: [--no-build-isolation]
additional_dependencies: [setuptools-scm, wheel, toml]
- repo: meta
hooks:
- id: check-hooks-apply
Expand Down
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.2
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
This is a record of all past latex-dependency-scanner releases and what went into them
in reverse chronological order. Releases follow [semantic versioning](https://semver.org/) and all releases are available on [PyPI](https://pypi.org/project/latex-dependency-scanner) and [Anaconda.org](https://anaconda.org/pytask/latex-dependency-scanner).

## 0.1.3 - 2024-xx-xx

- {pull}`31` adds rye.

## 0.1.2 - 2023-10-02

- {pull}`21` updates the readme and other infrastructure files.
Expand Down
65 changes: 61 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,66 @@
[build-system]
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.setuptools_scm]
write_to = "src/latex_dependency_scanner/_version.py"
[project]
name = "latex_dependency_scanner"
description = "Scan LaTeX documents for their dependencies."
classifiers = [
"Development Status :: 3 - Alpha",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
]
requires-python = ">=3.8"
dynamic = ["version"]

[[project.authors]]
name = "Tobias Raabe"
email = "raabe@posteo.de"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.license]
text = "MIT"

[project.urls]
Homepage = "https://github.com/pytask-dev/latex-dependency-scanner"
Changelog = "https://github.com/pytask-dev/latex-dependency-scanner/blob/main/CHANGES.md"
Documentation = "https://github.com/pytask-dev/latex-dependency-scanner"
Github = "https://github.com/pytask-dev/latex-dependency-scanner"
Tracker = "https://github.com/pytask-dev/latex-dependency-scanner/issues"

[project.optional-dependencies]
typing = [
"mypy>=1.10.0",
]
test = [
"pytest>=8.1.1",
"pytest-cov>=5.0.0",
]

[tool.rye]
managed = true

[tool.hatch.build.hooks.vcs]
version-file = "src/latex_dependency_scanner/_version.py"

[tool.hatch.build.targets.sdist]
exclude = ["tests"]
only-packages = true

[tool.hatch.build.targets.wheel]
exclude = ["tests"]
only-packages = true

[tool.hatch.version]
source = "vcs"

[tool.hatch.metadata]
allow-direct-references = true

[tool.mypy]
files = ["src", "tests"]
Expand Down
35 changes: 0 additions & 35 deletions setup.cfg

This file was deleted.

38 changes: 10 additions & 28 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
[tox]
envlist = pytest
requires = tox>=4
envlist = test, typing

[testenv]
usedevelop = true
passenv = CI
package = editable

[testenv:pytest]
conda_channels =
conda-forge
conda_deps =
pytest
pytest-cov
pytest-xdist
sphinx
commands =
pytest {posargs}
[testenv:typing]
extras = typing
commands = mypy

[pytest]
testpaths =
src
tests
addopts = --doctest-modules
filterwarnings =
ignore: the imp module is deprecated in favour of importlib
ignore: Using or importing the ABCs from 'collections' instead of from
markers =
wip: Tests that are work-in-progress.
unit: Flag for unit tests which target mainly a single function.
integration: Flag for integration tests which may comprise of multiple unit tests.
end_to_end: Flag for tests that cover the whole program.
norecursedirs =
.idea
.tox
[testenv:test]
extras = test
commands = pytest {posargs}

0 comments on commit ea266be

Please sign in to comment.