-
Notifications
You must be signed in to change notification settings - Fork 28
149 lines (130 loc) · 5.61 KB
/
Copy pathformatting.yml
File metadata and controls
149 lines (130 loc) · 5.61 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Post Commit Checks and Pushes
on:
push:
branches:
- "**"
pull_request:
branches:
- "**"
workflow_dispatch:
permissions:
contents: write # Needed for push
pull-requests: write # Needed for PR comments
env:
MAIN_REPO: "NSPC911/rovr"
jobs:
format_and_push_changes:
runs-on: ubuntu-slim
if: github.event_name != 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
with:
activate-environment: true
- name: Install dependencies
run: uv sync --all-groups --no-group build
- name: Run ty
run: uv run ty check
- name: Run ruff format if needed (main repo)
if: github.repository == env.MAIN_REPO && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
run: |
uv run ruff format .
uv run ruff check --fix --unsafe-fixes
- name: Commit and push changes if needed (main repo)
if: github.repository == env.MAIN_REPO && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
run: |
git config --global user.name "${GITHUB_ACTOR_NAME:-NSPBot911}"
git config --global user.email "${GITHUB_ACTOR_EMAIL:-176916861+NSPBot911@users.noreply.github.com}"
git add .
if ! git diff --cached --quiet; then
git commit -m "style: auto-format with ruff" -m "[skip ci]" -m "${{ GITHUB.ACTOR }} forgot to run ruff format" -m "skip-checks: true"
git push
fi
env:
GITHUB_ACTOR_NAME: ${{ vars.BOT_NAME || 'NSPBot911' }}
GITHUB_ACTOR_EMAIL: ${{ vars.BOT_EMAIL || '176916861+NSPBot911@users.noreply.github.com' }}
- name: Run docs scripts
run: |
uv run poe gen-schema
uv run poe gen-keys
uv run poe typed
# need to do ruff because type hints use scuffed configs
uv run ruff format .
uv run ruff check --fix --unsafe-fixes
- name: Commit and push changes if needed (main repo)
if: github.repository == env.MAIN_REPO && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false)
run: |
git config --global user.name "${GITHUB_ACTOR_NAME:-NSPBot911}"
git config --global user.email "${GITHUB_ACTOR_EMAIL:-176916861+NSPBot911@users.noreply.github.com}"
git add .
if ! git diff --cached --quiet; then
git commit -m "docs: generate things" -m "[skip ci]" -m "${{ GITHUB.ACTOR }} forgot to run some scripts" -m "skip-checks: true"
git push
fi
env:
GITHUB_ACTOR_NAME: ${{ vars.BOT_NAME || 'NSPBot911' }}
GITHUB_ACTOR_EMAIL: ${{ vars.BOT_EMAIL || '176916861+NSPBot911@users.noreply.github.com' }}
- name: Alert if fail
if: failure()
uses: sarisia/actions-status-discord@v1.16.0
with:
webhook: ${{ secrets.LOG_HOOK }}
title: Post Commit checks failed!
status: failure
description: "Check the workflow [details](https://github.com/NSPC911/rovr/actions/runs/${{ github.run_id }}) for more info."
avatar_url: "https://avatars.githubusercontent.com/u/176916861?v=4"
username: "NSPBot911"
nodetail: true
notimestamp: true
noprefix: true
format_and_alert:
runs-on: ubuntu-slim
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup uv
uses: astral-sh/setup-uv@cec208311dfd045dd5311c1add060b2062131d57
with:
activate-environment: true
- name: Install dependencies
run: uv sync --all-groups --no-group build
- name: Run ty
id: ty_check
run: uv run ty check || (echo "::error::Type checking failed! Please fix type errors before committing." && exit 1)
- name: Alert if ty fails
if: failure() && steps.ty_check.outcome == 'failure'
uses: sarisia/actions-status-discord@v1.16.0
with:
webhook: ${{ secrets.LOG_HOOK }}
title: rovr ty check failed!
status: failure
description: |
<:wazowski:1308074746772062248> Type checking failed on branch `${{ github.ref_name }}` (due to `${{ github.event_name }}`)
Check the workflow [details](https://github.com/NSPC911/rovr/actions/runs/${{ github.run_id }}) for more info.
avatar_url: "https://avatars.githubusercontent.com/u/176916861?v=4"
username: "NSPBot911"
nodetail: true
notimestamp: true
noprefix: true
# If on a fork, only check and fail if there are issues (no fixes/commits)
- name: Run ruff
id: ruff_check
uses: astral-sh/ruff-action@v4.0.0
- name: Alert if ruff fails
if: failure() && steps.ruff_check.outcome == 'failure'
uses: sarisia/actions-status-discord@v1.16.0
with:
webhook: ${{ secrets.LOG_HOOK }}
title: rovr ruff check failed!
status: failure
description: |
<:wazowski:1308074746772062248> Code formatting/linting failed on branch `${{ github.ref_name }}` (due to `${{ github.event_name }}`)
Check the workflow [details](https://github.com/NSPC911/rovr/actions/runs/${{ github.run_id }}) for more info.
avatar_url: "https://avatars.githubusercontent.com/u/176916861?v=4"
username: "NSPBot911"
nodetail: true
notimestamp: true
noprefix: true