Skip to content

Use Poetry for package management #97

Use Poetry for package management

Use Poetry for package management #97

Workflow file for this run

name: Lint and Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
# 1. Check out the repository
- uses: actions/checkout@v4
# 2. Set up Python environment
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# 3. Install Poetry
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
export PATH="$HOME/.local/bin:$PATH"
# 4. Cache Poetry dependencies
- name: Cache Poetry
uses: actions/cache@v4
with:
path: |
~/.cache/pypoetry
~/.local/share/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
# 5. Install project dependencies using Poetry
- name: Install dependencies
run: |
poetry install
# 6. Cache test dependencies
- name: Cache test dependencies
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-test-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-test-
# 7. Lint deps
- name: Install lint dependencies
run: |
pip install flake8
# 8. Lint with flake8 - Errors
- name: Lint with flake8 (Errors)
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
continue-on-error: false
# 9. Lint with flake8 - Warnings
- name: Lint with flake8 (Warnings)
run: |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
continue-on-error: true
# 10. Run tests with pytest
- name: Test with pytest
run: |
poetry run pytest --junitxml=reports/junit.xml --cov=graphedexcel --cov-report=xml
# 11. Upload test coverage to Codecov (Optional)
- name: Upload results to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
# 12. Upload Test Reports (Optional)
- name: Upload Test Report
if: always()
uses: actions/upload-artifact@v4
with:
name: dist-${{ matrix.python-version }}-junit-test-report
path: reports/junit.xml