-
Notifications
You must be signed in to change notification settings - Fork 5
55 lines (45 loc) · 1.74 KB
/
python_checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Python Checks
on: [pull_request]
permissions:
issues: write
pull-requests: write
jobs:
type_and_docstring_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Fetch base and head branches
run: |
git fetch --no-tags --depth=1 origin +${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}
git fetch --no-tags --depth=1 origin +${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mypy pydocstyle requests types-requests
- name: Find modified Python files
run: |
echo "MODIFIED_FILES<<EOF" >> $GITHUB_ENV
git diff --name-only refs/remotes/origin/${{ github.base_ref }} $(git merge-base refs/remotes/origin/${{ github.base_ref }} refs/remotes/origin/${{ github.head_ref }}) | grep '\.py$' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run mypy and save output
if: env.MODIFIED_FILES != ''
run: |
echo "${{ env.MODIFIED_FILES }}" | xargs mypy --ignore-missing-imports --disallow-untyped-defs > mypy_output.txt 2>&1
continue-on-error: true
- name: Run pydocstyle and save output
if: env.MODIFIED_FILES != ''
run: |
echo "${{ env.MODIFIED_FILES }}" | xargs pydocstyle > pydocstyle_output.txt 2>&1
continue-on-error: true
- name: Set script permissions
run: chmod +x .github/scripts/comment_pr.py
- name: Comment PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python .github/scripts/comment_pr.py