Skip to content

Modernize typing (#22) #38

Modernize typing (#22)

Modernize typing (#22) #38

Workflow file for this run

name: CI
on:
push:
branches: [master]
tags:
- 'v*'
pull_request:
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Installation (deps and package)
run: pip install .
- uses: pre-commit/action@v3.0.1
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ['3.10', 3.11, 3.12, 3.13, 3.14]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Installation (deps and package)
# we install with flit --pth-file,
# so that coverage will be recorded for the module
run: |
pip install flit
flit install --deps=production --extras=test --pth-file
- name: Run pytest
run: |
pytest --cov=mdformat_pyproject --cov-report=xml --cov-report=term-missing
- name: Store PR number and commit SHA
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14
run: |
echo "Storing PR number ${{ github.event.number }}"
echo "${{ github.event.number }}" > pr_number.txt
echo "Storing commit SHA ${{ github.event.pull_request.head.sha }}"
echo "${{ github.event.pull_request.head.sha }}" > commit_sha.txt
# Workaround for codecov tokenless upload errors on external PRs
# Copied and ajusted from the workarounds suggested in the link below:
# https://github.com/codecov/feedback/issues/301#issuecomment-2009355183
# Triggered sub-workflow is not able to detect the original commit/PR which is available
# in this workflow.
- name: Store PR number
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14
uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
- name: Store commit SHA
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14
uses: actions/upload-artifact@v4
with:
name: commit_sha
path: commit_sha.txt
# This stores the coverage report in artifacts. The actual upload to Codecov
# is executed by a different workflow `coverage-report.yml`. The reason for this
# split is because `on.pull_request` workflows don't have access to secrets.
- name: Store coverage report in artifacts
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14
uses: actions/upload-artifact@v4
with:
name: codecov_report
path: ./coverage.xml
- run: |
echo "The coverage report was stored in Github artifacts."
echo "It will be uploaded to Codecov using [codecov.yml] workflow shortly."
if: matrix.os == 'ubuntu-latest' && matrix.python-version == 3.14
pre-commit-hook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Installation (deps and package)
run: |
pip install pre-commit
pip install .
- name: run pre-commit with plugin
run: |
pre-commit run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
publish:
name: Publish to PyPi
needs: [pre-commit, tests, pre-commit-hook]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v5
- name: Set up Python 3.14
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: install flit
run: |
pip install flit~=3.0
- name: Build and publish
run: |
flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_KEY }}