Skip to content

Commit

Permalink
use poetry as a python package manager
Browse files Browse the repository at this point in the history
  • Loading branch information
jcschaff committed Aug 30, 2024
1 parent 2e40d2d commit bf8b9f9
Show file tree
Hide file tree
Showing 7 changed files with 5,042 additions and 117 deletions.
42 changes: 42 additions & 0 deletions .github/actions/setup-poetry-env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: "setup-poetry-env"
description: "Composite action to setup the Python and poetry environment."

inputs:
python-version:
required: false
description: "The python version to use"
default: "3.11"

runs:
using: "composite"
steps:
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python-version }}

- name: Install Poetry
env:
POETRY_VERSION: "1.7.1"
run: curl -sSL https://install.python-poetry.org | python - -y
shell: bash

- name: Add Poetry to Path
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash

- name: Configure Poetry virtual environment in project
run: poetry config virtualenvs.in-project true
shell: bash

- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ inputs.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction
shell: bash
68 changes: 23 additions & 45 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,19 @@ jobs:
name: Lint, test, and compile documentation
if: "!contains(github.event.head_commit.message, '[skip ci]') && github.actor != 'allcontributors'"
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.9.9' # no particular microversion of 3.9 is required; 3.9.8 behaves oddly in GitHub actions

- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.optional.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install pip and setuptools
run: |
python -m pip install --upgrade pip==23.0.1
python -m pip install --upgrade setuptools
- name: Install Java # for pyNeuroML
uses: actions/setup-java@v2
with:
Expand All @@ -69,32 +58,21 @@ jobs:
singularity-version: 3.7.1

# install package
- name: Install the package
run: |
python -m pip install git+https://github.com/biosimulators/RBApy.git#egg=rbapy
python -m pip install .[all]
# lint
- name: Install flake8
run: python -m pip install flake8
- name: Set up the environment
uses: ./.github/actions/setup-poetry-env
with:
python-version: ${{ matrix.python-version }}

- name: Lint the package
run: python -m flake8

# test and upload coverage report to Codecov
- name: Install pytest
run: python -m pip install pytest pytest-cov

- name: Install the requirements for the tests
run: python -m pip install .[tests]

- name: Run the tests
uses: GabrielBB/xvfb-action@v1
env:
MPLBACKEND: PDF
# BIOSIMULATORS_API_ENDPOINT: https://api.biosimulators.dev/ # uncomment to execute tests with the dev deployment
with:
run: python -m pytest tests/ --cov=./biosimulators_utils --cov-report=xml
run: poetry run python -m pytest tests/ --cov=./biosimulators_utils --cov-report=xml

- name: Upload the coverage report to Codecov
uses: codecov/codecov-action@v2
Expand All @@ -104,22 +82,22 @@ jobs:
file: ./coverage.xml

# compile documentation
- name: Install the requirements for compiling the documentation
run: python -m pip install -r docs-src/requirements.txt
#- name: Install the requirements for compiling the documentation
# run: python -m pip install -r docs-src/requirements.txt

- name: Compile the documentation
run: |
sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
mkdir -p docs-src/_static
sphinx-build docs-src docs
#- name: Compile the documentation
# run: |
# sphinx-apidoc . setup.py --output-dir docs-src/source --force --module-first --no-toc
# mkdir -p docs-src/_static
# sphinx-build docs-src docs

release:
name: Release a new version
needs: [getVersionNumber, build]
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1
ref: dev
Expand All @@ -131,15 +109,15 @@ jobs:
git config pull.rebase false
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.9'

- name: Setup pip cache
uses: actions/cache@v2
with:
path: /opt/hostedtoolcache/Python
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements.optional.txt') }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}-${{ hashFiles('poetry.lock') }}
restore-keys: |
${{ runner.os }}-pip-
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ docs/.buildinfo
docs/.doctrees/
docs/_raw_sources/
docs/_sources/

.python-version
Loading

0 comments on commit bf8b9f9

Please sign in to comment.