Skip to main content

Merge pull request #2 from alexwlchan/upgrade-github-actions

ID
73ccfe6
date
2024-05-07 08:49:48+00:00
author
Alex Chan <alex@alexwlchan.net>
parents
cda9737, 6302187
message
Merge pull request #2 from alexwlchan/upgrade-github-actions

Upgrade my GitHub Actions setup
changed files
8 files, 75 additions, 56 deletions

Changed files

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

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

.github/workflows/main.yml (601) → .github/workflows/main.yml (1149)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index ff94e59..8e09909 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -1,29 +1,44 @@
-on: push
+name: Run tests
+
+on:
+  push:
+    branches:
+    - main
+
+  pull_request:
+    branches:
+    - main
 
 jobs:
   test:
     runs-on: ubuntu-latest
-    timeout-minutes: 10
 
     steps:
       - name: Check out repository code
-        uses: actions/checkout@v3
+        uses: actions/checkout@v4
 
       - name: Setup Python
-        uses: actions/setup-python@v2
+        uses: actions/setup-python@v5
         with:
-          python-version: "3.10"
+          python-version: 3.12
+          cache: pip
+          cache-dependency-path: dev_requirements.txt
 
       - name: Install dependencies
-        run: |
-          pip3 install --user -r requirements_test.txt
+        run: python3 -m pip install -r dev_requirements.txt
 
       - name: Check formatting
         run: |
-          black .
-          git diff --exit-code
+          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: Run test suite
         run: |
           coverage run -m pytest test_concurrently.py
-          coverage report
+          coverage report --skip-covered --fail-under=100

dev_requirements.in (0) → dev_requirements.in (24)

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

dev_requirements.txt (0) → dev_requirements.txt (713)

diff --git a/dev_requirements.txt b/dev_requirements.txt
new file mode 100644
index 0000000..6f291f0
--- /dev/null
+++ b/dev_requirements.txt
@@ -0,0 +1,38 @@
+#
+# This file is autogenerated by pip-compile with Python 3.11
+# by the following command:
+#
+#    pip-compile dev_requirements.in
+#
+black==24.4.2
+    # via -r dev_requirements.in
+click==8.1.7
+    # via black
+coverage[toml]==7.5.1
+    # via pytest-cov
+flake8==7.0.0
+    # via -r dev_requirements.in
+iniconfig==2.0.0
+    # via pytest
+mccabe==0.7.0
+    # via flake8
+mypy-extensions==1.0.0
+    # via black
+packaging==24.0
+    # via
+    #   black
+    #   pytest
+pathspec==0.12.1
+    # via black
+platformdirs==4.2.1
+    # via black
+pluggy==1.5.0
+    # via pytest
+pycodestyle==2.11.1
+    # via flake8
+pyflakes==3.2.0
+    # via flake8
+pytest==8.2.0
+    # via pytest-cov
+pytest-cov==5.0.0
+    # via -r dev_requirements.in

examples/downloading.py (834) → examples/downloading.py (832)

diff --git a/examples/downloading.py b/examples/downloading.py
index 1c0c334..ce30d1a 100755
--- a/examples/downloading.py
+++ b/examples/downloading.py
@@ -26,5 +26,5 @@ def save_http_cat(status_code):
 if __name__ == "__main__":
     codes = [200, 201, 202, 301, 302, 400, 405, 410, 418, 420, 451, 500]
 
-    for (input, output) in concurrently(save_http_cat, inputs=codes):
+    for input, output in concurrently(save_http_cat, inputs=codes):
         print(input, output)

examples/sleepy_multiply.py (713) → examples/sleepy_multiply.py (711)

diff --git a/examples/sleepy_multiply.py b/examples/sleepy_multiply.py
index ad52faa..b2c1ec2 100755
--- a/examples/sleepy_multiply.py
+++ b/examples/sleepy_multiply.py
@@ -30,5 +30,5 @@ if __name__ == "__main__":
         (6, 1),
     ]
 
-    for ((x, y), output) in concurrently(lambda x: sleepy_multiply(*x), inputs=inputs):
+    for (x, y), output in concurrently(lambda x: sleepy_multiply(*x), inputs=inputs):
         print(x, "*", y, "=", output)

requirements_test.in (17) → requirements_test.in (24)

diff --git a/requirements_test.in b/requirements_test.in
index 3a4c1fb..ac72043 100644
--- a/requirements_test.in
+++ b/requirements_test.in
@@ -1,2 +1,3 @@
 black
+flake8
 pytest-cov

requirements_test.txt (776) → requirements_test.txt (0)

diff --git a/requirements_test.txt b/requirements_test.txt
deleted file mode 100644
index 494f358..0000000
--- a/requirements_test.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-# This file is autogenerated by pip-compile
-# To update, run:
-#
-#    pip-compile requirements_test.in
-#
-attrs==21.2.0
-    # via pytest
-black==21.9b0
-    # via -r requirements_test.in
-click==8.0.3
-    # via black
-coverage[toml]==6.0.2
-    # via pytest-cov
-iniconfig==1.1.1
-    # via pytest
-mypy-extensions==0.4.3
-    # via black
-packaging==21.0
-    # via pytest
-pathspec==0.9.0
-    # via black
-platformdirs==2.4.0
-    # via black
-pluggy==1.0.0
-    # via pytest
-py==1.10.0
-    # via pytest
-pyparsing==3.0.1
-    # via packaging
-pytest-cov==3.0.0
-    # via -r requirements_test.in
-pytest==6.2.5
-    # via pytest-cov
-regex==2021.10.23
-    # via black
-toml==0.10.2
-    # via pytest
-tomli==1.2.1
-    # via
-    #   black
-    #   coverage
-typing-extensions==3.10.0.2
-    # via black