Repository: blobfile/blobfile (language: python)

Issue:
Add black check
https://github.com/marketplace/actions/python-black-check


Discussion / hints:
Ideally it might run testing/run.py which should always use the correct
version of black and also pyright

On Thu, Jan 7, 2021 at 6:27 PM Ben Mann <notifications@github.com> wrote:

> https://github.com/marketplace/actions/python-black-check
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/christopher-hesse/blobfile/issues/151>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ALSBG2PCM6PEFU5PZTZBVQ3SYZURZANCNFSM4VZ2NACQ>
> .
>

i'm a little wary of the deps necessary to get their test runners doing that, so going to start with the dumbest thing first
even pyright requires npm to install
oh looks like you can use a dockerfile, nvm

Fix patch:
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
new file mode 100644
index 0000000..1b22823
--- /dev/null
+++ b/.github/workflows/main.yml
@@ -0,0 +1,14 @@
+on: [push]
+
+jobs:
+  test_job:
+    runs-on: ubuntu-latest
+    name: Run tests
+    steps:
+      # To use this repository's private action,
+      # you must check out the repository
+      - name: Checkout
+        uses: actions/checkout@v2
+      - name: Run tests step
+        uses: ./testing # Uses an action in the testing directory
+        id: test
\ No newline at end of file


Test patch:
diff --git a/testing/action.yml b/testing/action.yml
new file mode 100644
index 0000000..6b484f0
--- /dev/null
+++ b/testing/action.yml
@@ -0,0 +1,9 @@
+# https://docs.github.com/en/free-pro-team@latest/actions/creating-actions/creating-a-docker-container-action#testing-out-your-action-in-a-workflow
+name: 'Run tests'
+description: 'Run tests'
+runs:
+  using: 'docker'
+  image: 'Dockerfile'
+  
+  # TODO: add other tests
+  entrypoint: '/github/workspace/testing/run-static.py'
\ No newline at end of file
diff --git a/env.yaml b/testing/env.yaml
similarity index 94%
rename from env.yaml
rename to testing/env.yaml
index 68c311c..52e9881 100644
--- a/env.yaml
+++ b/testing/env.yaml
@@ -1,19 +1,19 @@
-channels:
-  - conda-forge
-
-dependencies:
-  - python=3.7.3
-  - av=6.2.0
-  - pip
-  - pip:
-    - pycryptodomex==3.8.2
-    - urllib3==1.25.3
-    - pytest==4.4.1
-    - pylint==2.3.1
-    - tensorflow==1.13.1
-    - google-cloud-storage==1.16.1
-    - imageio==2.5.0
-    - filelock==3.0.12
-    - imageio-ffmpeg==0.3.0
-    - xmltodict==0.12.0
-    - boto3==1.15.18
+channels:
+  - conda-forge
+
+dependencies:
+  - python=3.7.3
+  - av=6.2.0
+  - pip
+  - pip:
+    - pycryptodomex==3.8.2
+    - urllib3==1.25.3
+    - pytest==4.4.1
+    - pylint==2.3.1
+    - tensorflow==1.13.1
+    - google-cloud-storage==1.16.1
+    - imageio==2.5.0
+    - filelock==3.0.12
+    - imageio-ffmpeg==0.3.0
+    - xmltodict==0.12.0
+    - boto3==1.15.18
diff --git a/testing/run-static.py b/testing/run-static.py
old mode 100644
new mode 100755
index e920143..a7f3671
--- a/testing/run-static.py
+++ b/testing/run-static.py
@@ -1,38 +1,39 @@
-import subprocess as sp
-import shlex
-import os
-import shutil
-
-
-def shell(cmd):
-    print("SHELL: " + " ".join(shlex.quote(p) for p in cmd))
-    sp.run(cmd, check=True)
-
-
-def format_files(dirpath, extensions, command):
-    for root, dirs, filenames in os.walk(dirpath):
-        for filename in filenames:
-            _name, ext = os.path.splitext(filename)
-            if ext in extensions:
-                sp.run(command + [os.path.join(root, filename)], check=True)
-        if "third-party" in dirs:
-            dirs.remove("third-party")
-
-
-def main():
-    print("formatting python files")
-    shell(
-        [
-            "black",
-            "--target-version=py37",
-            r"--exclude=(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|third-party|typings)",
-            ".",
-        ]
-    )
-
-    print("checking python files")
-    shell([shutil.which("pyright"), "--project", "."])
-
-
-if __name__ == "__main__":
-    main()
+#!/root/miniconda3/envs/env/bin/python
+import subprocess as sp
+import shlex
+import os
+import shutil
+
+
+def shell(cmd):
+    print("SHELL: " + " ".join(shlex.quote(p) for p in cmd))
+    sp.run(cmd, check=True)
+
+
+def format_files(dirpath, extensions, command):
+    for root, dirs, filenames in os.walk(dirpath):
+        for filename in filenames:
+            _name, ext = os.path.splitext(filename)
+            if ext in extensions:
+                sp.run(command + [os.path.join(root, filename)], check=True)
+        if "third-party" in dirs:
+            dirs.remove("third-party")
+
+
+def main():
+    print("formatting python files")
+    shell(
+        [
+            "black",
+            "--target-version=py37",
+            r"--exclude=(\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|_build|buck-out|build|dist|third-party|typings)",
+            ".",
+        ]
+    )
+
+    print("checking python files")
+    shell([shutil.which("pyright"), "--project", "."])
+
+
+if __name__ == "__main__":
+    main()
diff --git a/testing/run.py b/testing/run.py
index bbe9b10..73d4a0d 100644
--- a/testing/run.py
+++ b/testing/run.py
@@ -1,8 +1,7 @@
-import os
-import time
-import os
 import argparse
+import os
 import subprocess as sp
+import time
 
 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
 
@@ -29,7 +28,7 @@ def run_tests_docker(name, rest, env):
     assert os.path.exists("testing/Dockerfile")
 
     sp.run(
-        ["docker", "build", "--file", "testing/Dockerfile", "--tag", name, "."],
+        ["docker", "build", "--file", "testing/Dockerfile", "--tag", name, "testing"],
         check=True,
     )
     google_credentials_path = os.environ.get(