lint.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. # Currently unused, skip to save time...
  100. # - echo "Histoire test build..."
  101. # - yarn story:build
  102. # Must be a separate job because it may fail and is only executed manually.
  103. 'lint: orphaned ruby gems':
  104. extends:
  105. - .template_lint_rails
  106. allow_failure: true
  107. rules:
  108. - when: manual
  109. script:
  110. - bundle exec rake zammad:ci:bundle:orphaned 5
  111. 'refresh global envs':
  112. services:
  113. - !reference [.services, postgresql]
  114. - !reference [.services, redis]
  115. stage: lint
  116. # ensure that only one Job runs in the whole project (branches etc.)
  117. resource_group: global_refresh_envs
  118. # allow download via the web UI to restore ENVs in case global cache got deleted (see: `.gitlab-ci.yml`)
  119. artifacts:
  120. expire_in: 1 week
  121. paths:
  122. - fresh.env
  123. rules:
  124. - if: $CI_COMMIT_REF_NAME =~ /^private/
  125. when: manual
  126. allow_failure: true
  127. - when: on_success
  128. script:
  129. - bundle exec rake zammad:ci:refresh_envs
  130. 'lint: secret_detection':
  131. extends: .template_lint
  132. image:
  133. name: "zricethezav/gitleaks:latest"
  134. entrypoint: [""]
  135. cache: []
  136. before_script: []
  137. script:
  138. # Since we clone with GIT_DEPTH=1, the commit has the entire codebase as a diff.
  139. # Otherwise, we'd need to use --no-git to scan the entire codebase, but that is slower
  140. # as it also traverses directories not scanned by git.
  141. - gitleaks detect --report-path secret-detection-report.json --verbose
  142. after_script: []
  143. # # GitLab can show this in a security widget, but that seems to be useless at this point (offers empty file for download).
  144. # artifacts:
  145. # reports:
  146. # secret_detection: secret-detection-report.json