Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 88 additions & 42 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,99 @@
name: tests
name: CI

on: [push]
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]

jobs:
test:
get-python-versions:
runs-on: ubuntu-latest
outputs:
python-versions: ${{ steps.get-versions.outputs.python-versions }}
steps:
- uses: actions/checkout@v4
- name: Extract Python versions from pyproject.toml
id: get-versions
run: |
# Extract Python versions from classifiers in pyproject.toml
# This looks for lines like "Programming Language :: Python :: 3.8"
python_versions=$(grep -o 'Programming Language :: Python :: 3\.[0-9]\+' pyproject.toml | grep -o '3\.[0-9]\+' | sort -V | jq -R -s -c 'split("\n")[:-1]')
echo "python-versions=$python_versions" >> $GITHUB_OUTPUT
echo "Detected Python versions: $python_versions"

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 src/ tests/ --count --select=E9,F63,F7,F82 --show-source --statistics
# run full linting
flake8 src/ tests/

test:
needs: [get-python-versions, lint]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ${{ fromJson(needs.get-python-versions.outputs.python-versions) }}

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install .
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install -r requirements.txt
pytest
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
publish:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: test
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Test with pytest
run: pytest

build:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/

publish:
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Build package for publishing
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: dist
path: dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 0 additions & 1 deletion legistar/__init__.py

This file was deleted.

Loading
Loading