files for reproduction #13052
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: Black formatting | |
| on: [pull_request, workflow_dispatch] | |
| jobs: | |
| black_format: | |
| runs-on: ubuntu-latest | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| strategy: | |
| matrix: | |
| python-version: ['3.10'] | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Check full Python version | |
| run: | | |
| python --version | |
| python_version=$(python --version 2>&1 | cut -d' ' -f2) | |
| echo "Python version: $python_version" | |
| echo "version=$python_version" >> $GITHUB_ENV | |
| - name: Restore Python environment cache | |
| id: restore-env | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: .venv-${{ env.version }} | |
| key: ${{ runner.os }}-venv-${{ env.version }}-${{ hashFiles('devtools/dev-requirements.txt', 'requirements.txt') }} | |
| - name: Set up virtual environment if not restored from cache | |
| if: steps.restore-env.outputs.cache-hit != 'true' | |
| run: | | |
| gh cache list | |
| python -m venv .venv-${{ env.version }} | |
| source .venv-${{ env.version }}/bin/activate | |
| python -m pip install --upgrade pip | |
| pip install -r devtools/dev-requirements.txt | |
| - name: Check files using the black formatter | |
| run: | | |
| source .venv-${{ env.version }}/bin/activate | |
| black --version | |
| black --check desc/ tests/ || black_return_code=$? | |
| echo "BLACK_RETURN_CODE=$black_return_code" >> $GITHUB_ENV | |
| black desc/ tests/ | |
| - name: Annotate diff changes using reviewdog | |
| uses: reviewdog/[email protected] | |
| with: | |
| tool_name: blackfmt | |
| - name: Fail if not formatted | |
| run: | | |
| exit ${{ env.BLACK_RETURN_CODE }} |