Skip to content

Commit

Permalink
Empty project
Browse files Browse the repository at this point in the history
  • Loading branch information
apmorton committed Jun 19, 2024
0 parents commit 3590e5f
Show file tree
Hide file tree
Showing 16 changed files with 771 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and upload to PyPI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main
release:
types:
- published

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Hatch
run: pipx install hatch

- name: Hatch Build
run: hatch build

- uses: actions/upload-artifact@v4
with:
name: hatch-build-sdist-and-wheel
path: ./dist/*

upload_pypi:
needs: [build]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v4
with:
pattern: hatch-build-*
path: dist
merge-multiple: true

- uses: pypa/gh-action-pypi-publish@release/v1
113 changes: 113 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
name: test

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

env:
STABLE_PYTHON_VERSION: '3.11'
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"

jobs:
run:
name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Hatch
run: pipx install hatch

- name: Run pre-commit checks
uses: pre-commit/[email protected]

- name: Run static analysis
run: hatch fmt --check

- name: Check types
run: hatch run types:check

- name: Run tests
run: hatch test --python ${{ matrix.python-version }} --cover --randomize --parallel

- name: Disambiguate coverage filename
run: mv .coverage ".coverage.${{ matrix.os }}.${{ matrix.python-version }}"

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage*

coverage:
name: Report coverage
runs-on: ubuntu-latest
needs:
- run

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ env.STABLE_PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.STABLE_PYTHON_VERSION }}

- name: Install Hatch
run: pipx install hatch

- name: Trigger build for auto-generated files
run: hatch build --hooks-only

- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-*
merge-multiple: true

- name: Combine coverage data
run: hatch run coverage:combine

- name: Export coverage reports
run: |
hatch run coverage:report-xml
hatch run coverage:report-uncovered-html
- name: Upload uncovered HTML report
uses: actions/upload-artifact@v4
with:
name: uncovered-html-report
path: htmlcov

- name: Generate coverage summary
run: hatch run coverage:generate-summary

- name: Write coverage summary report
if: github.event_name == 'pull_request'
run: hatch run coverage:write-summary-report

- name: Update coverage pull request comment
if: github.event_name == 'pull_request'
uses: marocchino/sticky-pull-request-comment@v2
with:
path: coverage-report.md
Loading

0 comments on commit 3590e5f

Please sign in to comment.