Skip to content

feat: ✨ enhance API with new slicing "target" system (#62) #36

feat: ✨ enhance API with new slicing "target" system (#62)

feat: ✨ enhance API with new slicing "target" system (#62) #36

Workflow file for this run

name: CI/CD Pipeline 🚀
on:
push:
branches: [ main ]
tags: [ '*.*.*' ] # Triggers on canonical tags like 1.2.0, 2.0.1-alpha, etc.
pull_request:
branches: [ main ]
jobs:
lint:
name: Lint & Format 🧹
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python 3.14 ⚙️
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install Ruff 🦀
run: python -m pip install ruff
- name: Lint and Format 🫧
run: |
ruff check . --output-format=github
ruff format --check .
build:
name: Build distribution 📦
needs: lint
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python ⚙️
uses: actions/setup-python@v6
with:
python-version: "3.x"
cache: "pip"
- name: Install build tools 📦
run: |
python -m pip install --upgrade pip
python -m pip install build
- name: Build sdist and wheel ⚙️
run: python -m build
- name: Store the distribution packages 📥
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
test:
name: Test on Python ${{ matrix.python-version }} 🐍
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
permissions:
contents: read
steps:
- uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python ${{ matrix.python-version }} ⚙️
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Download the dists 📥
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Install dependencies and package 📦
run: |
python -m pip install --upgrade pip
python -m pip install pytest coverage
WHEEL_FILE=$(ls dist/*.whl)
python -m pip install "${WHEEL_FILE}[all]"
- name: Run tests (No Coverage) 🧪
if: matrix.python-version != '3.14'
run: python -m pytest -v
- name: Run tests (With Coverage) 🧪📊
if: matrix.python-version == '3.14'
run: |
python -m coverage run -m pytest -v
python -m coverage report -m
python -m coverage json
TOTAL=$(python -c "import json; print(int(float(json.load(open('coverage.json'))['totals']['percent_covered'])))")
echo "total=$TOTAL" >> $GITHUB_ENV
if [ "$TOTAL" -ge 95 ]; then
echo "color=brightgreen" >> $GITHUB_ENV
elif [ "$TOTAL" -ge 90 ]; then
echo "color=green" >> $GITHUB_ENV
elif [ "$TOTAL" -ge 85 ]; then
echo "color=yellowgreen" >> $GITHUB_ENV
elif [ "$TOTAL" -ge 80 ]; then
echo "color=yellow" >> $GITHUB_ENV
elif [ "$TOTAL" -ge 70 ]; then
echo "color=orange" >> $GITHUB_ENV
else
echo "color=red" >> $GITHUB_ENV
fi
- name: Update Coverage Badge Gist 🪪
if: matrix.python-version == '3.14'
uses: Schneegans/dynamic-badges-action@v1.8.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 9f30f8200703cf6886ab323e86b9f0a1
filename: pyansistring_coverage.json
label: coverage
message: ${{ env.total }}%
color: ${{ env.color }}
publish-to-pypi:
name: Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyansistring
permissions:
id-token: write
steps:
- name: Download all the dists 📥
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI 🚀
uses: pypa/gh-action-pypi-publish@release/v1