review.yml 5.0 KB

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