pre.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. - echo "Checking .po file syntax..."
  50. - for FILE in i18n/*.pot i18n/*.po; do echo "Checking $FILE"; msgfmt -o /dev/null -c $FILE; done
  51. - echo "Checking .pot catalog consistency..."
  52. - bundle exec rails generate translation_catalog --check
  53. - echo "Brakeman security check..."
  54. - bundle exec brakeman -o /dev/stdout -o tmp/brakeman-report.html
  55. - echo "bundler-audit security check..."
  56. - gem install bundler-audit
  57. - bundle-audit update
  58. - bundle-audit --ignore CVE-2015-9284
  59. - echo "Rails zeitwerk:check autoloader check..."
  60. - bundle exec rails zeitwerk:check
  61. - echo "Checking if auto-generated GraphQL API is up-to-date..."
  62. - echo "Use the command 'yarn run generate-graphql-api' to re-generate it, if required."
  63. - yarn install
  64. - cp app/frontend/apps/mobile/graphql/api.ts app/frontend/apps/mobile/graphql/api.ts.bak
  65. - yarn run generate-graphql-api
  66. - cmp -s app/frontend/apps/mobile/graphql/api.ts app/frontend/apps/mobile/graphql/api.ts.bak
  67. "lint: ruby, js & css":
  68. <<: *template_pre
  69. script:
  70. - echo "Coffeelint check..."
  71. - coffeelint --rules ./.coffeelint/rules/* app/
  72. - echo "Stylelint check..."
  73. - yarn install
  74. - yarn lint:css
  75. - echo "Rubocop check..."
  76. - echo -e "\\e[0Ksection_start:`date +%s`:bundle_install[collapsed=true]\\r\\e[0Kbundle install"
  77. - bundle config set --local frozen 'true'
  78. - bundle config set --local path 'vendor'
  79. - bundle install -j $(nproc)
  80. - echo -e "\\e[0Ksection_end:`date +%s`:bundle_install\\r\\e[0K"
  81. - bundle exec rubocop --parallel
  82. # Must be a separate job because it may fail and is only executed for develop.
  83. "lint: orphaned ruby gems":
  84. <<: *template_pre_rails
  85. allow_failure: true
  86. rules:
  87. - if: $CI_MERGE_REQUEST_ID
  88. when: never
  89. - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
  90. when: always
  91. - when: manual
  92. script:
  93. - bundle exec rake zammad:ci:bundle:orphaned 5
  94. # Executed on a dedicated runner.
  95. "push to github":
  96. <<: *template_pre
  97. tags:
  98. - deploy
  99. before_script:
  100. - '' # no RVM present in deploy ENV
  101. script:
  102. - git fetch --unshallow
  103. - script/build/sync_repo.sh git@github.com:zammad/zammad.git
  104. global_refresh_envs:
  105. extends:
  106. - .tags_docker
  107. - .services_postgresql
  108. stage: pre
  109. interruptible: true
  110. # ensure that only one Job runs in the whole project (branches etc.)
  111. resource_group: global_refresh_envs
  112. # allow download via the web UI to restore ENVs in case global cache got deleted (see: `.gitlab-ci.yml`)
  113. artifacts:
  114. expire_in: 1 week
  115. paths:
  116. - fresh.env
  117. rules:
  118. - if: $CI_MERGE_REQUEST_ID
  119. when: never
  120. - if: '$CI_COMMIT_BRANCH =~ /^private/'
  121. when: manual
  122. allow_failure: true
  123. - when: on_success
  124. script:
  125. - bundle exec rake zammad:ci:refresh_envs