forked from netdata/go.d.plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (137 loc) · 4.55 KB
/
reviewdog.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
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
---
# Runs various ReviewDog based checks against PR with suggested changes to improve quality
name: Review
on:
pull_request:
concurrency:
group: review-${{ github.ref }}
cancel-in-progress: true
jobs:
prep-review:
name: Prepare Review Jobs
runs-on: ubuntu-latest
outputs:
actionlint: ${{ steps.actionlint.outputs.run }}
golangci-lint: ${{ steps.golangci-lint.outputs.run }}
hadolint: ${{ steps.hadolint.outputs.run }}
shellcheck: ${{ steps.shellcheck.outputs.run }}
yamllint: ${{ steps.yamllint.outputs.run }}
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check files for actionlint
id: actionlint
run: |
if git diff --name-only origin/${{ github.base_ref }} HEAD -- | grep -Eq '\.github/workflows/.*' ; then
echo "run=true" >> $GITHUB_OUTPUT
echo 'GitHub Actions workflows have changed, need to run actionlint.'
else
echo "run=false" >> $GITHUB_OUTPUT
fi
- name: Check files for golangci-lint
id: golangci-lint
run: |
if git diff --name-only origin/${{ github.base_ref }} HEAD -- | grep -Eq '.*\.go' ; then
echo "run=true" >> $GITHUB_OUTPUT
echo 'Go code has changed, need to run golangci-lint.'
else
echo "run=false" >> $GITHUB_OUTPUT
fi
- name: Check files for hadolint
id: hadolint
run: |
if git diff --name-only origin/${{ github.base_ref }} HEAD -- | grep -Eq '.*Dockerfile.*' ; then
echo "run=true" >> $GITHUB_OUTPUT
echo 'Dockerfiles have changed, need to run Hadolint.'
else
echo "run=false" >> $GITHUB_OUTPUT
fi
- name: Check files for shellcheck
id: shellcheck
run: |
if git diff --name-only origin/${{ github.base_ref }} HEAD -- | grep -Eq '.*\.sh.*' ; then
echo "run=true" >> $GITHUB_OUTPUT
echo 'Shell scripts have changed, need to run shellcheck.'
else
echo "run=false" >> $GITHUB_OUTPUT
fi
- name: Check files for yamllint
id: yamllint
run: |
if git diff --name-only origin/${{ github.base_ref }} HEAD -- | grep -Eq '.*\.ya?ml|config/.*\.conf' ; then
echo "run=true" >> $GITHUB_OUTPUT
echo 'YAML files have changed, need to run yamllint.'
else
echo "run=false" >> $GITHUB_OUTPUT
fi
actionlint:
name: actionlint
needs: prep-review
if: needs.prep-review.outputs.actionlint == 'true'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
- name: Run actionlint
uses: reviewdog/action-actionlint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
golangci-lint:
name: golangci-lint
needs: prep-review
if: needs.prep-review.outputs.golangci-lint == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run golangci-lint
uses: reviewdog/action-golangci-lint@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
golangci_lint_flags: '--timeout=10m'
hadolint:
name: hadolint
needs: prep-review
if: needs.prep-review.outputs.hadolint == 'true'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
- name: Run hadolint
uses: reviewdog/action-hadolint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
shellcheck:
name: shellcheck
needs: prep-review
if: needs.prep-review.outputs.shellcheck == 'true'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
- name: Run shellcheck
uses: reviewdog/action-shellcheck@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
path: "."
pattern: "*.sh*"
exclude: "./.git/*"
yamllint:
name: yamllint
needs: prep-review
if: needs.prep-review.outputs.yamllint == 'true'
runs-on: ubuntu-latest
steps:
- name: Git clone repository
uses: actions/checkout@v4
- name: Run yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check