Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
Adds gh workflows.

Also refactors optional dependencies to tests and dev.
  • Loading branch information
maread99 authored Nov 18, 2022
1 parent 78c5c56 commit 8af144f
Show file tree
Hide file tree
Showing 11 changed files with 346 additions and 50 deletions.
28 changes: 28 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name-template: 'v$NEXT_PATCH_VERSION 🧮'
tag-template: '$NEXT_PATCH_VERSION'
categories:
- title: 'New Features'
label: 'enhancement'
- title: 'Deprecation'
label: 'deprecation'
- title: 'Bug Fixes'
labels:
- 'bug'
- 'Fix'
- title: 'Documentation'
label: 'documentation'
- title: 'Maintenance'
labels:
- 'maintenance'
- 'dependencies'
- 'github_actions'
- title: 'Testing'
label: 'tests'
- title: 'Under the Bonnet'
label: 'code improvement'
- title: 'Continuous Integration'
label: 'CI'
template: |
# What's Changed
$CHANGES
50 changes: 50 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and test

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
check-black:
# fail it if doesn't conform to black
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose"

build-and-test:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: 'requirements_tests.txt'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_tests.txt
pip install -e .
- name: Lint with flake8
# fail it if doesn't pass flake8
run: |
flake8 . --statistics
- name: Test with pytest
# fail it if doesn't pass test suite
run: |
pytest
16 changes: 16 additions & 0 deletions .github/workflows/draft-release-notes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Release Drafter

on:
push:
branches:
- main

# Updates next release notes on any push to main. Label a PR to categorize it
# in accordance with .github/release_drafter.yml.
jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Workflow to upload a Python Package using Twine when a release is created
name: Release to PyPI

on:
release:
types: [released]

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Install from testpypi and import
run: |
i=0
while (($i<12)) && [ "${{ github.ref_name }}" != $(pip index versions -i https://test.pypi.org/simple --pre beanahead | cut -d'(' -f2 | cut -d')' -f1 | sed 1q) ];\
do echo waiting for package to appear in test index, sleeping 5s; sleep 5s; let i++; done
pip install --index-url https://test.pypi.org/simple beanahead==${{ github.ref_name }} --no-deps
pip install -r requirements.txt
python -c 'import beanahead;print(beanahead.__version__)'
- name: Clean pip
run: |
pip uninstall -y beanahead
pip cache purge
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Install and import
run: |
i=0
while (($i<12)) && [ "${{ github.ref_name }}" != $(pip index versions -i https://pypi.org/simple --pre beanahead | cut -d'(' -f2 | cut -d')' -f1 | sed 1q) ];\
do echo waiting for package to appear in index, sleeping 5s; sleep 5s; let i++; done
pip install --index-url https://pypi.org/simple beanahead==${{ github.ref_name }}
python -c 'import beanahead;print(beanahead.__version__)'
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ dependencies = [
dynamic = ["version"]

[project.optional-dependencies]
dev = [
tests = [
"black",
"flake8",
"flake8-docstrings",
"pytest",
]
dev = [
"beanahead[tests]",
"mypy",
"pip-tools",
"pre-commit",
"pylint",
"pytest",
]

[project.urls]
Expand Down
26 changes: 13 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ chardet==5.0.0
# via beancount
charset-normalizer==2.1.1
# via requests
colorama==0.4.5
colorama==0.4.6
# via pytest
google-api-core==2.10.1
exceptiongroup==1.0.4
# via pytest
google-api-core==2.10.2
# via google-api-python-client
google-api-python-client==2.64.0
google-api-python-client==2.66.0
# via beancount
google-auth==2.12.0
google-auth==2.14.1
# via
# google-api-core
# google-api-python-client
# google-auth-httplib2
google-auth-httplib2==0.1.0
# via google-api-python-client
googleapis-common-protos==1.56.4
googleapis-common-protos==1.57.0
# via google-api-core
httplib2==0.20.4
httplib2==0.21.0
# via
# google-api-python-client
# google-auth-httplib2
Expand All @@ -45,22 +47,20 @@ iniconfig==1.1.1
# via pytest
lxml==4.9.1
# via beancount
numpy==1.23.3
numpy==1.23.4
# via pandas
packaging==21.3
# via pytest
pandas==1.5.0
pandas==1.5.1
# via beanahead (pyproject.toml)
pluggy==1.0.0
# via pytest
ply==3.11
# via beancount
protobuf==4.21.7
protobuf==4.21.9
# via
# google-api-core
# googleapis-common-protos
py==1.11.0
# via pytest
pyasn1==0.4.8
# via
# pyasn1-modules
Expand All @@ -71,13 +71,13 @@ pyparsing==3.0.9
# via
# httplib2
# packaging
pytest==7.1.3
pytest==7.2.0
# via beancount
python-dateutil==2.8.2
# via
# beancount
# pandas
pytz==2022.4
pytz==2022.6
# via pandas
requests==2.28.1
# via
Expand Down
Loading

0 comments on commit 8af144f

Please sign in to comment.