-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (66 loc) · 2.3 KB
/
check-format.yaml
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
name: "check formatting"
on:
push:
branches: "**"
tags-ignore: ["**"]
pull_request:
permissions:
contents: "read"
checks: "write"
issues: "write"
pull-requests: "write"
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- name: "setup"
uses: "KyoriPowered/.github/.github/actions/setup-python-env@trunk"
- name: "setup / install reviewdog"
uses: "reviewdog/action-setup@v1.3.0"
with:
reviewdog_version: "latest"
- name: "setup / install deps"
id: "install"
run: "poetry install"
- name: "run ruff / apply format"
env:
REVIEWDOG_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
REPORTER="github-pr-review"
else
REPORTER="github-check"
fi
poetry run ruff format --diff | reviewdog -reporter=$REPORTER -f=diff -f.diff.strip=0 -name=ruff-format -filter-mode=nofilter -fail-level=error
- name: "run ruff / check"
if: "${{ always() && steps.install.conclusion == 'success' }}"
run: "poetry run ruff check --output-format=github"
pre-commit:
runs-on: ubuntu-latest
steps:
- name: "setup"
uses: "KyoriPowered/.github/.github/actions/setup-python-env@trunk"
- name: "setup / install reviewdog"
uses: "reviewdog/action-setup@v1.3.0"
with:
reviewdog_version: "latest"
- name: "setup / install deps"
id: "install"
run: "poetry install"
- uses: "actions/cache@v4.2.0"
with:
path: "~/.cache/pre-commit"
key: "pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }}"
- name: "check pre-commit"
run: "poetry run pre-commit run --show-diff-on-failure --all-files --color=always"
- name: "publish results"
if: "${{ always() && steps.install.conclusion == 'success' }}"
env:
REVIEWDOG_GITHUB_API_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
REPORTER="github-pr-review"
else
REPORTER="github-check"
fi
git diff | reviewdog -reporter=$REPORTER -f=diff -f.diff.strip=1 -name=pre-commit -filter-mode=nofilter -fail-level=error