Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates gh-actions, initial packaging, quality automation #3

Merged
merged 17 commits into from
Feb 7, 2024
Merged
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
13 changes: 13 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[bumpversion]
current_version = 0.1.0
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(-(?P<stage>[^.]*)\.(?P<devnum>\d+))?
serialize =
{major}.{minor}.{patch}-{stage}.{devnum}
{major}.{minor}.{patch}-{stage}
{major}.{minor}.{patch}

[bumpversion:part:devnum]

[bumpversion:file:pyproject.toml]
21 changes: 21 additions & 0 deletions .github/workflows/darker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 🧹 Darker

on:
pull_request:
branches:
- main

jobs:
darker-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.12'
- uses: akaihola/[email protected]
with:
version: "1.7.2"
74 changes: 53 additions & 21 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,63 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Tests
name: '🔎 Python Tests'

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
branches:
- main

permissions:
contents: read
concurrency:
group: ci-tests-${{ github.ref }}-pytest
cancel-in-progress: true

jobs:
build:
python-tests:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.8", "3.12" ]

steps:
- uses: actions/checkout@v3
- name: Set up Python 3.12
uses: actions/setup-python@v3
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[test]
- name: Test with pytest
run: pytest
- name: Checkout repo
uses: actions/checkout@v4


- id: setup_python
name: Set up Python ${{ matrix.python-version }} Environment
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- id: python_cache
name: Retrieve Cached Python Dependencies
uses: actions/cache@v4
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-pip-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('dev-requirements.txt', 'requirements.txt') }}

- name: Upgrade pip
if: steps.python_cache.outputs.cache-hit != 'true'
run: python -m pip install --upgrade pip

- name: Install Dependencies
run: pip install .[test]

- name: Tests (Coverage)
if: matrix.python-version == '3.12'
run: |
pip install coverage
coverage run --data-file=data -m pytest tests
coverage xml -i --data-file=data -o coverage.xml

- name: Tests
if: matrix.python-version != '3.12'
run: pytest tests

- name: Upload to Codecov
if: matrix.python-version == '3.12'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
fail_ci_if_error: false
verbose: true
6 changes: 3 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Upload Python Package
name: 📦 Upload Python Package

on:
release:
Expand All @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: 🧹 Lint with Ruff

on:
pull_request:
branches:
- main

jobs:
ruff-lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
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
python -m pip install ruff
pip install .

- name: Lint with Ruff
run: ruff --output-format=github atxm
50 changes: 50 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Install with: pre-commit install && pre-commit install -t pre-push
repos:

- repo: local
hooks:

- id: tests
name: Run Tests
entry: scripts/run_tests.sh
language: system
types: [python]
stages: [push]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:

# Git
- id: forbid-new-submodules

# Files
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-added-large-files
- id: check-symlinks
- id: end-of-file-fixer

# Syntax
- id: check-yaml
- id: check-toml
- id: check-ast

# Code
- id: check-merge-conflict
- id: debug-statements
- id: detect-private-key

- repo: https://github.com/akaihola/darker
rev: 1.7.2
hooks:
- id: darker
args: ["--check"]
stages: [push]
- id: darker
stages: [commit]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.1.4'
hooks:
- id: ruff
28 changes: 28 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
web3 = "*"
twisted = "*"
eth-account = "<0.11,>=0.10.0"
eth-typing = "<4,>=3.5.2"
eth-utils = "<3,>=2.3.1"
eth-abi = "<5,>=4.2.1"
eth-keys = "<0.5,>=0.4.0"
rlp = "<4,>=3.0.0"

[dev-packages]
# testing
eth-ape = "*"
pytest = "*"
pytest-mock = "*"
pytest-twisted = "*"
# quality control
pre-commit = "*"
black = "*"
ruff = "*"

[requires]
python_version = "3"
Loading
Loading