Skip to content

Conversation

@jensens
Copy link
Member

@jensens jensens commented Nov 7, 2025

Overview

This PR modernizes the CI/CD pipeline to match the mxrepo workflow and implements automated releases via GitHub Actions.

Base branch: refactor-package-layout (builds on the package refactoring work)

Changes

New Workflow Files

  • lint.yml: Automated code quality checks (ruff, isort)
  • typecheck.yml: Type checking with mypy on Python 3.13
  • release.yml: Automated PyPI publishing workflow
    • Publishes to Test PyPI on every master push
    • Publishes to production PyPI on GitHub releases
    • Uses build attestation for supply chain security
  • dependabot.yml: Weekly GitHub Actions dependency updates

Updated Workflow Files

test.yml:

docs.yml:

  • Switch to astral-sh/setup-uv@v7 for consistency
  • Update action versions (checkout@v5, setup-node@v4)
  • Update Node.js version from 16 to 20
  • Add workflow_call trigger for reusability

Build System Updates

pyproject.toml:

  • Add hatch-vcs for automatic versioning from git tags
  • Add hatch-fancy-pypi-readme for combined readme generation
  • Make version and readme dynamic
  • Add ruff.lint configuration for enhanced code quality checks
  • Add pytest.ini_options for test configuration
  • Add coverage.run and coverage.report for coverage settings
  • Preserve existing stricter mypy settings from refactor-package-layout
  • Preserve existing isort "plone" profile
  • Maintain backward compatibility with zest.releaser config

Documentation

RELEASE.md (new):

  • Comprehensive release process documentation
  • Automated GitHub release workflow instructions
  • PyPI Trusted Publishing setup guide
  • Version numbering guidelines (Semantic Versioning)
  • Troubleshooting section
  • Migration notes from zest.releaser

Post-Merge Actions Required

After merging this PR, the following steps are needed:

  1. Configure GitHub Environments:

    • Create release-test-pypi environment
    • Create release-pypi environment
  2. Set up PyPI Trusted Publishing:

  3. Test the Workflow:

    • First push to master will trigger Test PyPI release
    • Create a GitHub release (e.g., v2.0.0) to publish to production PyPI

Related Issues

Testing

  • All workflows use the same patterns as the proven mxrepo implementation
  • Coverage artifacts follow best practices from https://hynek.me/articles/ditch-codecov-python/
  • Build configuration tested with hatch-vcs and hatch-fancy-pypi-readme

Migration Notes

  • The old manual release process using zest.releaser will be replaced by automated GitHub releases
  • Version numbers will now be automatically determined from git tags via hatch-vcs
  • The stricter mypy configuration from refactor-package-layout is preserved
  • The isort "plone" profile from refactor-package-layout is preserved

This commit modernizes the CI/CD pipeline to match the mxrepo workflow
and implements automated releases via GitHub Actions.

Based on refactor-package-layout branch.

## New Workflow Files

- Add lint.yml: Automated code quality checks (ruff, isort)
- Add typecheck.yml: Type checking with mypy
- Add release.yml: Automated PyPI publishing workflow
  - Publishes to Test PyPI on every master push
  - Publishes to production PyPI on GitHub releases
- Add dependabot.yml: Weekly GitHub Actions dependency updates

## Updated Workflow Files

- Update test.yml:
  - Switch from actions/setup-python to astral-sh/setup-uv@v7
  - Add workflow_call and workflow_dispatch triggers
  - Implement coverage artifact collection and reporting
  - Add dedicated coverage job with HTML report generation

- Update docs.yml:
  - Switch to astral-sh/setup-uv@v7 for consistency
  - Update action versions (checkout@v5, setup-node@v4)
  - Update Node.js version from 16 to 20
  - Add workflow_call trigger for reusability

## Build System Updates

- Update pyproject.toml:
  - Add hatch-vcs for automatic versioning from git tags
  - Add hatch-fancy-pypi-readme for combined readme
  - Make version and readme dynamic
  - Add ruff.lint configuration for code quality
  - Add pytest and coverage configuration
  - Preserve existing stricter mypy settings
  - Preserve existing isort "plone" profile
  - Maintain backward compatibility with zest.releaser config

## Documentation

- Add RELEASE.md: Comprehensive release process documentation
  - Automated GitHub release workflow
  - PyPI Trusted Publishing setup instructions
  - Version numbering guidelines
  - Troubleshooting guide
  - Migration notes from zest.releaser

## Related

- Addresses #3: GitHub Actions for testing with coverage artifacts
- Migrates release process from manual zest.releaser to automated GitHub releases
- Follows same pattern as https://github.com/mxstack/mxrepo
- Add tests/__init__.py to make tests a proper Python package
- Add requires-python = '>=3.10' to pyproject.toml
- Fixes import issues when running pytest
- Add noqa: S101 comment for type guard assert in resolver.py
- Fix per-file-ignores pattern to match tests/*.py instead of */tests.py
- Addresses S101 (assert detection) and E501 (line length) issues
- Add 'if TYPE_CHECKING:' to coverage exclude_lines
- TYPE_CHECKING blocks contain type-only imports that never execute at runtime
- Fixes coverage failure (99% -> 100%)
- Use 'source venv/bin/activate' instead of 'uv run coverage'
- uv run creates ephemeral environment without test dependencies
- Use the venv created by make install which has coverage installed
- Add 'parallel = true' to tool.coverage.run in pyproject.toml
- Update Makefile COVERAGE_COMMAND to include 'coverage combine'
- Fixes artifact upload: now creates .coverage.* files instead of single .coverage
- Required for combining coverage from multiple test matrix runs
- Add --keep flag to 'coverage combine' in Makefile
- Without --keep, combine deletes .coverage.* files after combining
- Test jobs need .coverage.* files to upload as artifacts
- Fixes 'No files were found with the provided path' error
- Add 'relative_files = true' to tool.coverage.run
- Makes coverage use relative paths instead of absolute paths
- Fixes path mismatch when combining coverage from macOS/Windows/Ubuntu
- Resolves 'No source for code' error when combining artifacts
@jensens jensens requested a review from rnixx November 7, 2025 16:47
Base automatically changed from refactor-package-layout to master November 10, 2025 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants