-
-
Notifications
You must be signed in to change notification settings - Fork 5
91 lines (75 loc) · 3.08 KB
/
lint.yml
File metadata and controls
91 lines (75 loc) · 3.08 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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@5a80476d175edf56cb205b08bc58986fa99d1725 # v3.2.0
with:
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@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'