Skip to content

Commit 1ece951

Browse files
authored
Merge pull request #2 from circuitpython/new_infra_files
new infrastructure files, use ruff, update for new displayio API
2 parents c8b9d22 + e7bed0c commit 1ece951

19 files changed

+252
-298
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -10,71 +10,5 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Dump GitHub context
14-
env:
15-
GITHUB_CONTEXT: ${{ toJson(github) }}
16-
run: echo "$GITHUB_CONTEXT"
17-
- name: Translate Repo Name For Build Tools filename_prefix
18-
id: repo-name
19-
run: |
20-
echo ::set-output name=repo-name::$(
21-
echo ${{ github.repository }} |
22-
awk -F '\/' '{ print tolower($2) }' |
23-
tr '_' '-'
24-
)
25-
- name: Set up Python 3.x
26-
uses: actions/setup-python@v2
27-
with:
28-
python-version: "3.x"
29-
- name: Versions
30-
run: |
31-
python3 --version
32-
- name: Checkout Current Repo
33-
uses: actions/checkout@v1
34-
with:
35-
submodules: true
36-
- name: Checkout tools repo
37-
uses: actions/checkout@v2
38-
with:
39-
repository: adafruit/actions-ci-circuitpython-libs
40-
path: actions-ci
41-
- name: Install dependencies
42-
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
43-
run: |
44-
source actions-ci/install.sh
45-
- name: Pip install pylint, Sphinx, pre-commit
46-
run: |
47-
pip install --force-reinstall pylint Sphinx sphinx-rtd-theme pre-commit
48-
- name: Library version
49-
run: git describe --dirty --always --tags
50-
- name: Setup problem matchers
51-
uses: adafruit/circuitpython-action-library-ci-problem-matchers@v1
52-
- name: Pre-commit hooks
53-
run: |
54-
pre-commit run --all-files
55-
- name: Build assets
56-
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
57-
- name: Archive bundles
58-
uses: actions/upload-artifact@v2
59-
with:
60-
name: bundles
61-
path: ${{ github.workspace }}/bundles/
62-
- name: Check For docs folder
63-
id: need-docs
64-
run: |
65-
echo ::set-output name=docs::$( find . -wholename './docs' )
66-
- name: Build docs
67-
if: contains(steps.need-docs.outputs.docs, 'docs')
68-
working-directory: docs
69-
run: sphinx-build -E -W -b html . _build/html
70-
- name: Check For setup.py
71-
id: need-pypi
72-
run: |
73-
echo ::set-output name=setup-py::$( find . -wholename './setup.py' )
74-
- name: Build Python package
75-
if: contains(steps.need-pypi.outputs.setup-py, 'setup.py')
76-
run: |
77-
pip install --upgrade setuptools wheel twine readme_renderer testresources
78-
python setup.py sdist
79-
python setup.py bdist_wheel --universal
80-
twine check dist/*
13+
- name: Run Build CI workflow
14+
uses: adafruit/workflows-circuitpython-libs/build@main

.github/workflows/release.yml

Lines changed: 0 additions & 88 deletions
This file was deleted.

.github/workflows/release_gh.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: GitHub Release Actions
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
upload-release-assets:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Run GitHub Release CI workflow
16+
uses: adafruit/workflows-circuitpython-libs/release-gh@main
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
upload-url: ${{ github.event.release.upload_url }}
20+
# TODO: If you're creating a package (library is a folder), add this
21+
# argument along with the prefix (or full name) of the package folder
22+
# so the MPY bundles are built correctly:s
23+
# package-prefix: displayio_effects

.github/workflows/release_pypi.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
name: PyPI Release Actions
6+
7+
on:
8+
release:
9+
types: [published]
10+
11+
jobs:
12+
upload-release-assets:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Run PyPI Release CI workflow
16+
uses: adafruit/workflows-circuitpython-libs/release-pypi@main
17+
with:
18+
pypi-username: ${{ secrets.pypi_username }}
19+
pypi-password: ${{ secrets.pypi_password }}

.pre-commit-config.yaml

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,21 @@
1-
# SPDX-FileCopyrightText: 2020 Diego Elio Pettenò
1+
# SPDX-FileCopyrightText: 2024 Justin Myers for Adafruit Industries
22
#
33
# SPDX-License-Identifier: Unlicense
44

55
repos:
6-
- repo: https://github.com/python/black
7-
rev: 20.8b1
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v4.5.0
88
hooks:
9-
- id: black
10-
- repo: https://github.com/fsfe/reuse-tool
11-
rev: v0.12.1
9+
- id: check-yaml
10+
- id: end-of-file-fixer
11+
- id: trailing-whitespace
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: v0.3.4
1214
hooks:
13-
- id: reuse
14-
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v2.3.0
15+
- id: ruff-format
16+
- id: ruff
17+
args: ["--fix"]
18+
- repo: https://github.com/fsfe/reuse-tool
19+
rev: v3.0.1
1620
hooks:
17-
- id: check-yaml
18-
- id: end-of-file-fixer
19-
- id: trailing-whitespace
20-
- repo: https://github.com/pycqa/pylint
21-
rev: pylint-2.7.1
22-
hooks:
23-
- id: pylint
24-
name: pylint (library code)
25-
types: [python]
26-
exclude: "^(docs/|examples/|tests/|setup.py$)"
27-
- repo: local
28-
hooks:
29-
- id: pylint_examples
30-
name: pylint (examples code)
31-
description: Run pylint rules on "examples/*.py" files
32-
entry: /usr/bin/env bash -c
33-
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name,consider-using-f-string $example; done)']
34-
language: system
35-
- id: pylint_tests
36-
name: pylint (tests code)
37-
description: Run pylint rules on "tests/*.py" files
38-
entry: /usr/bin/env bash -c
39-
args: ['([[ ! -d "tests" ]] || for test in $(find . -path "./tests/*.py"); do pylint --disable=missing-docstring $test; done)']
40-
language: system
21+
- id: reuse

.readthedocs.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
# Required
99
version: 2
1010

11+
sphinx:
12+
configuration: docs/conf.py
13+
1114
build:
12-
os: ubuntu-20.04
15+
os: ubuntu-lts-latest
1316
tools:
1417
python: "3"
1518

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ Introduction
1717
:alt: Build Status
1818

1919

20-
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
21-
:target: https://github.com/psf/black
22-
:alt: Code Style: Black
20+
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
21+
:target: https://github.com/astral-sh/ruff
22+
:alt: Code Style: Ruff
2323

2424
Add some flair to your widgets with effects!
2525

displayio_effects/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
https://circuitpython.org/downloads
2222
"""
2323

24-
2524
WIDGET_TYPE_ATTR = "_widget_type"
2625

26+
2727
# pylint: disable=too-few-public-methods
2828
class WidgetType:
2929
"""Enum values for customizable widget types. Valid options are:

displayio_effects/colorwheel_effect.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# SPDX-License-Identifier: MIT
55
# pylint: disable=protected-access
66
"""
7-
`displayio_effects.fluctuation_effect`
7+
`displayio_effects.colorwheel_effect`
88
================================================================================
99
1010
Add the colorwheel effect to your widgets
@@ -21,9 +21,10 @@
2121
https://circuitpython.org/downloads
2222
"""
2323

24+
from adafruit_itertools import cycle
2425
from rainbowio import colorwheel
25-
from adafruit_itertools.adafruit_itertools import cycle
26-
from displayio_effects import WidgetType, WIDGET_TYPE_ATTR
26+
27+
from displayio_effects import WIDGET_TYPE_ATTR, WidgetType
2728

2829
__version__ = "0.0.0-auto.0"
2930
__repo__ = "https://github.com/tekktrik/CircuitPython_Org_DisplayIO_Effects.git"
@@ -69,9 +70,7 @@ def hook_colorwheel_effect(widget_class, widget_type):
6970
"""
7071

7172
if not COLORWHEEL_WIDGET_VALUES.get(widget_type):
72-
raise ValueError(
73-
"The given widget does not have the ability to use this effect"
74-
)
73+
raise ValueError("The given widget does not have the ability to use this effect")
7574

7675
setattr(widget_class, WIDGET_TYPE_ATTR, widget_type)
7776

displayio_effects/fluctuation_effect.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"""
2323

2424
import random
25-
from displayio_effects import WidgetType, WIDGET_TYPE_ATTR
25+
26+
from displayio_effects import WIDGET_TYPE_ATTR, WidgetType
2627

2728
__version__ = "0.0.0-auto.0"
2829
__repo__ = "https://github.com/tekktrik/CircuitPython_Org_DisplayIO_Effects.git"
@@ -79,11 +80,10 @@ def update_fluctuation(self):
7980
self._fluctuation_destination = None
8081
return
8182

82-
if self._fluctuation_destination in (None, self._fluctuation_hold_value):
83+
if self._fluctuation_destination in {None, self._fluctuation_hold_value}:
8384
limit_bound = self._fluctuation_amplitude * 10
8485
self._fluctuation_destination = (
85-
random.uniform(-limit_bound, limit_bound) / 10
86-
+ self._fluctuation_hold_value
86+
random.uniform(-limit_bound, limit_bound) / 10 + self._fluctuation_hold_value
8787
)
8888

8989
value = getattr(self, value_name)
@@ -124,9 +124,7 @@ def hook_fluctuation_effect(widget_class, widget_type):
124124
"""
125125

126126
if not FLUCTUATION_WIDGET_VALUES.get(widget_type):
127-
raise ValueError(
128-
"The given widget does not have the ability to use this effect"
129-
)
127+
raise ValueError("The given widget does not have the ability to use this effect")
130128

131129
setattr(widget_class, WIDGET_TYPE_ATTR, widget_type)
132130

docs/api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
.. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py)
55
.. use this format as the module name: "adafruit_foo.foo"
66
7+
API Reference
8+
#############
9+
710
.. automodule:: displayio_effects.fluctuation_effect
811
:members:
12+
13+
.. automodule:: displayio_effects.colorwheel_effect
14+
:members:

0 commit comments

Comments
 (0)