generated from reviewdog/action-template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
95 lines (92 loc) · 3.21 KB
/
test.yml
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
name: Test
on:
push:
branches:
- master
pull_request:
jobs:
test-empty:
name: runner / black-format (empty)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata/emptyfolder
- name: Check if code is left untouched (not formatted)
run: |
changed_files=$(git diff --name-only -- testdata/emptyfolder/ | wc -l)
if [[ ${changed_files} -eq 0 ]]; then
echo "No changes detected!"
else
echo "Changes detected!"
exit 1
fi
test-check:
name: runner / black-format (github-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-check
level: info
workdir: ./testdata/
- name: Check if code is left untouched (not formatted)
run: |
changed_files=$(git diff --name-only -- testdata/ | wc -l)
if [[ ${changed_files} -eq 0 ]]; then
echo "No changes detected!"
else
echo "Changes detected!"
exit 1
fi
- name: Check black would format the expected files
run: |
expected_files=(num_guess.py num_guess.ipynb subfolder/queen_problem.py subfolder/queen_problem.ipynb)
checked_files=(${{ env.BLACK_CHECK_FILE_PATHS }})
# Check whether the expected files are checked
for file in ${expected_files[@]}; do
if ! [[ " ${checked_files[*]} " == *"${file}"* ]]; then
echo "Black forgot to check file ${file}!"
exit 1
fi
done
# Check whether black checks files that should not be checked
for file in ${checked_files[@]}; do
trimmed_file="${file#${GITHUB_WORKSPACE}/testdata/}"
if ! [[ " ${expected_files[*]} " == *"${trimmed_file}"* ]]; then
echo "Unexpected file ${trimmed_file} got checked!"
exit 1
fi
done
echo "Black checked the expected files: [${expected_files[@]}] successfully!"
test-pr-check:
if: github.event_name == 'pull_request'
name: runner / black-format (github-pr-check)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-check
level: warning
workdir: ./testdata/
test-pr-review:
if: github.event_name == 'pull_request'
name: runner / black-format (github-pr-review)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: ./
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
level: error
reviewdog_flags: -filter-mode=file -fail-on-error
workdir: ./testdata/