review.yml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. ---
  2. # Runs various ReviewDog based checks against PR with suggested changes to improve quality
  3. name: Review
  4. on:
  5. pull_request:
  6. types: [opened, reopened, labeled, synchronize]
  7. env:
  8. DISABLE_TELEMETRY: 1
  9. concurrency:
  10. group: review-${{ github.ref }}
  11. cancel-in-progress: true
  12. jobs:
  13. prep-review:
  14. name: Prepare Review Jobs
  15. runs-on: ubuntu-latest
  16. outputs:
  17. actionlint: ${{ steps.actionlint.outputs.run }}
  18. eslint: ${{ steps.eslint.outputs.run }}
  19. hadolint: ${{ steps.hadolint.outputs.run }}
  20. shellcheck: ${{ steps.shellcheck.outputs.run }}
  21. yamllint: ${{ steps.yamllint.outputs.run }}
  22. steps:
  23. - name: Clone repository
  24. uses: actions/checkout@v3
  25. with:
  26. submodules: recursive
  27. fetch-depth: 0
  28. - name: Check files for actionlint
  29. id: actionlint
  30. run: |
  31. if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/actionlint') }}" = "true" ]; then
  32. echo "run=true" >> "${GITHUB_OUTPUT}"
  33. elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '\.github/workflows/.*' ; then
  34. echo "run=true" >> "${GITHUB_OUTPUT}"
  35. echo 'GitHub Actions workflows have changed, need to run actionlint.'
  36. else
  37. echo "run=false" >> "${GITHUB_OUTPUT}"
  38. fi
  39. - name: Check files for eslint
  40. id: eslint
  41. run: |
  42. if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/eslint') }}" = "true" ]; then
  43. echo "run=true" >> "${GITHUB_OUTPUT}"
  44. elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -v "web/gui/dashboard" | grep -Eq '.*\.js|node\.d\.plugin\.in' ; then
  45. echo "run=true" >> "${GITHUB_OUTPUT}"
  46. echo 'JS files have changed, need to run ESLint.'
  47. else
  48. echo "run=false" >> "${GITHUB_OUTPUT}"
  49. fi
  50. - name: Check files for hadolint
  51. id: hadolint
  52. run: |
  53. if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/hadolint') }}" = "true" ]; then
  54. echo "run=true" >> "${GITHUB_OUTPUT}"
  55. elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*Dockerfile.*' ; then
  56. echo "run=true" >> "${GITHUB_OUTPUT}"
  57. echo 'Dockerfiles have changed, need to run Hadolint.'
  58. else
  59. echo "run=false" >> "${GITHUB_OUTPUT}"
  60. fi
  61. - name: Check files for shellcheck
  62. id: shellcheck
  63. run: |
  64. if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/shellcheck') }}" = "true" ]; then
  65. echo "run=true" >> "${GITHUB_OUTPUT}"
  66. elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.sh.*' ; then
  67. echo "run=true" >> "${GITHUB_OUTPUT}"
  68. echo 'Shell scripts have changed, need to run shellcheck.'
  69. else
  70. echo "run=false" >> "${GITHUB_OUTPUT}"
  71. fi
  72. - name: Check files for yamllint
  73. id: yamllint
  74. run: |
  75. if [ "${{ contains(github.event.pull_request.labels.*.name, 'run-ci/yamllint') }}" = "true" ]; then
  76. echo "run=true" >> "${GITHUB_OUTPUT}"
  77. elif git diff --name-only origin/${{ github.base_ref }} HEAD | grep -Eq '.*\.ya?ml|python\.d/.*\.conf' ; then
  78. echo "run=true" >> "${GITHUB_OUTPUT}"
  79. echo 'YAML files have changed, need to run yamllint.'
  80. else
  81. echo "run=false" >> "${GITHUB_OUTPUT}"
  82. fi
  83. actionlint:
  84. name: actionlint
  85. needs: prep-review
  86. if: needs.prep-review.outputs.actionlint == 'true'
  87. runs-on: ubuntu-latest
  88. steps:
  89. - name: Git clone repository
  90. uses: actions/checkout@v3
  91. with:
  92. submodules: recursive
  93. fetch-depth: 0
  94. - name: Run actionlint
  95. uses: reviewdog/action-actionlint@v1
  96. with:
  97. github_token: ${{ secrets.GITHUB_TOKEN }}
  98. reporter: github-pr-check
  99. eslint:
  100. name: eslint
  101. needs: prep-review
  102. if: needs.prep-review.outputs.eslint == 'true'
  103. runs-on: ubuntu-latest
  104. steps:
  105. - name: Git clone repository
  106. uses: actions/checkout@v3
  107. with:
  108. submodules: recursive
  109. fetch-depth: 0
  110. - name: Install eslint
  111. run: npm install eslint -D
  112. - name: Run eslint
  113. uses: reviewdog/action-eslint@v1
  114. with:
  115. github_token: ${{ secrets.GITHUB_TOKEN }}
  116. reporter: github-pr-check
  117. eslint_flags: '.'
  118. hadolint:
  119. name: hadolint
  120. needs: prep-review
  121. if: needs.prep-review.outputs.hadolint == 'true'
  122. runs-on: ubuntu-latest
  123. steps:
  124. - name: Git clone repository
  125. uses: actions/checkout@v3
  126. with:
  127. fetch-depth: 0
  128. - name: Run hadolint
  129. uses: reviewdog/action-hadolint@v1
  130. with:
  131. github_token: ${{ secrets.GITHUB_TOKEN }}
  132. reporter: github-pr-check
  133. shellcheck:
  134. name: shellcheck
  135. needs: prep-review
  136. if: needs.prep-review.outputs.shellcheck == 'true'
  137. runs-on: ubuntu-latest
  138. steps:
  139. - name: Git clone repository
  140. uses: actions/checkout@v3
  141. with:
  142. submodules: recursive
  143. fetch-depth: 0
  144. - name: Run shellcheck
  145. uses: reviewdog/action-shellcheck@v1
  146. with:
  147. github_token: ${{ secrets.GITHUB_TOKEN }}
  148. reporter: github-pr-check
  149. path: "."
  150. pattern: "*.sh*"
  151. exclude: "./.git/*"
  152. yamllint:
  153. name: yamllint
  154. needs: prep-review
  155. if: needs.prep-review.outputs.yamllint == 'true'
  156. runs-on: ubuntu-latest
  157. steps:
  158. - name: Git clone repository
  159. uses: actions/checkout@v3
  160. with:
  161. submodules: recursive
  162. fetch-depth: 0
  163. - name: Run yamllint
  164. uses: reviewdog/action-yamllint@v1
  165. with:
  166. github_token: ${{ secrets.GITHUB_TOKEN }}
  167. reporter: github-pr-check