Skip to main content

Add some basic GitHub Actions config

ID
e129e46
date
2024-05-19 20:45:41+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
9f5c3d8
message
Add some basic GitHub Actions config
changed files
6 files, 113 additions, 5 deletions

Changed files

.github/dependabot.yml (0) → .github/dependabot.yml (203)

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000..47a31bc
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,10 @@
+version: 2
+updates:
+  - package-ecosystem: "github-actions"
+    directory: "/"
+    schedule:
+      interval: "daily"
+  - package-ecosystem: "pip"
+    directory: "/"
+    schedule:
+      interval: "daily"

.github/workflows/test.yml (0) → .github/workflows/test.yml (1007)

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..c0f149e
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,43 @@
+name: Test
+
+on:
+  push:
+    branches:
+    - main
+
+  pull_request:
+    branches:
+    - main
+
+jobs:
+  test:
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout@v4
+
+    - name: Set up Python
+      uses: actions/setup-python@v5
+      with:
+        python-version: 3.12
+        cache: pip
+        cache_path: dev_requirements.txt
+
+    - name: Install dependencies
+      run: pip install -r dev_requirements.txt
+
+    - name: Run linting
+      run: |
+        black --check .
+
+        # E501 = line too long; anything up to 100-ish is fine in my book
+        # (the "ish" is intentional; see https://www.youtube.com/watch?v=wf-BqAjZb8M)
+        #
+        # E203/W503/W504 = this is where black and flake8 conflict, see https://black.readthedocs.io/en/stable/faq.html#why-are-flake8-s-e203-and-w503-violated
+        flake8 --ignore=E501,E203,W503 --extend-select=W504
+
+    - name: Check types
+      run: mypy *.py expansions/*.py
+
+    - name: Build the workflow
+      run: python3 create_snippets.py

create_snippets.py (7434) → create_snippets.py (7452)

diff --git a/create_snippets.py b/create_snippets.py
index 91096ad..19115ad 100755
--- a/create_snippets.py
+++ b/create_snippets.py
@@ -9,8 +9,8 @@ import uuid
 import zipfile
 
 
-def read(name):
-    with open(os.path.join('expansions', name)) as infile:
+def read(name: str) -> str:
+    with open(os.path.join("expansions", name)) as infile:
         return infile.read()
 
 
@@ -251,7 +251,7 @@ SNIPPETS = {
 # fmt: on
 
 
-def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str):
+def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str) -> None:
     """
     Add a single snippet to a snippets bundle.
     """
@@ -273,11 +273,10 @@ def add_snippet(zf: zipfile.ZipFile, shortcut: str, expansion: str):
     zf.writestr(f"{snippet_id}.json", data=json.dumps(snippet_data))
 
 
-
 if __name__ == "__main__":
     curdir = pathlib.Path(os.getcwd()).absolute()
 
-    with zipfile.ZipFile(f"Alex’s snippets.alfredsnippets", "w") as zf:
+    with zipfile.ZipFile("Alex’s snippets.alfredsnippets", "w") as zf:
         zf.write("info.plist")
 
         for shortcut, expansion in SNIPPETS.items():

dev_requirements.in (0) → dev_requirements.in (18)

diff --git a/dev_requirements.in b/dev_requirements.in
new file mode 100644
index 0000000..355ed83
--- /dev/null
+++ b/dev_requirements.in
@@ -0,0 +1,3 @@
+black
+flake8
+mypy

dev_requirements.txt (0) → dev_requirements.txt (604)

diff --git a/dev_requirements.txt b/dev_requirements.txt
new file mode 100644
index 0000000..e7a1e32
--- /dev/null
+++ b/dev_requirements.txt
@@ -0,0 +1,32 @@
+#
+# This file is autogenerated by pip-compile with Python 3.12
+# by the following command:
+#
+#    pip-compile dev_requirements.in
+#
+black==24.4.2
+    # via -r dev_requirements.in
+click==8.1.7
+    # via black
+flake8==7.0.0
+    # via -r dev_requirements.in
+mccabe==0.7.0
+    # via flake8
+mypy==1.10.0
+    # via -r dev_requirements.in
+mypy-extensions==1.0.0
+    # via
+    #   black
+    #   mypy
+packaging==24.0
+    # via black
+pathspec==0.12.1
+    # via black
+platformdirs==4.2.2
+    # via black
+pycodestyle==2.11.1
+    # via flake8
+pyflakes==3.2.0
+    # via flake8
+typing-extensions==4.11.0
+    # via mypy

pyproject.toml (0) → pyproject.toml (497)

diff --git a/pyproject.toml b/pyproject.toml
new file mode 100644
index 0000000..38d30dd
--- /dev/null
+++ b/pyproject.toml
@@ -0,0 +1,21 @@
+[project]
+name = "snipperts"
+version = "1.0"
+
+[tool.mypy]
+mypy_path = "src"
+check_untyped_defs = true
+disallow_any_generics = true
+disallow_incomplete_defs = true
+disallow_subclassing_any = true
+disallow_untyped_calls = true
+disallow_untyped_decorators = true
+disallow_untyped_defs = true
+no_implicit_optional = true
+no_implicit_reexport = true
+show_error_codes = true
+strict_equality = true
+warn_redundant_casts = true
+warn_return_any = true
+warn_unused_configs = true
+warn_unused_ignores = true