Skip to content
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
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 5

- package-ecosystem: uv
directory: /
schedule:
interval: weekly
day: monday
open-pull-requests-limit: 5
56 changes: 11 additions & 45 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@ on:
- main
pull_request:

permissions:
contents: read

jobs:
build-docs:
name: "Build Docs"
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Full history for accurate page timestamps

- uses: actions/setup-python@v6
- uses: actions/setup-python@v7
with:
python-version: "3.11"
cache: pip
cache-dependency-path: pyproject.toml

- name: Install package and dependencies
run: |
python -m pip install uv
uv sync
uv pip install great-docs
python -m pip install --upgrade pip
python -m pip install --group docs --editable .

- name: Set up Quarto
uses: quarto-dev/quarto-actions/setup@v2

- name: Build docs
run: uv run great-docs build
run: great-docs build

- name: Save docs artifact
uses: actions/upload-artifact@v7
Expand All @@ -58,7 +62,7 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/download-artifact@v7
- uses: actions/download-artifact@v8
with:
name: docs-html
path: great-docs/_site
Expand All @@ -72,41 +76,3 @@ jobs:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5

preview-docs:
name: "Preview Docs"
runs-on: ubuntu-latest
needs: "build-docs"
if: github.event_name == 'pull_request'
permissions:
deployments: write
pull-requests: write
steps:
- uses: actions/download-artifact@v7
with:
name: docs-html
path: great-docs/_site

# Start deployment
- name: Configure pull release name
if: ${{ github.event_name == 'pull_request' }}
run: |
echo "RELEASE_NAME=pr-${{ github.event.number }}" >> $GITHUB_ENV

- name: Configure branch release name
if: ${{ github.event_name != 'pull_request' }}
run: |
# use branch name, but replace slashes. E.g. feat/a -> feat-a
echo "RELEASE_NAME=${GITHUB_REF_NAME//\//-}" >> $GITHUB_ENV

# Deploy
- name: Create Github Deployment
uses: bobheadxi/deployments@v1
id: deployment
if: ${{ !github.event.pull_request.head.repo.fork }}
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: ${{ env.RELEASE_NAME }}
ref: ${{ github.head_ref }}
logs: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
101 changes: 101 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Publish to PyPI

on:
release:
types: [published]

permissions: {}

concurrency:
group: pypi-${{ github.event.release.tag_name }}
cancel-in-progress: false

jobs:
build:
name: Build release distributions
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read

steps:
- name: Check out release tag
uses: actions/checkout@v7
with:
ref: ${{ github.event.release.tag_name }}
fetch-depth: 0
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
cache: pip
cache-dependency-path: pyproject.toml

- name: Validate release source and version
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
python - <<'PY'
import os
import subprocess
import tomllib

with open("pyproject.toml", "rb") as file:
version = tomllib.load(file)["project"]["version"]

tag = os.environ["RELEASE_TAG"]
expected_tag = f"v{version}"
if tag != expected_tag:
raise SystemExit(f"Release tag {tag!r} does not match package version {version!r}; expected {expected_tag!r}")

subprocess.run(
["git", "merge-base", "--is-ancestor", "HEAD", "origin/main"],
check=True,
)
print(f"Validated {tag} from main for secure {version}")
PY

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install build tools
run: python -m pip install --group build

- name: Build distributions
run: python -m build

- name: Validate distributions
run: python -m twine check dist/*

- name: Upload distributions
uses: actions/upload-artifact@v7
with:
name: python-package-distributions
path: dist/
if-no-files-found: error
retention-days: 7

publish:
name: Publish release to PyPI
if: ${{ !github.event.release.prerelease }}
needs: build
runs-on: ubuntu-latest
timeout-minutes: 15
environment:
name: pypi
url: https://pypi.org/project/secure/
permissions:
id-token: write

steps:
- name: Download distributions
uses: actions/download-artifact@v8
with:
name: python-package-distributions
path: dist/

- name: Publish distributions to PyPI
uses: pypa/gh-action-pypi-publish@v1.14.3
67 changes: 51 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,75 @@
name: Unit Tests
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
python:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14-dev"
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install toolchain
run: pip install ruff==0.13.2 pytest
- name: Install project and development dependencies
run: python -m pip install --group dev --editable .

- name: Install package
run: pip install -e .
- name: Run test suite
run: python -m pytest -q

- name: Unit tests
run: python -m pytest
quality:
name: Lint, format, and package
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- uses: actions/checkout@v7

- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
cache: pip
cache-dependency-path: pyproject.toml

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install project and development dependencies
run: python -m pip install --group dev --editable .

- name: Lint
run: ruff check secure tests

- name: Check formatting
run: ruff format --check secure tests

- name: Build distributions
run: python -m build

- name: Validate distributions
run: python -m twine check dist/*
29 changes: 14 additions & 15 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,25 @@ Thanks for helping make `secure` better. The following guidance keeps contributi

## Development environment

1. Create a virtual environment and activate it:
1. Install the locked development environment:
```bash
python -m venv .venv
source .venv/bin/activate
```
2. Install the package in editable mode so local changes are picked up automatically:
```bash
pip install -e .
uv sync
```
3. Install the tooling used by the project:
`uv` creates `.venv`, installs `secure` in editable mode, and installs the default `dev` group. On Python 3.11+, this also provides `uv run great-docs`.

2. If `uv` is unavailable, use a standard virtual environment and pip:
```bash
pip install pytest ruff
python -m venv .venv
source .venv/bin/activate
python -m pip install --group dev --editable .
```
_Optional:_ `uv` is the package manager used by the project for releases; you can use `uv run pytest` and `uv add ...` to manage dependencies, but it is not required for local development.

## Running tests, linting, and formatting

- **Run unit tests:** `pytest`
- **Run the linter:** `ruff check`
- **Apply formatting / fix issues:** `ruff format`
- **Run unit tests:** `uv run pytest -q`
- **Run the linter:** `uv run ruff check secure tests`
- **Check formatting:** `uv run ruff format --check secure tests`
- **Apply formatting locally:** `uv run ruff format secure tests`

Run these commands before opening a pull request. If you rely on a different Python version, keep it within the supported range (Python 3.10+).

Expand Down Expand Up @@ -57,8 +56,8 @@ Run these commands before opening a pull request. If you rely on a different Pyt

## Pull request checklist

- [ ] I have run `pytest` locally (or a representative suite) and addressed any failures.
- [ ] I have run `ruff check` and `ruff format` (when formatting attr).
- [ ] I have run `uv run pytest -q` locally (or a representative suite) and addressed any failures.
- [ ] I have run `uv run ruff check secure tests` and `uv run ruff format --check secure tests`.
- [ ] Documentation updates describe the new behavior (new header docs, framework guidance, etc.).
- [ ] If applicable, I have updated the release notes/CHANGELOG entry for new user-visible behavior.
- [ ] My changes follow the project’s security and contribution guidelines (this document).
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
prune .github
prune docs
prune great-docs
prune tests
Loading