Fix build action #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
check-version: | |
name: Ensure version has been bumped | |
runs-on: ubuntu-22.04 | |
if: github.event_name == 'pull_request' # Only run on PRs | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install toml package | |
run: pip install toml | |
- name: Check version | |
run: | | |
# Read current version from PR branch | |
CURRENT_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
echo "Current version: $CURRENT_VERSION" | |
# Checkout main branch to compare | |
git fetch origin main | |
git checkout origin/main | |
# Read version from main branch | |
MAIN_VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") | |
echo "Main version: $MAIN_VERSION" | |
# Checkout back to PR branch | |
git checkout - | |
# Compare versions | |
if [ "$CURRENT_VERSION" = "$MAIN_VERSION" ]; then | |
echo "Error: Version has not been bumped from $MAIN_VERSION" | |
exit 1 | |
fi | |
# Check if new version already exists as a tag | |
if git rev-parse "v$CURRENT_VERSION" >/dev/null 2>&1; then | |
echo "Error: Version v$CURRENT_VERSION already exists as a tag" | |
exit 1 | |
fi | |
echo "Version v$CURRENT_VERSION is new and has been bumped from v$MAIN_VERSION" | |
test: | |
name: Run tests | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
cache-dependency-glob: 'uv.lock' | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: 'pyproject.toml' | |
- name: install pis | |
run: uv sync --all-extras --dev | |
- name: run tests | |
run: uv run pytest | |
lint: | |
name: Check code style | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
cache-dependency-glob: 'uv.lock' | |
- name: set up python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: 'pyproject.toml' | |
- name: install pis | |
run: uv sync --all-extras --dev | |
- name: run ruff | |
run: uv run ruff check --output-format=github . |