Skip to content

Commit

Permalink
update testing and release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhsmit committed Aug 7, 2023
1 parent fbf4515 commit e1e40de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 75 deletions.
11 changes: 4 additions & 7 deletions .github/workflows/pypi_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: |
pip install poetry-dynamic-versioning
- name: Install Hatch
run: pip install hatch
- name: Build
run: poetry build
- name: Publish distribution 📦 to Test PyPI
run: hatch build
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
11 changes: 4 additions & 7 deletions .github/workflows/pypi_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
run: |
pip install poetry-dynamic-versioning
- name: Install Hatch
run: pip install hatch
- name: Build
run: poetry build
run: hatch build
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
76 changes: 15 additions & 61 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,9 @@
name: Testing and Linting
name: Testing
on: [push]

# adapted from: https://github.com/tiangolo/poetry-version-plugin
jobs:
linting:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.9
#----------------------------------------------
# load pip cache if cache exists
#----------------------------------------------
- uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: ${{ runner.os }}-pip
#----------------------------------------------
# install and run linters
#----------------------------------------------
- run: python -m pip install black
- run: |
black . --check
test:
needs: linting
strategy:
fail-fast: true
matrix:
Expand All @@ -40,50 +14,30 @@ jobs:
shell: bash
runs-on: ${{ matrix.os }}
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3

- name: Set up python ${{ matrix.python-version }}
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
cache: pip
cache-dependency-path: requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt

- name: Install pinned requirements
run: |
python -m pip install --upgrade pip
pip install -r requirements/requirements-${{ matrix.os }}-${{ matrix.python-version }}.txt --prefer-binary
- name: Install test requirements
run: pip install .[test]

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ~/.venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: |
poetry install --no-interaction --no-root --all-extras
#----------------------------------------------
# install root project
#----------------------------------------------
- name: Install library
run: poetry install --no-interaction --all-extras
#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: |
source $VENV
pytest tests/
run: |
pytest tests/

0 comments on commit e1e40de

Please sign in to comment.