pre.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. # Workaround to enable usage of mixed SSH and Docker GitLab CI runners
  2. .template_pre: &template_pre
  3. stage: pre
  4. interruptible: true
  5. extends:
  6. - .tags_docker
  7. - .rules_singletest
  8. - .artifacts_error
  9. before_script:
  10. - source /etc/profile.d/rvm.sh # ensure RVM is loaded
  11. .template_pre_rails: &template_pre_rails
  12. stage: pre
  13. interruptible: true
  14. extends:
  15. - .tags_docker
  16. - .rules_singletest
  17. - .services_postgresql
  18. - .artifacts_error
  19. before_script:
  20. - source /etc/profile.d/rvm.sh # ensure RVM is loaded
  21. - echo -e "\\e[0Ksection_start:`date +%s`:bundle_install[collapsed=true]\\r\\e[0Kbundle install"
  22. - bundle config set --local frozen 'true'
  23. - bundle config set --local path 'vendor'
  24. - bundle install -j $(nproc)
  25. - echo -e "\\e[0Ksection_end:`date +%s`:bundle_install\\r\\e[0K"
  26. - bundle exec ruby .gitlab/configure_environment.rb
  27. - source .gitlab/environment.env
  28. - echo -e "\\e[0Ksection_start:`date +%s`:zammad_db_init[collapsed=true]\\r\\e[0Kbundle exec rake zammad:db:init"
  29. - bundle exec rake zammad:db:init
  30. - echo -e "\\e[0Ksection_end:`date +%s`:zammad_db_init\\r\\e[0K"
  31. # Must be a separate job because it uses a custom image.
  32. 'lint: shellcheck':
  33. <<: *template_pre
  34. image: koalaman/shellcheck-alpine:stable
  35. before_script:
  36. - echo "Disable default before_script."
  37. script:
  38. - shellcheck -S warning $(find . -name "*.sh" -o -name "functions" | grep -v "/vendor/")
  39. after_script:
  40. - echo "Disable default before_script."
  41. 'lint: i18n, rails & security':
  42. <<: *template_pre_rails
  43. artifacts:
  44. expire_in: 1 week
  45. paths:
  46. - tmp/brakeman-report.html
  47. when: on_failure
  48. script:
  49. - yarn install
  50. - echo "Checking .po file syntax..."
  51. - for FILE in i18n/*.pot i18n/*.po; do echo "Checking $FILE"; msgfmt -o /dev/null -c $FILE; done
  52. - echo "Checking .pot catalog consistency..."
  53. - bundle exec rails generate translation_catalog --check
  54. - echo "Brakeman security check..."
  55. - bundle exec brakeman -o /dev/stdout -o tmp/brakeman-report.html
  56. - echo "bundler-audit security check..."
  57. - gem install bundler-audit
  58. - bundle-audit update
  59. - bundle-audit --ignore CVE-2015-9284
  60. - echo "Rails zeitwerk:check autoloader check..."
  61. - bundle exec rails zeitwerk:check
  62. - .gitlab/check_graphql_api_consistency.sh
  63. 'lint: ruby, js & css':
  64. <<: *template_pre
  65. script:
  66. - echo "Coffeelint check..."
  67. - coffeelint --rules ./.coffeelint/rules/* app/
  68. - echo "Stylelint check..."
  69. - yarn install
  70. - yarn lint:css
  71. - echo "ESLint check..."
  72. - yarn install --cwd .storybook
  73. - yarn lint
  74. - echo "Storybook build..."
  75. - yarn storybook:build
  76. - echo "Rubocop check..."
  77. - echo -e "\\e[0Ksection_start:`date +%s`:bundle_install[collapsed=true]\\r\\e[0Kbundle install"
  78. - bundle config set --local frozen 'true'
  79. - bundle config set --local path 'vendor'
  80. - bundle install -j $(nproc)
  81. - echo -e "\\e[0Ksection_end:`date +%s`:bundle_install\\r\\e[0K"
  82. - bundle exec rubocop --parallel
  83. # Must be a separate job because it may fail and is only executed for develop.
  84. 'lint: orphaned ruby gems':
  85. <<: *template_pre_rails
  86. allow_failure: true
  87. rules:
  88. - if: $CI_MERGE_REQUEST_ID
  89. when: never
  90. - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  91. when: always
  92. - when: manual
  93. script:
  94. - bundle exec rake zammad:ci:bundle:orphaned 5
  95. # Executed on a dedicated runner.
  96. 'push to github':
  97. <<: *template_pre
  98. tags:
  99. - deploy
  100. before_script:
  101. - '' # no RVM present in deploy ENV
  102. script:
  103. - git fetch --unshallow
  104. - script/build/sync_repo.sh git@github.com:zammad/zammad.git
  105. global_refresh_envs:
  106. extends:
  107. - .tags_docker
  108. - .services_postgresql
  109. stage: pre
  110. interruptible: true
  111. # ensure that only one Job runs in the whole project (branches etc.)
  112. resource_group: global_refresh_envs
  113. # allow download via the web UI to restore ENVs in case global cache got deleted (see: `.gitlab-ci.yml`)
  114. artifacts:
  115. expire_in: 1 week
  116. paths:
  117. - fresh.env
  118. rules:
  119. - if: $CI_MERGE_REQUEST_ID
  120. when: never
  121. - if: '$CI_COMMIT_BRANCH =~ /^private/'
  122. when: manual
  123. allow_failure: true
  124. - when: on_success
  125. script:
  126. - bundle exec rake zammad:ci:refresh_envs