Skip to content

Fix CI virtual environment setup for tests #298

Fix CI virtual environment setup for tests

Fix CI virtual environment setup for tests #298

Workflow file for this run

---
name: CI
"on":
push:
branches: [main]
tags: [v*]
pull_request: null
jobs:
prek:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.12
- uses: j178/prek-action@v1
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.12"]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v5
- name: Install uv and Python
uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
- name: Create virtual environment
run: uv venv
- name: Activate virtual environment
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "$GITHUB_WORKSPACE/.venv/Scripts" >> $GITHUB_PATH
else
echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
fi
shell: bash
- name: Install Package
run: uv pip install ".[test]"
- name: Run pytest
run: pytest --cov
prek-hook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv and Python
uses: astral-sh/setup-uv@v7
with:
python-version: 3.12
- name: Install prek
uses: j178/prek-action@v1
with:
install-only: true
- name: Create virtual environment
run: uv venv
- name: Activate virtual environment
run: echo "$GITHUB_WORKSPACE/.venv/bin" >> $GITHUB_PATH
- name: Install Package
run: uv pip install ".[test]"
- name: run prek with plugin
run: prek run --config .pre-commit-test.yaml --all-files --verbose --show-diff-on-failure
publish:
name: Publish to PyPi
needs: [prek, tests, prek-hook]
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/mdformat-mkdocs
permissions:
contents: write # For GitHub release creation
id-token: write # IMPORTANT: mandatory for PyPI trusted publishing
steps:
- uses: actions/checkout@v5
- name: Install uv and Python
uses: astral-sh/setup-uv@v7
with:
python-version: 3.12
- name: Build Package
run: uv build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
- name: Generate GitHub Release Notes
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true