lint.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Workaround to enable usage of mixed SSH and Docker GitLab CI runners
  2. .template_lint:
  3. stage: lint
  4. extends:
  5. - .job_rules_default
  6. .template_lint_rails:
  7. extends:
  8. - .template_lint
  9. services:
  10. - !reference [.services, postgresql]
  11. before_script:
  12. - !reference [.scripts, source_rvm]
  13. - !reference [.scripts, bundle_install]
  14. - !reference [.scripts, configure_environment]
  15. - !reference [.scripts, zammad_db_init]
  16. variables:
  17. ZAMMAD_SAFE_MODE: 1
  18. # Must be a separate job because it uses a custom image.
  19. 'lint: shellcheck':
  20. extends:
  21. - .template_lint
  22. image: koalaman/shellcheck-alpine:stable
  23. cache: []
  24. before_script: []
  25. script:
  26. - shellcheck -S warning $(find . -name "*.sh" -o -name "functions" | egrep -v "/vendor|node_modules/")
  27. after_script: []
  28. 'lint: i18n & rails':
  29. extends:
  30. - .template_lint_rails
  31. cache: !reference [.cache, read_only_full]
  32. artifacts:
  33. expire_in: 1 week
  34. paths:
  35. - tmp/brakeman-report.html
  36. when: on_failure
  37. script:
  38. - !reference [.scripts, yarn_install]
  39. - echo "Checking .po file syntax…"
  40. - for FILE in i18n/*.pot i18n/*.po; do echo "Checking $FILE"; msgfmt -o /dev/null -c $FILE; done
  41. - echo "Checking .pot catalog consistency…"
  42. - bundle exec rails generate zammad:translation_catalog --check
  43. - echo "Checking consistency of Settings types file…"
  44. - bundle exec rails generate zammad:setting_types --check
  45. - echo "Brakeman security check…"
  46. - bundle exec brakeman -o /dev/stdout -o tmp/brakeman-report.html
  47. - echo "Rails zeitwerk:check autoloader check…"
  48. - bundle exec rails zeitwerk:check
  49. - .gitlab/check_graphql_api_consistency.sh
  50. 'lint: ruby & security':
  51. extends:
  52. - .template_lint
  53. before_script:
  54. - !reference [.scripts, source_rvm]
  55. - !reference [.scripts, bundle_install]
  56. script:
  57. - echo "Rubocop check…"
  58. - bundle exec .rubocop/validate_todos.rb
  59. - bundle exec rubocop --parallel
  60. - echo "bundler-audit security check…"
  61. - gem install bundler-audit
  62. - bundle-audit update
  63. - bundle-audit
  64. - echo "Checking if yard can generate documentation…"
  65. - bundle exec yard --no-output --no-progress
  66. - echo "Checking if chat assets need a rebuild…"
  67. - echo "Please see public/assets/chat/README.md for build instructions."
  68. - cp public/assets/chat/chat.js tmp/chat.js
  69. - yarn install --cwd public/assets/chat
  70. - (cd public/assets/chat && npx gulp build)
  71. - echo "First characters of public/assets/chat/chat.js"
  72. - head -c300 public/assets/chat/chat.js; echo # Insert newline after chat content
  73. - echo "First characters of tmp/chat.js"
  74. - head -c300 tmp/chat.js; echo # Insert newline after chat content
  75. - cmp public/assets/chat/chat.js tmp/chat.js
  76. - echo "Verify that vendored gems are not world writable"
  77. - GEM_FILES=$(find vendor/ -name "*.rb" -perm -002)
  78. - if [[ ! -z "$GEM_FILES" ]]; then echo $GEM_FILES; exit 1; fi # Raise error if files were found.
  79. - echo "Finally, ensure cleanup.sh passes…"
  80. - script/build/cleanup.sh
  81. 'lint: coffee & css':
  82. extends:
  83. - .template_lint
  84. cache: !reference [.cache, read_only_nodejs]
  85. before_script:
  86. - !reference [.scripts, yarn_install]
  87. script:
  88. - echo "Coffeelint check…"
  89. - coffeelint --rules ./.coffeelint/rules/* app/
  90. - echo "Stylelint check…"
  91. - yarn lint:css
  92. 'lint: js':
  93. extends:
  94. - .template_lint
  95. cache:
  96. - !reference [.cache, read_only_nodejs]
  97. - !reference [.cache, read_write_eslint]
  98. before_script:
  99. - cp yarn.lock tmp/yarn.lock # Save original state of yarn.lock
  100. - !reference [.scripts, yarn_install]
  101. script:
  102. - echo "Checking if yarn.lock is up-to-date"
  103. - "if ! diff yarn.lock tmp/yarn.lock; then echo 'Error: yarn.lock is not up-to-date'; exit 1; fi"
  104. - echo "ESLint check…"
  105. - yarn lint
  106. # Must be a separate job because it may fail and is only executed manually.
  107. 'lint: orphaned ruby gems':
  108. extends:
  109. - .template_lint_rails
  110. allow_failure: true
  111. rules:
  112. - when: manual
  113. script:
  114. - bundle exec rake zammad:ci:bundle:orphaned 5
  115. 'update CI variables':
  116. extends:
  117. - .template_lint_rails
  118. rules:
  119. - if: $CI_PIPELINE_SOURCE != "schedule"
  120. when: manual
  121. allow_failure: true
  122. - when: on_success
  123. script:
  124. - bundle exec rake zammad:ci:update_ci_variables
  125. 'lint: secret_detection':
  126. extends: .template_lint
  127. image:
  128. name: "zricethezav/gitleaks:latest"
  129. entrypoint: [""]
  130. cache: []
  131. before_script: []
  132. script:
  133. # Since we clone with GIT_DEPTH=1, the commit has the entire codebase as a diff.
  134. # Otherwise, we'd need to use --no-git to scan the entire codebase, but that is slower
  135. # as it also traverses directories not scanned by git.
  136. - gitleaks detect --report-path secret-detection-report.json --verbose
  137. after_script: []
  138. # # GitLab can show this in a security widget, but that seems to be useless at this point (offers empty file for download).
  139. # artifacts:
  140. # reports:
  141. # secret_detection: secret-detection-report.json