summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
Diffstat (limited to '.github')
-rwxr-xr-x.github/mypy-github-formatter38
-rw-r--r--.github/workflows/build.yml54
2 files changed, 86 insertions, 6 deletions
diff --git a/.github/mypy-github-formatter b/.github/mypy-github-formatter
new file mode 100755
index 00000000..dfc8309a
--- /dev/null
+++ b/.github/mypy-github-formatter
@@ -0,0 +1,38 @@
+#!/usr/bin/env python
+
+# A helper script that you can pipe the output of `mypy --output json` into Github actions workflow message commands
+# so they show up in the code review panel and job output as warnings.
+# (https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#about-workflow-commands)
+
+import json
+
+had_errors = False
+
+while True:
+ try:
+ line = input()
+ except EOFError:
+ break
+ if len(line) == 0:
+ break
+
+ had_errors = True
+
+ line = json.loads(line)
+
+ # Format the line into a github command that will show up in the code review panel,
+ # as well as a note about the file and line so that it's clear to readers of the build log where
+ # errors were found
+
+ # Could use line["severity"] to change the message type, but for now we just
+ # want to use these to flag potential commit issues rather than reject commits outright.
+ github_out = '::warning title=Type Checking,file={file},line={line},col={column}::{message} [{code}]'.format(**line)
+ hint = line["hint"]
+ if hint is not None:
+ github_out += f". HINT: {hint}"
+
+ print(github_out)
+ print('(in {file}:{line})'.format(**line))
+
+if not had_errors:
+ print("No type errors found!") \ No newline at end of file
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 7ecbffbb..de20b889 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -66,9 +66,16 @@ jobs:
- shell: bash
run: |
bin/build-linux
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist
@@ -131,9 +138,16 @@ jobs:
python -m pip install pyinstaller
echo "${{ env.pythonLocation }}\bin" >> $GITHUB_PATH
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist
@@ -286,9 +300,16 @@ jobs:
run: |
SET BUILD32="1"
bin\build-geos-win.cmd
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist
@@ -345,9 +366,16 @@ jobs:
shell: cmd
run: |
bin\build-geos-win.cmd
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist
@@ -404,9 +432,16 @@ jobs:
pip install pyinstaller
echo "${{ env.pythonLocation }}/bin" >> $GITHUB_PATH
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist
@@ -466,9 +501,16 @@ jobs:
pip install pyinstaller
echo "${{ env.pythonLocation }}/bin" >> $GITHUB_PATH
- - shell: bash
+ - name: Tests
+ shell: bash
run: |
pytest
+ - name: Mypy Type Checking
+ shell: bash
+ run: |
+ python -m pip install mypy
+ python -m mypy --output json | python .github/mypy-github-formatter
+ continue-on-error: true
- shell: bash
run: |
make dist