forked from mendersoftware/integration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci-full-integration-generator.yml
More file actions
78 lines (72 loc) · 2.73 KB
/
Copy path.gitlab-ci-full-integration-generator.yml
File metadata and controls
78 lines (72 loc) · 2.73 KB
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
#
# Ideally we would have used "parallel: $CI_JOBS_IN_PARALLEL_INTEGRATION" to run the tests, but it
# is not supported to use an integer variable here. Do a blame on these lines for more context.
#
# To workaround this issue, we set up "Dynamic child pipelines" to control how many CI jobs to
# run tests (iow how many child pipelines) to launch. For an overview of this features see:
# https://docs.gitlab.com/ee/ci/pipelines/downstream_pipelines.html#dynamic-child-pipelines
#
# And how is really implemented? Using envsubst to set the values of CI_NODE_TOTAL and CI_NODE_INDEX
# in the template pipeline file for each desired child job, and concatenate all of them.
#
test:integration:generator:
image: debian:12-slim
stage: test-gen
script:
- apt-get update && apt-get install -y gettext-base
- |
- touch gitlab-ci-full-integration-jobs.yml
- CI_NODE_TOTAL=$CI_JOBS_IN_PARALLEL_INTEGRATION
- export CI_NODE_TOTAL CI_NODE_INDEX
- for CI_NODE_INDEX in $(seq $CI_JOBS_IN_PARALLEL_INTEGRATION); do
- envsubst '$CI_NODE_TOTAL,$CI_NODE_INDEX' < .gitlab-ci-full-integration-template.yml >> gitlab-ci-full-integration-jobs.yml
- done
artifacts:
paths:
- gitlab-ci-full-integration-jobs.yml
test:integration:trigger:
stage: test
variables:
PARENT_CI_PIPELINE_ID: $CI_PIPELINE_ID
PARENT_CI_PIPELINE_SOURCE: $CI_PIPELINE_SOURCE
trigger:
strategy: depend
include:
- artifact: gitlab-ci-full-integration-jobs.yml
job: test:integration:generator
forward:
pipeline_variables: true
# GitHub status reports: send a separate one for the integration tests
# pending after the generation is completed, success/failure after the child pipeline finishes
test:integration:start:
extends: .github_status_template
variables:
GITHUB_STATUS_API_JSON_F: '{"state": "%s", "context": "ci/gitlab/integ-tests", "target_url": "%s", "description": "%s"}'
stage: test
needs:
- job: test:integration:generator
artifacts: false
script:
- send_status pending "Pipeline running on Gitlab"
test:integration:success:
extends: .github_status_template
variables:
GITHUB_STATUS_API_JSON_F: '{"state": "%s", "context": "ci/gitlab/integ-tests", "target_url": "%s", "description": "%s"}'
stage: test
needs:
- job: test:integration:trigger
artifacts: false
when: on_success
script:
- send_status success "Pipeline passed on Gitlab"
test:integration:failure:
extends: .github_status_template
variables:
GITHUB_STATUS_API_JSON_F: '{"state": "%s", "context": "ci/gitlab/integ-tests", "target_url": "%s", "description": "%s"}'
stage: test
needs:
- job: test:integration:trigger
artifacts: false
when: on_failure
script:
- send_status failure "Pipeline failed on Gitlab"