Migrate relevant documentation to repository from docs
repository.
#11
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
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 |