Skip to content

Commit

Permalink
Merge pull request #13 from callowayproject/add-testing-tools
Browse files Browse the repository at this point in the history
Add testing tools
  • Loading branch information
coordt authored Dec 8, 2024
2 parents 04472d0 + 64499b6 commit 8329bcb
Show file tree
Hide file tree
Showing 47 changed files with 1,189 additions and 660 deletions.
9 changes: 0 additions & 9 deletions .github/actions/release/action.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
name: Release
description: Create a GitHub release and upload the package to PyPI
inputs:
pypi-api-token:
description: 'PyPI API token'
required: true
tag-name:
description: 'The name of the tag for the GitHub release'
required: true
github-token:
description: 'GitHub token'
required: true

runs:
using: "composite"
Expand All @@ -31,9 +25,6 @@ runs:
files: dist/*
tag_name: "${{ inputs.tag-name }}"
body_path: release-notes.md
token: ${{ inputs.github-token }}

- name: Upload package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ inputs.pypi-api-token }}
10 changes: 6 additions & 4 deletions .github/actions/setup-python-and-git/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ inputs:
python-version:
description: 'Python version to use'
required: false
default: '3.11'
default: '3.12'
runs:
using: 'composite'
steps:
- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
name: Setup Python
with:
python-version: ${{ inputs.python-version }}
cache: 'pip' # caching pip dependencies

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v4
with:
version: "latest"
- name: Git check
run: |
git config --global user.email "[email protected]"
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/docs-final.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- name: Set up Python 3.10
uses: actions/setup-python@v5
- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: "3.10"
python-version: '3.12'

- name: Install dependencies
run: |
git pull --all
python -m pip install ".[docs]"
uv sync -p 3.12 --group docs
- name: Build and deploy documentation
run: |
mkdocs gh-deploy --strict -v
uv run mkdocs gh-deploy --strict
11 changes: 5 additions & 6 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python 3.10
uses: actions/setup-python@v5
- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: "3.10"
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install ".[docs]"
run: uv sync -p 3.12 --group docs

- name: Build documentation
run: |
mkdocs build --strict -v
uv run mkdocs build --strict
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ jobs:
name: Checkout the repository
with:
fetch-depth: 0
token: ${{ secrets.PAT }}

- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: '3.11'
python-version: '3.12'

- name: Install requirements
run: |
python -m pip install generate-changelog bump-my-version
uv sync -p 3.12 --group dev
- name: Generate the changelog and get the release hint
id: generate-changelog
Expand All @@ -43,8 +42,6 @@ jobs:
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Bump version
if: ${{ env.RELEASE_KIND != 'no-release' }}
Expand Down Expand Up @@ -74,5 +71,3 @@ jobs:
uses: ./.github/actions/release
with:
tag-name: ${{ env.TAG_NAME }}
github-token: ${{ secrets.PAT }}
pypi-api-token: ${{ secrets.PYPI_API_TOKEN }}
45 changes: 14 additions & 31 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,71 +22,54 @@ jobs:
- ubuntu-latest
- windows-latest
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
name: Checkout the repository
with:
fetch-depth: 0
- uses: ./.github/actions/setup-python-and-git
with:
python-version: ${{ matrix.python-version }}
- name: Check git is working
run: |
git config --global user.email "[email protected]"
git config --global user.name "Testing Git"
git --version
git config --list
- name: Install test dependencies
run: pip install '.[test]'
run: uv sync -p ${{ matrix.python-version }} --group test
- name: Test
run: pytest --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: test-reports/coverage.xml
flags: python-${{ matrix.python-version }}
verbose: true # optional (default = false)
env_vars: OS,PYTHON
run: uv run pytest

# Upload to Test PyPI.
release-test-pypi:
name: Publish in-dev package to test.pypi.org
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
ref: ${{ github.head_ref }}

- uses: actions/setup-python@v5
- uses: ./.github/actions/setup-python-and-git
with:
python-version: '3.11'
cache: 'pip' # caching pip dependencies
python-version: "3.12"

- name: Install requirements
shell: bash
run: |
python -m pip install --disable-pip-version-check --no-python-version-warning build
python -m pip install --disable-pip-version-check --no-python-version-warning -e .
uv sync -p 3.12 --group dev
- name: Set dev version
shell: bash
run: |
export PR_NUMBER=$(gh pr view --json number -q .number || echo "")
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
echo "::notice::PR_NUMBER is: ${PR_NUMBER}"
bump-my-version bump dev bumpversion/__init__.py --no-commit --no-tag --no-configured-files -v
env:
GH_TOKEN: ${{ secrets.PAT }}
uv run bump-my-version bump dev --no-commit --no-tag -v
- name: Package
shell: bash
run: |
python -m build
uv build
- name: Upload package to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
20 changes: 8 additions & 12 deletions .github/workflows/version-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,19 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.PAT }}

- name: Setup Python and Git
uses: ./.github/actions/setup-python-and-git
with:
python-version: '3.11'
python-version: '3.12'

- name: Install requirements
run: |
python -m pip install generate-changelog bump-my-version
- name: Install test dependencies
run: uv sync -p 3.12 --group dev

- name: Get the release hint
id: generate-changelog
run: |
RELEASE_KIND=$(generate-changelog --output release-hint --branch-override ${{ github.base_ref }} --skip-output-pipeline)
RELEASE_KIND=$(uv run generate-changelog --output release-hint --branch-override ${{ github.base_ref }} --skip-output-pipeline)
echo "::notice::Suggested release type upon merge to ${{ github.base_ref }}: ${RELEASE_KIND}"
echo "RELEASE_KIND=$RELEASE_KIND" >> $GITHUB_ENV
echo "release-kind=$RELEASE_KIND" >> $GITHUB_OUTPUT
Expand All @@ -39,26 +37,24 @@ jobs:
echo "pull_request_number=${PR_NUMBER}" >> $GITHUB_OUTPUT
echo "::notice::PR_NUMBER is ${PR_NUMBER}"
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.PAT }}
- name: Bump version dry run
if: ${{ env.RELEASE_KIND != 'no-release' }}
shell: bash
run: |
# This will display a full log of what would happen if we were to bump the version.
bump-my-version bump --dry-run --verbose "$RELEASE_KIND"
uv run bump-my-version bump --dry-run --verbose "$RELEASE_KIND"
# This retrieves the current and new version numbers as a JSON-formatted string.
VERSION_INFO=$(bump-my-version show --format json --increment "$RELEASE_KIND" current_version new_version)
VERSION_INFO=$(uv run bump-my-version show --format json --increment "$RELEASE_KIND" current_version new_version)
echo "CURRENT_VERSION=$(echo $VERSION_INFO | jq -r .current_version)" >> $GITHUB_ENV
echo "NEW_VERSION=$(echo $VERSION_INFO | jq -r .new_version)" >> $GITHUB_ENV
- name: Set no-release information
if: ${{ env.RELEASE_KIND == 'no-release' }}
run: |
echo "CURRENT_VERSION=$(bump-my-version show current_version)" >> $GITHUB_ENV
echo "NEW_VERSION=$(bump-my-version show current_version)" >> $GITHUB_ENV
echo "CURRENT_VERSION=$(uv run bump-my-version show current_version)" >> $GITHUB_ENV
echo "NEW_VERSION=$(uv run bump-my-version show current_version)" >> $GITHUB_ENV
- name: Display the version hint
uses: s-gehring/singleton-comment@v1
Expand Down
26 changes: 16 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ repos:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.8.0'
rev: 'v0.8.2'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
args: [ --fix, --exit-non-zero-on-fix ]
exclude: test.*
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
args: [--ignore-words-list, astroid ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
Expand All @@ -29,28 +36,27 @@ repos:
test.*|
mkdocs.yml
)$
args: [--allow-multiple-documents]
args: [ --allow-multiple-documents ]
- id: debug-statements
- id: end-of-file-fixer
exclude: "^tests/resources/"
- id: fix-byte-order-marker
- id: fix-encoding-pragma
args: ["--remove"]
- id: requirements-txt-fixer
args: [ "--remove" ]
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
additional_dependencies: ["gibberish-detector"]
- id: detect-secrets
additional_dependencies: [ "gibberish-detector" ]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
hooks:
- id: mypy
args: [--no-strict-optional, --ignore-missing-imports]
additional_dependencies: ["pydantic>2.0", "toml", "types-PyYAML"]
args: [ --no-strict-optional, --ignore-missing-imports ]
additional_dependencies: [ "pydantic>2.0", "toml", "types-PyYAML" ]
exclude: "^tests/"
- repo: https://github.com/jsh9/pydoclint
rev: 0.5.9
rev: 0.5.10
hooks:
- id: pydoclint
args:
Expand Down
Loading

0 comments on commit 8329bcb

Please sign in to comment.