release: 26.5.0 #1198
Workflow file for this run
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: Run linting and formatting | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| - release/** | |
| env: | |
| # workaround: secrets cannot be directly referenced in `if` | |
| # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-secrets | |
| SECRET_ACCESS: ${{toJSON(secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY != null)}} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| lint: | |
| timeout-minutes: 5 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - # get a non-default github token so that any changes are verified by CI | |
| if: env.SECRET_ACCESS == 'true' | |
| uses: getsentry/action-github-app-token@d4b5da6c5e37703f8c3b3e43abb5705b46e159cc # v3.0.0 | |
| id: token | |
| with: | |
| app_id: ${{ vars.SENTRY_INTERNAL_APP_ID }} | |
| private_key: ${{ secrets.SENTRY_INTERNAL_APP_PRIVATE_KEY }} | |
| - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
| - name: Get changed files | |
| id: changes | |
| uses: dorny/paths-filter@0bc4621a3135347011ad047f9ecf449bf72ce2bd # v3.0.0 | |
| with: | |
| list-files: json | |
| filters: | | |
| all: | |
| - added|modified: '**/*' | |
| - uses: astral-sh/setup-uv@884ad927a57e558e7a70b92f2bccf9198a4be546 # v6 | |
| with: | |
| version: '0.8.2' | |
| # we just cache the venv-dir directly in action-setup-venv | |
| enable-cache: false | |
| - uses: getsentry/action-setup-venv@3a832a9604b3e1a4202ae559248f26867b467cc7 # v2.1.1 | |
| with: | |
| python-version: 3.13.5 | |
| cache-dependency-path: uv.lock | |
| install-cmd: uv sync --frozen --only-dev --active | |
| - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: cache-epoch-1|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml', 'uv.lock') }} | |
| - name: Install Rust Toolchain | |
| run: rustup toolchain install stable --profile minimal --component rustfmt --component clippy --no-self-update | |
| - name: Cache rust cargo artifacts | |
| uses: swatinem/rust-cache@42dc69e1aa15d09112580998cf2ef0119e2e91ae # v2 | |
| - name: Install protoc | |
| uses: arduino/setup-protoc@c65c819552d16ad3c9b72d9dfd5ba5237b9c906b # v3 | |
| with: | |
| repo-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Lint | |
| run: cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings | |
| - name: Format | |
| run: cargo fmt | |
| - name: Install pre-commit | |
| run: pre-commit install-hooks | |
| - name: Run pre-commit | |
| run: | | |
| jq '.[]' --raw-output <<< '${{steps.changes.outputs.all_files}}' | | |
| xargs pre-commit run --files | |
| - name: Apply any formatting fixed files | |
| # note: this runs "always" or else it's skipped when pre-commit fails | |
| if: env.SECRET_ACCESS == 'true' && startsWith(github.ref, 'refs/pull') && always() | |
| uses: getsentry/action-github-commit@31f6706ca1a7b9ad6d22c1b07bf3a92eabb05632 # v2.0.0 | |
| with: | |
| github-token: ${{ steps.token.outputs.token }} | |
| message: ':hammer_and_wrench: apply pre-commit fixes' |