official completion #23
This file contains hidden or 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: Lint & Type Check | |
| on: | |
| push: | |
| branches: [ 'main' ] | |
| pull_request: | |
| branches: [ '*' ] | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| name: Run Linters | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('backend/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run pylint | |
| id: pylint | |
| run: | | |
| echo "Running pylint..." | |
| if pylint app > pylint-output.txt 2>&1; then | |
| echo "PYLINT_PASSED=true" >> $GITHUB_ENV | |
| echo "No pylint errors found!" | |
| else | |
| echo "PYLINT_PASSED=false" >> $GITHUB_ENV | |
| echo "Pylint found issues!" | |
| fi | |
| cat pylint-output.txt | |
| continue-on-error: true | |
| - name: Run ruff | |
| id: ruff | |
| run: | | |
| echo "Running ruff check..." | |
| if ruff check app > ruff-output.txt 2>&1; then | |
| echo "RUFF_PASSED=true" >> $GITHUB_ENV | |
| echo "No ruff errors found!" | |
| else | |
| echo "RUFF_PASSED=false" >> $GITHUB_ENV | |
| echo "Ruff found issues" | |
| fi | |
| cat ruff-output.txt | |
| continue-on-error: true | |
| - name: Run mypy | |
| id: mypy | |
| run: | | |
| echo "Running mypy..." | |
| cd app | |
| if mypy . > ../mypy-output.txt 2>&1; then | |
| echo "MYPY_PASSED=true" >> $GITHUB_ENV | |
| echo "No mypy errors found" | |
| else | |
| echo "MYPY_PASSED=false" >> $GITHUB_ENV | |
| echo "Mypy found issues" | |
| fi | |
| cat ../mypy-output.txt | |
| continue-on-error: true | |
| - name: Create Lint Summary | |
| id: create_summary | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| { | |
| echo '## Lint & Type Check Results' | |
| echo '' | |
| # Pylint Status | |
| if [[ "${{ env.PYLINT_PASSED }}" == "true" ]]; then | |
| echo '### Pylint: **Passed**' | |
| echo 'No pylint issues found.' | |
| else | |
| echo '### Pylint: **Issues Found**' | |
| echo '<details><summary>View pylint output</summary>' | |
| echo '' | |
| echo '```' | |
| head -100 pylint-output.txt | |
| echo '```' | |
| echo '</details>' | |
| fi | |
| echo '' | |
| # Ruff Status | |
| if [[ "${{ env.RUFF_PASSED }}" == "true" ]]; then | |
| echo '### Ruff: **Passed**' | |
| echo 'No ruff issues found.' | |
| else | |
| echo '### Ruff: **Issues Found**' | |
| echo '<details><summary>View ruff output</summary>' | |
| echo '' | |
| echo '```' | |
| head -100 ruff-output.txt | |
| echo '```' | |
| echo '</details>' | |
| fi | |
| echo '' | |
| # Mypy Status | |
| if [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then | |
| echo '### Mypy: **Passed**' | |
| echo 'No mypy issues found.' | |
| else | |
| echo '### Mypy: **Issues Found**' | |
| echo '<details><summary>View mypy output</summary>' | |
| echo '' | |
| echo '```' | |
| head -100 mypy-output.txt | |
| echo '```' | |
| echo '</details>' | |
| fi | |
| echo '' | |
| # Overall Summary | |
| if [[ "${{ env.PYLINT_PASSED }}" == "true" ]] && [[ "${{ env.RUFF_PASSED }}" == "true" ]] && [[ "${{ env.MYPY_PASSED }}" == "true" ]]; then | |
| echo '---' | |
| echo '### All checks passed!' | |
| else | |
| echo '---' | |
| echo '### Review the issues above and consider fixing them.' | |
| fi | |
| echo '' | |
| echo '<!-- lint-check-comment-marker -->' | |
| } > ../lint-report.md | |
| - name: Post PR Comment | |
| if: github.event_name == 'pull_request' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body-path: lint-report.md | |
| comment-marker: lint-check-comment-marker |