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
62 changes: 62 additions & 0 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Smokeshow

on:
workflow_run:
workflows:
- Test
types:
- completed

permissions:
statuses: write

env:
UV_SYSTEM_PYTHON: 1

jobs:
smokeshow:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest

steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.9'
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- run: uv pip install -r requirements-tests.txt
- uses: actions/download-artifact@v5
with:
name: coverage-html
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
# Try 5 times to upload coverage to smokeshow
- name: Upload coverage to Smokeshow
run: |
for i in 1 2 3 4 5; do
if smokeshow upload htmlcov; then
echo "Smokeshow upload success!"
break
fi
echo "Smokeshow upload error, sleep 1 sec and try again."
sleep 1
done
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100
SMOKESHOW_GITHUB_CONTEXT: coverage
SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }}
59 changes: 59 additions & 0 deletions .github/workflows/test-redistribute.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Test Redistribute

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

env:
UV_SYSTEM_PYTHON: 1

jobs:
test-redistribute:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.10"
- name: Install build dependencies
run: pip install build
- name: Build source distribution
run: python -m build --sdist
- name: Decompress source distribution
run: |
cd dist
tar xvf annotated_doc*.tar.gz
- name: Install test dependencies
run: |
cd dist/annotated_doc*/
pip install -r requirements-tests.txt
- name: Run source distribution tests
run: |
cd dist/annotated_doc*/
bash scripts/test.sh
- name: Build wheel distribution
run: |
cd dist
pip wheel --no-deps annotated_doc*.tar.gz

# https://github.com/marketplace/actions/alls-green#why
test-redistribute-alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- test-redistribute
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
140 changes: 140 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Test

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: 'false'
schedule:
# cron every week on monday
- cron: "0 0 * * 1"

env:
UV_SYSTEM_PYTHON: 1

jobs:
test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- "3.14"
include:
- os: macos-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.9"
- os: ubuntu-latest
python-version: "3.10"
- os: macos-latest
python-version: "3.11"
- os: windows-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
- os: macos-latest
python-version: "3.13"
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- name: Lint
run: bash scripts/lint.sh
- run: mkdir coverage
- name: Test
run: bash scripts/test.sh
env:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v4
with:
name: coverage-${{ runner.os }}-${{ matrix.python-version }}
path: coverage
include-hidden-files: true

coverage-combine:
needs:
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Setup uv
uses: astral-sh/setup-uv@v7
with:
version: "0.4.15"
enable-cache: true
cache-dependency-glob: |
requirements**.txt
pyproject.toml
- name: Get coverage files
uses: actions/download-artifact@v5
with:
pattern: coverage-*
path: coverage
merge-multiple: true
# Allow debugging with tmate
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
with:
limit-access-to-actor: true
- name: Install Dependencies
run: uv pip install -r requirements-tests.txt
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
include-hidden-files: true

# https://github.com/marketplace/actions/alls-green#why
alls-green: # This job does nothing and is only used for the branch protection
if: always()
needs:
- coverage-combine
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
15 changes: 8 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ junit_family = "xunit2"
parallel = true
data_file = "coverage/.coverage"
source = [
"src",
"src/annotated_doc",
"tests",
]
context = '${CONTEXT}'
dynamic_context = "test_function"
relative_files = true

[tool.coverage.report]
show_missing = true
Expand Down Expand Up @@ -91,10 +93,9 @@ ignore = [
# Preserve types, even if a file imports `from __future__ import annotations`.
keep-runtime-typing = true

[dependency-groups]
dev = [
"coverage>=7.6.1",
"mypy>=1.14.1",
"pytest>=8.3.5",
"ruff>=0.14.1",
[tool.uv.build-backend]
source-include = [
"tests/**",
"requirements*.txt",
"scripts/**",
]
7 changes: 7 additions & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-e .

pytest >=8.3.5
coverage[toml] >=7.6.1
mypy ==1.14.1
ruff ==0.14.1
smokeshow >=0.5.0
8 changes: 8 additions & 0 deletions scripts/coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e
set -x

coverage combine
coverage report
coverage html
5 changes: 5 additions & 0 deletions scripts/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash
set -x

ruff check src tests scripts --fix
ruff format src tests scripts
8 changes: 8 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

set -e
set -x

mypy src
ruff check src tests scripts
ruff format src tests --check
7 changes: 7 additions & 0 deletions scripts/test-cov-html.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -e
set -x

bash scripts/test.sh ${@}
bash scripts/coverage.sh
6 changes: 6 additions & 0 deletions scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e
set -x

coverage run -m pytest tests ${@}
1 change: 1 addition & 0 deletions src/annotated_doc/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def hi(name: Annotated[str, Doc("Who to say hi to")]) -> None:
print(f"Hi, {name}!")
```
"""

def __init__(self, documentation: str, /) -> None:
self.documentation = documentation

Expand Down
Loading
Loading