-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53f859e
commit 6ebdf80
Showing
2 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: Check Type Completeness | ||
on: | ||
pull_request: | ||
paths: | ||
- aiorem/** | ||
- pyproject.toml | ||
- .github/workflows/type_completeness_test.yml | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test-type-completeness: | ||
name: test-type-completeness | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# https://github.com/actions/checkout/issues/329#issuecomment-674881489 | ||
- run: git fetch --depth=1 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: 3.11 | ||
- name: Install Pyright | ||
run: | | ||
python -W ignore -m pip install pyright | ||
- name: Get PR Completeness | ||
# Must run before base completeness, as base completeness will check out the base branch | ||
# and we can't go back to the PR branch after that in case the PR is coming from a fork | ||
run: | | ||
pip install . -U | ||
pyright --verifytypes aiorem --ignoreexternal --outputjson > pr.json || true | ||
pyright --verifytypes aiorem --ignoreexternal > pr.readable || true | ||
- name: Get Base Completeness | ||
run: | | ||
git checkout ${{ github.base_ref }} | ||
pip install . -U | ||
pyright --verifytypes aiorem --ignoreexternal --outputjson > base.json || true | ||
pyright --verifytypes aiorem --ignoreexternal > base.readable || true | ||
- name: Compare Completeness | ||
uses: jannekem/run-python-script-action@v1 | ||
with: | ||
script: | | ||
import json | ||
import os | ||
from pathlib import Path | ||
base = float( | ||
json.load(open("base.json", "rb"))["typeCompleteness"]["completenessScore"] | ||
) | ||
pr = float( | ||
json.load(open("pr.json", "rb"))["typeCompleteness"]["completenessScore"] | ||
) | ||
base_text = f"This PR changes type completeness from {round(base, 3)} to {round(pr, 3)}." | ||
if base == 0: | ||
text = f"Something is broken in the workflow. Reported type completeness is 0. 💥" | ||
set_summary(text) | ||
print("pyright report for base branch:") | ||
print(Path("base.readable").read_text(encoding="utf-8")) | ||
print("\n\npyright report for PR branch:") | ||
print(Path("pr.readable").read_text(encoding="utf-8")) | ||
error(text) | ||
exit(1) | ||
if pr < base: | ||
text = f"{base_text} ❌" | ||
set_summary(text) | ||
print(Path("pr.readable").read_text(encoding="utf-8")) | ||
error(text) | ||
exit(1) | ||
elif pr > base: | ||
text = f"{base_text} ✨" | ||
set_summary(text) | ||
if pr < 1: | ||
print(Path("pr.readable").read_text(encoding="utf-8")) | ||
print(text) | ||
else: | ||
text = f"{base_text} ✅" | ||
set_summary(text) | ||
print(Path("pr.readable").read_text(encoding="utf-8")) | ||
print(text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters