summaryrefslogtreecommitdiff
path: root/.gitlab/ci/setup.gitlab-ci.yml
blob: 1aeccfcb212799a25d932f268c476e1499e54785 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# Insurance in case a gem needed by one of our releases gets yanked from
# rubygems.org in the future.
cache gems:
  extends:
    - .default-retry
    - .rails-cache
    - .default-before_script
    - .setup:rules:cache-gems
  stage: test
  needs: ["setup-test-env"]
  variables:
    BUNDLE_INSTALL_FLAGS: --with=production --with=development --with=test --jobs=2 --path=vendor --retry=3 --quiet
    SETUP_DB: "false"
  script:
    - bundle package --all --all-platforms
  artifacts:
    paths:
      - vendor/cache
    expire_in: 31d

.minimal-job:
  extends:
    - .default-retry
  needs: []

dont-interrupt-me:
  extends: .setup:rules:dont-interrupt-me
  stage: sync
  image: ${GITLAB_DEPENDENCY_PROXY}alpine:edge
  interruptible: false
  variables:
    GIT_STRATEGY: none
  script:
    - echo "This jobs makes sure this pipeline won't be interrupted! See https://docs.gitlab.com/ee/ci/yaml/#interruptible."

gitlab_git_test:
  extends:
    - .minimal-job
    - .setup:rules:gitlab_git_test
  stage: test
  script:
    - spec/support/prepare-gitlab-git-test-for-commit --check-for-changes

no-ee-check:
  extends:
    - .minimal-job
    - .setup:rules:no-ee-check
  stage: test
  script:
    - scripts/no-dir-check ee

no-jh-check:
  extends:
    - .minimal-job
    - .setup:rules:no-jh-check
  stage: test
  script:
    - scripts/no-dir-check jh

verify-tests-yml:
  extends:
    - .setup:rules:verify-tests-yml
  image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7-alpine3.13
  stage: test
  needs: []
  script:
    - source scripts/utils.sh
    - install_tff_gem
    - scripts/verify-tff-mapping

generate-frontend-fixtures-mapping:
  extends:
    - .setup:rules:generate-frontend-fixtures-mapping
    - .use-pg12
    - .rails-cache
  needs: ["setup-test-env"]
  stage: prepare
  before_script:
    - !reference [.default-before_script, before_script]
    - source ./scripts/rspec_helpers.sh
    - run_timed_command "scripts/gitaly-test-spawn"
  script:
    - generate_frontend_fixtures_mapping
  artifacts:
    expire_in: 7d
    paths:
      - ${FRONTEND_FIXTURES_MAPPING_PATH}

.detect-test-base:
  image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7
  needs: []
  stage: prepare
  script:
    - source ./scripts/utils.sh
    - source ./scripts/rspec_helpers.sh
    - install_gitlab_gem
    - install_tff_gem
    - retrieve_tests_mapping
    - retrieve_frontend_fixtures_mapping
    - |
      if [ -n "$CI_MERGE_REQUEST_IID" ]; then
        tooling/bin/find_changes ${CHANGES_FILE};
        tooling/bin/find_tests ${CHANGES_FILE} ${MATCHED_TESTS_FILE};
        tooling/bin/find_changes ${CHANGES_FILE} ${MATCHED_TESTS_FILE} ${FRONTEND_FIXTURES_MAPPING_PATH};
        echo "Changed files: $(cat $CHANGES_FILE)";
        echo "Related rspec tests: $(cat $MATCHED_TESTS_FILE)";
      fi
  artifacts:
    expire_in: 7d
    paths:
      - ${CHANGES_FILE}
      - ${MATCHED_TESTS_FILE}
      - ${FRONTEND_FIXTURES_MAPPING_PATH}

detect-tests:
  extends:
    - .detect-test-base
    - .rails:rules:detect-tests
  variables:
    RSPEC_TESTS_MAPPING_ENABLED: "true"
    CHANGES_FILE: tmp/changed_files.txt
    MATCHED_TESTS_FILE: tmp/matching_tests.txt

detect-tests as-if-foss:
  extends:
    - .detect-test-base
    - .rails:rules:detect-tests
    - .as-if-foss
  variables:
    CHANGES_FILE: tmp/changed_foss_files.txt
    MATCHED_TESTS_FILE: tmp/matching_foss_tests.txt
  before_script:
    - '[ "$FOSS_ONLY" = "1" ] && rm -rf ee/ qa/spec/ee/ qa/qa/specs/features/ee/ qa/qa/ee/ qa/qa/ee.rb'

detect-previous-failed-tests:
  extends:
    - .detect-test-base
    - .rails:rules:detect-previous-failed-tests
  variables:
    PREVIOUS_FAILED_TESTS_DIR: tmp/previous_failed_tests/
    RSPEC_PG_REGEX: /rspec .+ pg12( .+)?/
    RSPEC_EE_PG_REGEX: /rspec-ee .+ pg12( .+)?/
  script:
    - source ./scripts/utils.sh
    - source ./scripts/rspec_helpers.sh
    - retrieve_previous_failed_tests ${PREVIOUS_FAILED_TESTS_DIR} "${RSPEC_PG_REGEX}" "${RSPEC_EE_PG_REGEX}"
  artifacts:
    expire_in: 7d
    paths:
      - ${PREVIOUS_FAILED_TESTS_DIR}

add-jh-folder:
  extends: .setup:rules:add-jh-folder
  image: ${GITLAB_DEPENDENCY_PROXY}ruby:2.7
  stage: prepare
  before_script:
    - source ./scripts/utils.sh
    - install_gitlab_gem
  script:
    - JH_BRANCH=$(./scripts/setup/find-jh-branch.rb)
    - 'echo "JH_BRANCH: ${JH_BRANCH}"'
    - curl --location -o "jh-folder.tar.gz" "https://gitlab.com/gitlab-org/gitlab-jh/gitlab/-/archive/${JH_BRANCH}/gitlab-${JH_BRANCH}.tar.gz?path=jh"
    - tar -xf "jh-folder.tar.gz"
    - mv "gitlab-${JH_BRANCH}-jh/jh/" ./
    - cp Gemfile.lock jh/
    - ls -l jh/
  artifacts:
    expire_in: 2d
    paths:
      - jh/