@cryptotaxi247 / netdata-1 / commits / b50547097

Restructure review check CI to properly show jobs as skipped. (#11553)

* Restructure review check CI to properly show jobs as skipped. This will make it easier to understand what ran versus what did not. * Add linting for GitHub Actions workflows. * Formatting fixes. * Fix grep expressions in reviewdog CI checks.

Austin S. Hemmelgarn committed Oct 12, 2021 at 10:38 UTC b5054709798232f8b6de64f8fe64e7344834ca82
1 file changed +86 -28
.github/workflows/review.yml
+86 -28
@@ -4,14 +4,90 @@ name: Review
4 on:
5 pull_request: null
6 env:
7 - run_eslint: 0
8 - run_hadolint: 0
9 - run_shellcheck: 0
10 - run_yamllint: 0
7 DO_NOT_TRACK: 1
8 jobs:
9 + prep-review:
10 + name: Prepare Review Jobs
11 + runs-on: ubuntu-latest
12 + outputs:
13 + actionlint: ${{ steps.actionlint.outputs.run }}
14 + eslint: ${{ steps.eslint.outputs.run }}
15 + hadolint: ${{ steps.hadolint.outputs.run }}
16 + shellcheck: ${{ steps.shellcheck.outputs.run }}
17 + yamllint: ${{ steps.yamllint.outputs.run }}
18 + steps:
19 + - name: Clone repository
20 + uses: actions/checkout@v2
21 + with:
22 + submodules: recursive
23 + fetch-depth: 0
24 + - name: Check files for actionlint
25 + id: actionlint
26 + run: |
27 + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '\.github/workflows/.*' ; then
28 + echo '::set-output name=run::true'
29 + echo 'GitHub Actions workflows have changed, need to run actionlint.'
30 + else
31 + echo '::set-output name=run::false'
32 + fi
33 + - name: Check files for eslint
34 + id: eslint
35 + run: |
36 + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -v "web/gui/dashboard" | grep -Eq '.*\.js|node\.d\.plugin\.in' ; then
37 + echo '::set-output name=run::true'
38 + echo 'JS files have changed, need to run ESLint.'
39 + else
40 + echo '::set-output name=run::false'
41 + fi
42 + - name: Check files for hadolint
43 + id: hadolint
44 + run: |
45 + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*Dockerfile.*' ; then
46 + echo '::set-output name=run::true'
47 + echo 'Dockerfiles have changed, need to run Hadolint.'
48 + else
49 + echo '::set-output name=run::false'
50 + fi
51 + - name: Check files for shellcheck
52 + id: shellcheck
53 + run: |
54 + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.sh.*' ; then
55 + echo '::set-output name=run::true'
56 + echo 'Shell scripts have changed, need to run shellcheck.'
57 + else
58 + echo '::set-output name=run::false'
59 + fi
60 + - name: Check files for yamllint
61 + id: yamllint
62 + run: |
63 + if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.ya?ml|python\.d/.*\.conf' ; then
64 + echo '::set-output name=run::true'
65 + echo 'YAML files have changed, need to run yamllint.'
66 + else
67 + echo '::set-output name=run::false'
68 + fi
69 +
70 + actionlint:
71 + name: actionlint
72 + needs: prep-review
73 + if: needs.prep-review.outputs.actionlint == 'true'
74 + runs-on: ubuntu-latest
75 + steps:
76 + - name: Git clone repository
77 + uses: actions/checkout@v2
78 + with:
79 + submodules: recursive
80 + fetch-depth: 0
81 + - name: Run actionlint
82 + uses: reviewdog/action-actionlint@v1
83 + with:
84 + github_token: ${{ secrets.GITHUB_TOKEN }}
85 + reporter: github-pr-check
86 +
87 eslint:
88 name: eslint
89 + needs: prep-review
90 + if: needs.prep-review.outputs.eslint == 'true'
91 runs-on: ubuntu-latest
92 steps:
93 - name: Git clone repository
@@ -19,13 +95,7 @@ jobs:
95 with:
96 submodules: recursive
97 fetch-depth: 0
22 - - name: Check files
23 - run: |
24 - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -v "web/gui/dashboard" | grep -Eq '*\.js|node\.d\.plugin\.in' ; then
25 - echo 'run_eslint=1' >> $GITHUB_ENV
26 - fi
98 - name: Run eslint
28 - if: env.run_eslint == 1
99 uses: reviewdog/action-eslint@v1
100 with:
101 github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -34,19 +104,15 @@ jobs:
104
105 hadolint:
106 name: hadolint
107 + needs: prep-review
108 + if: needs.prep-review.outputs.hadolint == 'true'
109 runs-on: ubuntu-latest
110 steps:
111 - name: Git clone repository
112 uses: actions/checkout@v2
113 with:
114 fetch-depth: 0
43 - - name: Check files
44 - run: |
45 - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '*Dockerfile*' ; then
46 - echo 'run_hadolint=1' >> $GITHUB_ENV
47 - fi
115 - name: Run hadolint
49 - if: env.run_hadolint == 1
116 uses: reviewdog/action-hadolint@v1
117 with:
118 github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -54,6 +120,8 @@ jobs:
120
121 shellcheck:
122 name: shellcheck
123 + needs: prep-review
124 + if: needs.prep-review.outputs.shellcheck == 'true'
125 runs-on: ubuntu-latest
126 steps:
127 - name: Git clone repository
@@ -61,13 +129,7 @@ jobs:
129 with:
130 submodules: recursive
131 fetch-depth: 0
64 - - name: Check files
65 - run: |
66 - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '*\.sh.*' ; then
67 - echo 'run_shellcheck=1' >> $GITHUB_ENV
68 - fi
132 - name: Run shellcheck
70 - if: env.run_shellcheck == 1
133 uses: reviewdog/action-shellcheck@v1
134 with:
135 github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -78,6 +140,8 @@ jobs:
140
141 yamllint:
142 name: yamllint
143 + needs: prep-review
144 + if: needs.prep-review.outputs.yamllint == 'true'
145 runs-on: ubuntu-latest
146 steps:
147 - name: Git clone repository
@@ -85,13 +149,7 @@ jobs:
149 with:
150 submodules: recursive
151 fetch-depth: 0
88 - - name: Check files
89 - run: |
90 - if git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '*\.ya?ml|python\.d/.*\.conf' ; then
91 - echo 'run_yamllint=1' >> $GITHUB_ENV
92 - fi
152 - name: Run yamllint
94 - if: env.run_yamllint == 1
153 uses: reviewdog/action-yamllint@v1
154 with:
155 github_token: ${{ secrets.GITHUB_TOKEN }}