Skip to content
Closed
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
16 changes: 16 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# These are supported funding model platforms

github: HEROgold # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
# polar: # Replace with a single Polar username
# buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
# thanks_dev: # Replace with a single thanks.dev username
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
#
74 changes: 74 additions & 0 deletions .github/workflows/bump-version-by-labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Bump Version By Labels

on:
pull_request:
types: [closed]
branches: [main]

jobs:
bump-version:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.*"

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Determine version bump
id: detect-bump
env:
LABELS: ${{ github.event.pull_request.labels.*.name }}
run: |
# Check PR labels to determine bump type
if echo "$LABELS" | grep -q "Major"; then
echo "bump_type=major" >> $env:GITHUB_OUTPUT
elif echo "$LABELS" | grep -q "Minor"; then
echo "bump_type=minor" >> $env:GITHUB_OUTPUT
elif echo "$LABELS" | grep -q "Patch"; then
echo "bump_type=patch" >> $env:GITHUB_OUTPUT
else
echo "bump_type=" >> $env:GITHUB_OUTPUT
fi

- name: Bump Version
if: steps.detect-bump.outputs.bump_type != ''
id: bump-version
run: |
uv run bump-my-version bump ${{ steps.detect-bump.outputs.bump_type }}
$NEW_VERSION = uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"
echo "version-bumped=true" >> $env:GITHUB_OUTPUT
echo "new-version=$NEW_VERSION" >> $env:GITHUB_OUTPUT

- name: Create version bump PR
if: steps.bump-version.outputs.version-bumped == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

$BRANCH_NAME = "bump-version-${{ steps.bump-version.outputs.new-version }}"
git checkout -b "$BRANCH_NAME"
git add pyproject.toml
git commit -m "chore: bump version to ${{ steps.bump-version.outputs.new-version }}"
git push origin "$BRANCH_NAME"

gh pr create \
--title "chore: bump version to ${{ steps.bump-version.outputs.new-version }}" \
--body "Automated version bump to ${{ steps.bump-version.outputs.new-version }}" \
--base main \
--admin
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.13"

- name: Install dependencies
run: uv sync
Expand All @@ -39,7 +39,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.12", "3.13"]
steps:
- uses: actions/checkout@v4

Expand All @@ -57,7 +57,7 @@ jobs:
run: uv sync

- name: Run tests
run: uv run pytest -v --cov=undersort --cov-report=term-missing
run: uv run pytest -v --cov=funcsort --cov-report=term-missing

publish:
name: Publish to PyPI
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.13"

- name: Build package
run: uv build
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Coverage

on:
workflow_run:
workflows: ["Test"]
branches: [main]
types:
- completed

permissions:
contents: read

jobs:
coveralls-upload:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Set up Python 3.13
run: uv python install 3.13

- name: Install dependencies
run: uv sync --group dev

- name: Run tests with coverage
run: uv run coverage run --source=. -m pytest tests/

- name: Upload coverage data to coveralls.io
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_SERVICE_NAME: github-actions
COVERALLS_PARALLEL: true
run: uvx coveralls --service=github

- name: Coveralls Finished
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: uvx coveralls --finish
28 changes: 28 additions & 0 deletions .github/workflows/gitleaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Gitleaks

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
workflow_call:

concurrency: gitleaks-${{ github.ref }}

permissions:
contents: read

jobs:
gitleaks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Run Gitleaks
uses: gitleaks/gitleaks-action@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70 changes: 70 additions & 0 deletions .github/workflows/lint-public.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Type Check Public API

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
workflow_call:

concurrency:
group: lint-public-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Install dependencies
run: uv sync --dev

lint:
needs: setup
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- tool: ruff
args: "check ."
- tool: ty
args: "check . --ignore no-matching-overload"
- tool: pyrefly
args: "check ."
- tool: zuban
args: "check ."
- tool: mypy
args: "."
- tool: pyright
args: "."
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install uv (Should be cached from setup job)
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Cache lint results
uses: actions/cache@v4
with:
path: .lint_cache
key: ${{ runner.os }}-lint-${{matrix.tool}}-${{ hashFiles('**/tests/**/*.py', 'src/**') }}
restore-keys: |
${{ runner.os }}-lint-${{matrix.tool}}

- name: Run type checking - ${{matrix.tool}}
run: uv add ${{matrix.tool}} && uv run ${{matrix.tool}} ${{matrix.args}}
40 changes: 40 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Publish to PyPI

on:
repository_dispatch:
types: [new-release-created]
workflow_dispatch:

permissions:
contents: read

jobs:
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/funcsort
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true

- name: Set up Python
run: uv python install 3.14

- name: Build distribution 📦
run: uv build

- name: Publish distribution 📦 to PyPI
run: uv publish
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Auto-release

on:
workflow_run:
workflows: ["Test"]
branches: [main]
types:
- completed
workflow_dispatch:

jobs:
new-release:
runs-on: ubuntu-latest
permissions:
contents: write
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
outputs:
version_changed: ${{ steps.version-check.outputs.version_changed }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed to get all tags for version comparison

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.*"

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"

- name: Check if version changed
id: version-check
run: |
# Get current version from pyproject.toml
CURRENT_VERSION=$(uv run python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])")
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT

# Check if this version already has a tag
if git tag --list | grep -q "^v$CURRENT_VERSION$"; then
echo "version_changed=false" >> $GITHUB_OUTPUT
echo "Version v$CURRENT_VERSION already exists as a tag"
else
echo "version_changed=true" >> $GITHUB_OUTPUT
echo "New version v$CURRENT_VERSION detected - will create release"
fi

- name: Create GitHub Release
if: steps.version-check.outputs.version_changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version-check.outputs.current_version }}
name: Release v${{ steps.version-check.outputs.current_version }}
draft: false
prerelease: false
generate_release_notes: true

# Trigger PyPI workflow when after we create a release.
# Pypi workflow won't with the usual on-release trigger
# because another workflow (this one) created the release. (avoiding inf recursion)
- name: Trigger PyPI workflow
if: steps.version-check.outputs.version_changed == 'true'
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: new-release-created
client-payload: '{"version": "${{ steps.version-check.outputs.current_version }}"}'
Loading