Skip to content

Commit

Permalink
switch to pre-commit and pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Feb 3, 2023
1 parent 88d57a3 commit b9928d4
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 630 deletions.
184 changes: 129 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,135 @@
name: Build CI

on: [pull_request, push]
on:
pull_request:
types: [opened, reopened]
push:

jobs:
test:
build-wheel:
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
run: |
echo ::set-output name=repo-name::$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
)
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Versions
run: |
python3 --version
- name: Checkout Current Repo
uses: actions/checkout@v1
with:
submodules: true
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: adafruit/actions-ci-circuitpython-libs
path: actions-ci
- name: Install deps
run: |
source actions-ci/install.sh
- name: Pip install pylint, black, & Sphinx stuff
run: |
pip install pylint black
pip install -r docs/requirements.txt
- name: Library version
run: git describe --dirty --always --tags
- name: PyLint
run: |
pylint circuitpython_cirque_pinnacle/*.py
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace,too-few-public-methods $( find . -path "./examples/*.py" ))
- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . --package_folder_prefix circuitpython_cirque_pinnacle
- name: Archive bundles
uses: actions/upload-artifact@v2
with:
name: bundles
path: ${{ github.workspace }}/bundles/
- name: Build docs
working-directory: docs
run: |
pip install ..
sphinx-build -E -W -b html . _build/html
- uses: actions/setup-python@v4
with:
python-version: "3.x"

- uses: actions/checkout@v3

- name: Build wheel
run: pip wheel -w dist --no-deps .

- name: check dist
run: pipx run twine check dist/*

- name: Archive wheel
uses: actions/upload-artifact@v3
with:
name: wheel
path: ${{ github.workspace }}/dist/

linters:
runs-on: ubuntu-latest
steps:

- uses: actions/setup-python@v4
with:
python-version: "3.x"

- uses: actions/checkout@v3

- name: Install pre-commit and deps
run: pip install pre-commit -r requirements.txt

- name: Setup problem matchers
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1

- name: Pre-commit hooks
run: pre-commit run --all-files

# test-coverage:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3

# - uses: actions/setup-python@v4
# with:
# python-version: "3.x"

# - name: Install testing tools
# run: pip install -r requirements.txt -r tests/requirements.txt

# - name: Collect coverage
# run: |
# coverage run -m pytest
# coverage report
# coverage xml

# - name: Upload coverage reports to Codecov
# uses: codecov/codecov-action@v3
# with:
# files: ./coverage.xml
# verbose: true # optional (default = false)

build-bundles:
runs-on: ubuntu-latest
steps:
- name: Translate Repo Name For Build Tools filename_prefix
id: repo-name
run: |
echo repo-name=$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }' |
tr '_' '-'
) >> $GITHUB_OUTPUT
- name: Translate Repo Name For Build Tools package_prefix
id: pkg-name
run: |
echo pkg-name=$(
echo ${{ github.repository }} |
awk -F '\/' '{ print tolower($2) }'
) >> $GITHUB_OUTPUT
- uses: actions/checkout@v3

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

- name: Install deps
run: pip install circuitpython-build-tools

- name: Build assets
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --package_folder_prefix ${{ steps.pkg-name.outputs.pkg-name }} --library_location .

- name: Archive bundles
uses: actions/upload-artifact@v3
with:
name: bundles
path: ${{ github.workspace }}/bundles/

build-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

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

- name: Install deps
run: |
pip install -r docs/requirements.txt -r requirements.txt
sudo apt-get install graphviz
- name: Build docs
working-directory: docs
run: sphinx-build -E -W -b html . _build/html

- name: Archive docs
uses: actions/upload-artifact@v3
with:
name: docs
path: ${{ github.workspace }}/docs/_build/html
43 changes: 43 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
repos:
- repo: https://github.com/python/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/pylint
rev: v2.15.3
hooks:
- id: pylint
name: pylint (library code)
types: [python]
args:
- --disable=consider-using-f-string,duplicate-code,too-many-public-methods,too-few-public-methods
exclude: "^(docs/|examples/|tests/|setup.py$)"
additional_dependencies: ["adafruit-circuitpython-busdevice"]
- id: pylint
name: pylint (example code)
description: Run pylint rules on "examples/*.py" files
types: [python]
files: "^examples/"
args:
- --disable=missing-docstring,invalid-name,consider-using-f-string,duplicate-code,import-error
- id: pylint
name: pylint (test code)
description: Run pylint rules on "tests/*.py" files
types: [python]
additional_dependencies: [pytest]
files: "^tests/"
args:
- --disable=import-error,invalid-name,protected-access,too-few-public-methods
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.981
hooks:
- id: mypy
name: mypy (library code)
exclude: "^(docs/|examples/|tests/|setup.py$)"
types: [python]

0 comments on commit b9928d4

Please sign in to comment.