lint.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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 chat assets need a rebuild…"
  65. - echo "Please see public/assets/chat/README.md for build instructions."
  66. - cp public/assets/chat/chat.js tmp/chat.js
  67. - yarn install --cwd public/assets/chat
  68. - (cd public/assets/chat && npx gulp build)
  69. - echo "First characters of public/assets/chat/chat.js"
  70. - head -c300 public/assets/chat/chat.js; echo # Insert newline after chat content
  71. - echo "First characters of tmp/chat.js"
  72. - head -c300 tmp/chat.js; echo # Insert newline after chat content
  73. - cmp public/assets/chat/chat.js tmp/chat.js
  74. 'lint: coffee & css':
  75. extends:
  76. - .template_lint
  77. cache: !reference [.cache, read_only_nodejs]
  78. before_script:
  79. - !reference [.scripts, yarn_install]
  80. script:
  81. - echo "Coffeelint check…"
  82. - coffeelint --rules ./.coffeelint/rules/* app/
  83. - echo "Stylelint check…"
  84. - yarn lint:css
  85. 'lint: js':
  86. extends:
  87. - .template_lint
  88. cache:
  89. - !reference [.cache, read_only_nodejs]
  90. - !reference [.cache, read_write_eslint]
  91. before_script:
  92. - cp yarn.lock tmp/yarn.lock # Save original state of yarn.lock
  93. - !reference [.scripts, yarn_install]
  94. script:
  95. - echo "Checking if yarn.lock is up-to-date"
  96. - "if ! diff yarn.lock tmp/yarn.lock; then echo 'Error: yarn.lock is not up-to-date'; exit 1; fi"
  97. - echo "ESLint check…"
  98. - yarn lint
  99. # Must be a separate job because it may fail and is only executed manually.
  100. 'lint: orphaned ruby gems':
  101. extends:
  102. - .template_lint_rails
  103. allow_failure: true
  104. rules:
  105. - when: manual
  106. script:
  107. - bundle exec rake zammad:ci:bundle:orphaned 5
  108. 'update CI variables':
  109. extends:
  110. - .template_lint_rails
  111. rules:
  112. - if: $CI_PIPELINE_SOURCE != "schedule"
  113. when: manual
  114. allow_failure: true
  115. - when: on_success
  116. script:
  117. - bundle exec rake zammad:ci:update_ci_variables
  118. 'lint: secret_detection':
  119. extends: .template_lint
  120. image:
  121. name: "zricethezav/gitleaks:latest"
  122. entrypoint: [""]
  123. cache: []
  124. before_script: []
  125. script:
  126. # Since we clone with GIT_DEPTH=1, the commit has the entire codebase as a diff.
  127. # Otherwise, we'd need to use --no-git to scan the entire codebase, but that is slower
  128. # as it also traverses directories not scanned by git.
  129. - gitleaks detect --report-path secret-detection-report.json --verbose
  130. after_script: []
  131. # # GitLab can show this in a security widget, but that seems to be useless at this point (offers empty file for download).
  132. # artifacts:
  133. # reports:
  134. # secret_detection: secret-detection-report.json