Skip to content
This repository was archived by the owner on Oct 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: "uv"
directory: "/"
schedule:
interval: "monthly"
# No version-update PRs; security updates are unaffected by this limit.
open-pull-requests-limit: 0
groups:
security:
applies-to: security-updates
patterns: ["*"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
# No version-update PRs; security updates are unaffected by this limit.
open-pull-requests-limit: 0
groups:
security:
applies-to: security-updates
patterns: ["*"]
186 changes: 158 additions & 28 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,186 @@
name: Python package

# yamllint disable-line rule:truthy
on: [push]
on:
push:
pull_request:
# Monthly run: detects breakage caused by new Python releases.
schedule:
- cron: "0 6 1 * *"
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
test:
versions:
name: Compute Python versions
runs-on: ubuntu-latest
outputs:
supported: ${{ steps.compute.outputs.supported }}
oldest: ${{ steps.compute.outputs.oldest }}
latest: ${{ steps.compute.outputs.latest }}
next: ${{ steps.compute.outputs.next }}
steps:
- uses: actions/checkout@v7

- name: Fetch supported CPython versions from endoflife.date
id: compute
run: |
if ! curl --fail --silent --show-error --location --retry 3 \
--output eol.json https://endoflife.date/api/python.json; then
echo "::error::Could not fetch" \
"https://endoflife.date/api/python.json;" \
"refusing to fall back to a pinned version list."
exit 1
fi
python3 - <<'PY'
import json
import os
import tomllib
from datetime import date

today = date.today().isoformat()
with open("eol.json") as fp:
cycles = json.load(fp)

def key(cycle):
return tuple(int(p) for p in cycle.split("."))

# Released (release date in the past) and not yet end-of-life.
supported = sorted(
(
c["cycle"]
for c in cycles
if str(c["releaseDate"]) <= today
and c["eol"] is not True
and (c["eol"] is False or str(c["eol"]) > today)
),
key=key,
)
if not supported:
raise SystemExit(
"::error::endoflife.date returned no supported"
" CPython version"
)
major, minor = key(supported[-1])
next_version = f"{major}.{minor + 1}"

with open("pyproject.toml", "rb") as fp:
requires = tomllib.load(fp)["project"]["requires-python"]
floor = requires.removeprefix(">=").strip()
if key(floor) < key(supported[0]):
print(
f"::warning::requires-python ({requires}) is below the "
f"oldest supported CPython ({supported[0]}). The next "
"release should "
"raise requires-python and the version classifiers."
)

with open(os.environ["GITHUB_OUTPUT"], "a") as out:
out.write(f"supported={json.dumps(supported)}\n")
out.write(f"oldest={supported[0]}\n")
out.write(f"latest={supported[-1]}\n")
out.write(f"next={next_version}\n")
print("supported:", supported, "next:", next_version)
PY

test:
name: Test (Python ${{ matrix.python-version }})
needs: versions
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]

python-version: ${{ fromJSON(needs.versions.outputs.supported) }}
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v10.3.2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
id: python
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install -e .
run: uv sync --locked --python '${{ steps.python.outputs.python-path }}'

- name: Lint with pylint
run: uv run pylint --reports=y --exit-zero config_resolver

- name: Test with pytest
run: |
pip install pylint
pylint --reports=y --exit-zero config_resolver
chmod 600 tests/examples/configs/secure.ini
uv run pytest -rsf

prerelease:
name: Test (upcoming Python ${{ needs.versions.outputs.next }}, may fail)
needs: versions
runs-on: ubuntu-latest
# Informational only: never fails the workflow or blocks publishing.
continue-on-error: true
steps:
- uses: actions/checkout@v7

- name: Install uv
uses: astral-sh/setup-uv@v10.3.2

- name: Set up Python ${{ needs.versions.outputs.next }} (pre-release)
id: python
# Fails when no pre-release of the next version exists yet.
continue-on-error: true
uses: actions/setup-python@v7
with:
python-version: ${{ needs.versions.outputs.next }}
allow-prereleases: true

- name: Note missing pre-release
if: steps.python.outcome != 'success'
run: >-
echo "::notice::No Python ${{ needs.versions.outputs.next }}
(pre-)release is available yet; skipping."

- name: Install dependencies
if: steps.python.outcome == 'success'
run: uv sync --locked --python '${{ steps.python.outputs.python-path }}'

- name: Test with pytest
if: steps.python.outcome == 'success'
run: |
pip install pytest pytest-coverage
chmod 600 tests/examples/configs/secure.ini
pytest -rsf
uv run pytest -rsf

build:
name: Build and inspect package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

needs: [test]
# Builds the sdist and wheel, runs check-wheel-contents and twine check,
# prints the contents and uploads them as the "Packages" artifact. Runs
# on every event so packaging problems show up in PRs.
- uses: hynek/build-and-inspect-python-package@v3.0.2

publish:
runs-on: ubuntu-latest
needs: [test, build]
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v1
- name: Build distribution
if: "github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags')"
run: |
pip install wheel
python setup.py sdist
python setup.py bdist_wheel
- name: Download the built packages
uses: actions/download-artifact@v8
with:
name: Packages
path: dist

- name: Publish package
if: "github.event_name == 'push' &&
startsWith(github.event.ref, 'refs/tags')"
uses: "pypa/gh-action-pypi-publish@\
e777b33388fefa46ce597d8afa9c15a5357af36f"
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_token }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/env3
/htmlcov
__pycache__
/.venv
18 changes: 0 additions & 18 deletions Pipfile

This file was deleted.

54 changes: 54 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"

[project]
name = "config_resolver"
dynamic = ["version"]
description = "A small package to automatically find a configuration file."
readme = "README.rst"
authors = [{ name = "Michel Albert", email = "michel@albert.lu" }]
license = { text = "MIT" }
requires-python = ">=3.6"
dependencies = ["packaging"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3 :: Only",
"Topic :: Software Development :: Libraries :: Python Modules",
]

[project.urls]
Homepage = "https://github.com/exhuma/config_resolver"
"Bug Tracker" = "https://github.com/exhuma/config_resolver/issues"
Documentation = "https://config-resolver.readthedocs.org/en/latest/"

[tool.setuptools.dynamic]
version = { file = "config_resolver/version.txt" }

[tool.setuptools.packages.find]
include = ["config_resolver*"]

[tool.setuptools.package-data]
config_resolver = ["py.typed"]

[dependency-groups]
dev = [
"pylint",
"pytest",
"pytest-cov",
"pytest-xdist",
"sphinx",
"sphinx-rtd-theme",
]

[tool.uv.dependency-groups]
# Current dev tooling no longer supports the package's Python floor. This
# only restricts the development environment, not the published package.
dev = { requires-python = ">=3.10" }

[tool.black]
line_length = 80

Expand Down
1 change: 1 addition & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[pytest]
log_print = False
testpaths = tests
pythonpath = .
addopts = --cov config_resolver --cov-report term-missing
44 changes: 0 additions & 44 deletions setup.py

This file was deleted.

Loading
Loading