forked from opencadc/deployments
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (88 loc) · 3.59 KB
/
Copy pathpre-commit.yml
File metadata and controls
111 lines (88 loc) · 3.59 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: pre-commit
on:
pull_request:
push:
branches:
- main
permissions:
contents: read
pull-requests: write
jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- name: Helm tool installer
uses: Azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
- name: Helm Dependency Updates
run: |
for chart in helm/applications/*/; do helm dependency update "$chart" 2>/dev/null || true; done
- name: Setup Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: 'stable'
- name: Install Helm Docs
run: go install github.com/norwoodj/helm-docs/cmd/helm-docs@latest
- name: Set up uv
uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7
with:
version: "latest"
python-version: 3.13
enable-cache: "auto"
cache-dependency-glob: |
pyproject.toml
uv.lock
restore-cache: "true"
save-cache: "true"
- name: Cache pre-commit
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-
- name: Run pre-commit checks
id: precommit
continue-on-error: true
run: uv run pre-commit run -a
- name: Share pre-commit guidance
if: ${{ github.event_name == 'pull_request' && (steps.precommit.outcome == 'failure') }}
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
message: |
### ⚠️ Pre-commit Checks Failed
${{ steps.precommit.outcome == 'failure' && '- Run `uv run pre-commit run -a` locally to reproduce the issues.' || '' }}
To reproduce the issues locally, run the following commands:
```bash
git clone ${{ github.event.pull_request.head.repo.clone_url }}
git checkout -b ${{ github.event.pull_request.head.ref }}
uv run pre-commit run -a
```
To always run pre-commit checks locally before pushing changes, simple run the following command once:
```bash
uv run pre-commit install
```
#### Errors
```
$(git diff --minimal)
```
#### Resources
- [Documentation to install `uv`](https://docs.astral.sh/uv/getting-started/installation/)
- [Conventional Commits](https://www.conventionalcommits.org/) standards for writing commit messages
- [Commitizen](https://commitizen-tools.github.io/commitizen/) CLI tool for writing commit messages
- [pre-commit](https://pre-commit.com/) CLI tool for running pre-commit hooks
- name: Celebrate spotless PR
if: ${{ github.event_name == 'pull_request' && steps.precommit.outcome == 'success' }}
uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2
with:
message: |
### ✅ All pre-commit checks passed
Thanks for keeping the repo tidy! ✨
- name: Fail if checks failed
if: ${{ steps.precommit.outcome == 'failure' }}
run: |
git diff --exit-code
- name: Cleanup pre-commit cache
run: |
uv run pre-commit gc