Skip to content

Set up hatch

Set up hatch #340

Workflow file for this run

name: tests
on:
push:
branches: [main]
pull_request:
schedule:
# Run every Sunday
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
code-quality:
name: Code Quality
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install hatch
run: |
pipx install hatch
pipx inject hatch git+https://github.com/jayqi/hatch-conda.git@27-fix-filenotfounderror-hatchling
- uses: conda-incubator/setup-miniconda@v3
with:
mamba-version: "*"
channels: conda-forge
- name: Lint package
run: |
hatch run lint
hatch run typecheck
tests:
name: Tests (${{ matrix.os }}, Python ${{ matrix.python-version }})
needs: code-quality
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest] # [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.8, 3.9, "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install hatch
run: |
pipx install hatch
pipx inject hatch git+https://github.com/jayqi/hatch-conda.git@27-fix-filenotfounderror-hatchling
- uses: conda-incubator/setup-miniconda@v3
with:
mamba-version: "*"
channels: conda-forge
- name: Run tests
run: |
hatch run tests.py${{ matrix.python-version }}:test
- name: Upload coverage to codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
fail_ci_if_error: true
if: ${{ matrix.os == 'ubuntu-latest' }}
- name: Build distribution and test installation
shell: bash
run: |
hatch build
python -m pip install dist/erdantic-*.whl --no-deps --force-reinstall
erdantic --version
python -m pip install dist/erdantic-*.tar.gz --no-deps --force-reinstall
erdantic --version
# - name: Test building documentation
# run: |
# hatch docs:builds
# if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
# - name: Deploy site preview to Netlify
# if: |
# matrix.os == 'ubuntu-latest' && matrix.python-version == '3.10'
# && github.event.pull_request != null
# uses: nwtgck/[email protected]
# with:
# publish-dir: "./docs/site"
# production-deploy: false
# github-token: ${{ secrets.GITHUB_TOKEN }}
# deploy-message: "Deploy from GitHub Actions"
# enable-pull-request-comment: true
# enable-commit-comment: false
# overwrites-pull-request-comment: true
# alias: deploy-preview-${{ github.event.number }}
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# timeout-minutes: 1
notify:
name: Notify failed build
needs: [code-quality, tests]
if: failure() && github.event.pull_request == null
runs-on: ubuntu-latest
steps:
- uses: jayqi/failed-build-issue-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}