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

CI #116

Merged
merged 42 commits into from
Mar 1, 2024
Merged

CI #116

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
47b7ee6
We're not using mypy anymore
ekiefl Feb 28, 2024
638c6ec
Make pyright conversion official
ekiefl Feb 29, 2024
c9ca5fe
First test with CI
ekiefl Feb 29, 2024
08cd1c5
CODEOWNERS file
ekiefl Feb 29, 2024
c2d0860
Update logo to have border (for social media preview
ekiefl Feb 29, 2024
f3dd1c7
update isort and black entries in precommit yaml
ekiefl Feb 29, 2024
987658c
change order of importance
ekiefl Feb 29, 2024
ab51a45
Global apply with black and isort
ekiefl Feb 29, 2024
7945348
touchup
ekiefl Feb 29, 2024
073ce89
Only test in pooltool/
ekiefl Feb 29, 2024
6a14b87
continue-on-error for all checks
ekiefl Feb 29, 2024
f25f52e
Change test order
ekiefl Feb 29, 2024
61edc01
I don't use VSCode, not my problem
ekiefl Feb 29, 2024
f7c41da
switch from black to ruff; pre-commits failing
ekiefl Feb 29, 2024
0f3b2d5
separate pyright as CI test and as a IDE tool
ekiefl Feb 29, 2024
412b4df
Create a super test that yields results from each
ekiefl Feb 29, 2024
3e71f03
Update output
ekiefl Feb 29, 2024
7b7e142
remove pyright from pyproject
ekiefl Feb 29, 2024
ae4e91a
Testing
ekiefl Feb 29, 2024
e4a34a7
New idea
ekiefl Feb 29, 2024
0f301d3
Another attempt
ekiefl Feb 29, 2024
5e9ab9a
test
ekiefl Feb 29, 2024
a1d7daa
test
ekiefl Feb 29, 2024
27d2e0f
test
ekiefl Feb 29, 2024
0d7595a
Finish CI job formatting for now
ekiefl Feb 29, 2024
14bc57c
Fix all ruff complaints
ekiefl Mar 1, 2024
1542baa
Make failure and success easier to spot
ekiefl Mar 1, 2024
10b7ac4
Touchup
ekiefl Mar 1, 2024
a52a1c2
Modernize error module
ekiefl Mar 1, 2024
04d5b15
Add types for terminal module
ekiefl Mar 1, 2024
b9ffa72
Clean up pyright complaints
ekiefl Mar 1, 2024
20ed90c
Ignore sympy import in test fn
ekiefl Mar 1, 2024
e0c6fe4
Celebrate if CI tests pass
ekiefl Mar 1, 2024
b075092
Fix doc format
ekiefl Mar 1, 2024
6c0e56f
Remove isort and replace with ruff
ekiefl Mar 1, 2024
bc79742
Add verbosity
ekiefl Mar 1, 2024
5f7f413
add diff
ekiefl Mar 1, 2024
7823432
Bump ruff
ekiefl Mar 1, 2024
7fee828
test
ekiefl Mar 1, 2024
cde9545
Add versions
ekiefl Mar 1, 2024
bbf5af4
asdf
ekiefl Mar 1, 2024
a3bf7c6
test
ekiefl Mar 1, 2024
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @ekiefl
118 changes: 118 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

on:
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements-dev.txt

# --- Ruff

- name: ruff (lint)
id: ruff_lint
continue-on-error: true
run: |
ruff --version
ruff check . --verbose --diff
echo "ruff_lint_failed=$?" >> $GITHUB_ENV

- name: ruff (format)
id: ruff_format
continue-on-error: true
run: |
ruff --version
ruff format . --check --verbose --diff
echo "ruff_format_failed=$?" >> $GITHUB_ENV

# --- Pytest

- name: pytest
id: pytest
continue-on-error: true
run: |
pytest --version
pytest
echo "pytest_failed=$?" >> $GITHUB_ENV

# --- Pyright

- name: pyright
id: pyright
continue-on-error: true
run: |
pyright --version
pyright --project ./pyrightconfig.ci.json
echo "pyright_failed=$?" >> $GITHUB_ENV

# --- Main

- name: Test results
if: always()
run: |
# Print out test results
passed=()
failed=()

if [[ "${{ env.pytest_failed }}" != "0" ]]; then
failed+=("pytest")
else
passed+=("pytest")
fi

if [[ "${{ env.pyright_failed }}" != "0" ]]; then
failed+=("pyright")
else
passed+=("pyright")
fi

if [[ "${{ env.ruff_lint_failed }}" != "0" ]]; then
failed+=("ruff_lint")
else
passed+=("ruff_lint")
fi

if [[ "${{ env.ruff_format_failed }}" != "0" ]]; then
failed+=("ruff_format")
else
passed+=("ruff_format")
fi

if [ ${#passed[@]} -ne 0 ]; then
echo "✅ PASSED:"
for check in "${passed[@]}"; do
echo " - $check"
done
fi

echo ""

if [ ${#failed[@]} -ne 0 ]; then
echo "❌ FAILED:"
for check in "${failed[@]}"; do
echo " - $check"
done
else
echo "🚀🚀 ALL TESTS PASSED 🚀🚀"
fi

echo ""
echo "Click above jobs for details on each success/failure"

if [ ${#failed[@]} -ne 0 ]; then
exit 1
fi
16 changes: 7 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format

- repo: local
hooks:
- id: isort
name: isort
entry: isort
language: system
- id: black
name: black
entry: black
language: system
types_or: [python, pyi]
- id: pytest
name: pytest
entry: pytest
Expand Down
15 changes: 0 additions & 15 deletions .vscode/settings.json

This file was deleted.

48 changes: 25 additions & 23 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

import os
import sys
sys.path.insert(0, os.path.abspath('../'))

sys.path.insert(0, os.path.abspath("../"))

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -46,7 +47,7 @@
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
# NOTE: Don't use this for excluding python files, use `autoapi_ignore` below
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# -- Global options ----------------------------------------------------------

Expand All @@ -59,7 +60,7 @@
# a list of builtin themes.
#
html_theme = "furo"
html_logo = '../pooltool/logo/logo_small.png'
html_logo = "../pooltool/logo/logo_small.png"

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -85,14 +86,14 @@
}

# -- copybutton options
copybutton_exclude = '.linenos, .gp, .go'
copybutton_exclude = ".linenos, .gp, .go"

# -- myst options
myst_enable_extensions = ["colon_fence"]

# -- autoapi configuration ---------------------------------------------------

#autodoc_typehints = "signature" # autoapi respects this
# autodoc_typehints = "signature" # autoapi respects this
autodoc_typehints = "both" # autoapi respects this
autodoc_typehints_description_target = "documented_params" # autoapi respects this
autodoc_class_signature = "mixed"
Expand All @@ -110,29 +111,30 @@
autoapi_keep_files = True

autoapi_ignore = [
'*/test_*.py',
"*/test_*.py",
"*/render.py",
"*/ai/*",
"*/user_config.py",
]
# Everything in ani/ except animate.py
autoapi_ignore.extend([
"*/ani/camera/*",
"*/ani/fonts/*",
"*/ani/image/*",
"*/ani/modes/*",
"*/ani/__init__.py",
"*/ani/action.py",
"*/ani/collision.py",
"*/ani/environment.py",
"*/ani/globals.py",
"*/ani/hud.py",
"*/ani/menu.py",
"*/ani/mouse.py",
"*/ani/tasks.py",
"*/ani/utils.py",
])

autoapi_ignore.extend(
[
"*/ani/camera/*",
"*/ani/fonts/*",
"*/ani/image/*",
"*/ani/modes/*",
"*/ani/__init__.py",
"*/ani/action.py",
"*/ani/collision.py",
"*/ani/environment.py",
"*/ani/globals.py",
"*/ani/hud.py",
"*/ani/menu.py",
"*/ani/mouse.py",
"*/ani/tasks.py",
"*/ani/utils.py",
]
)


# -- custom auto_summary() macro ---------------------------------------------
Expand Down
11 changes: 7 additions & 4 deletions docs/custom_directives.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from docutils import nodes
from sphinx.util.docutils import SphinxDirective


class CachedPropertyDirective(SphinxDirective):
required_arguments = 0
optional_arguments = 0
Expand All @@ -9,7 +10,7 @@ class CachedPropertyDirective(SphinxDirective):

def run(self):
targetid = f"cached-property-{self.env.new_serialno('cached-property')}"
targetnode = nodes.target('', '', ids=[targetid])
targetnode = nodes.target("", "", ids=[targetid])

# Create an admonition node to hold the content
admonition_node = nodes.admonition()
Expand All @@ -23,12 +24,14 @@ def run(self):
post_text = ", and should be accessed as an attribute, not as a method call."

# Creating the hyperlink
uri = "https://docs.python.org/3/library/functools.html#functools.cached_property"
uri = (
"https://docs.python.org/3/library/functools.html#functools.cached_property"
)
link_text = "cached property"
hyperlink = nodes.reference('', '', nodes.Text(link_text), refuri=uri)
hyperlink = nodes.reference("", "", nodes.Text(link_text), refuri=uri)

# Creating the paragraph and adding the intro text and hyperlink
para = nodes.paragraph('', '')
para = nodes.paragraph("", "")
para += nodes.Text(pre_text, pre_text)
para += hyperlink
para += nodes.Text(post_text, post_text)
Expand Down
12 changes: 7 additions & 5 deletions docs/custom_extensions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import attr
import re

import attr
from sphinx.application import Sphinx


def extract_qualified_name(obj):
repr_str = repr(obj)
class_or_instance_method_pattern = r"<bound method ([\w\.]+)\.([\w]+) of"
Expand All @@ -24,17 +26,17 @@ def extract_qualified_name(obj):

def process_signature(app, what, name, obj, options, signature, return_annotation):
# Check if the object is a class or a method of an attrs class
if attr.has(obj) or (hasattr(obj, '__objclass__') and attr.has(obj.__objclass__)):
if attr.has(obj) or (hasattr(obj, "__objclass__") and attr.has(obj.__objclass__)):
cls = obj if attr.has(obj) else obj.__objclass__
attrs_fields = attr.fields_dict(cls)

new_signature = signature
for field_name, attr_obj in attrs_fields.items():
if isinstance(attr_obj.default, attr.Factory):
# Extract full name from the factory's __repr__
factory_full_name = extract_qualified_name(attr_obj.default.factory)
replacement_str = f"{factory_full_name}"

# Define a regex pattern to match the parameter, its type, and the default value
pattern = re.compile(rf"({field_name}: [^=]+ = )_Nothing.NOTHING")
# Replace with the new default value representation
Expand All @@ -44,4 +46,4 @@ def process_signature(app, what, name, obj, options, signature, return_annotatio


def setup(app: Sphinx):
app.connect('autodoc-process-signature', process_signature)
app.connect("autodoc-process-signature", process_signature)
4 changes: 2 additions & 2 deletions docs/custom_skip_members.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#def autoapi_skip_members(app, what, name, obj, skip, options):
# def autoapi_skip_members(app, what, name, obj, skip, options):
# print(what, name, skip)
# # skip submodules
# if what == "module":
Expand Down Expand Up @@ -26,5 +26,5 @@
# return skip
#
#
#def setup(app):
# def setup(app):
# app.connect("autoapi-skip-member", autoapi_skip_members)
2 changes: 1 addition & 1 deletion docs/test_custom_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def just_a_func():
pass


lambda_func = lambda x: x
lambda_func = lambda x: x # noqa: E731


def test_a_class_method():
Expand Down
38 changes: 0 additions & 38 deletions mypy.ini

This file was deleted.

Loading
Loading