forked from ScaleComputing/HyperCoreAnsibleCollection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
163 lines (152 loc) · 4.83 KB
/
.gitlab-ci.yml
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
---
image: python:3.8.12-slim-buster # TODO gitlab registry
# TODO reuse Makefile - "make sanity", and docker dind.
variables:
# SC_HOST: https://10.5.11.30 # provide value in gitlab CI/CD settings
SC_USERNAME: admin
# SC_PASSWORD: # provide value in gitlab CI/CD settings
stages:
- test
- test-child-pipeline-generator
- test-child-pipeline-trigger
- build # build collection tar.gz
- deploy # push collection tar.gz to galaxy
before_script:
- pip3 install -r sanity.requirements -r test.requirements -r docs.requirements
- apt update
- apt install -y git shellcheck make
coverage:
stage: test
needs: []
image: python:3.8.12-slim-buster
script:
- pip install ansible-core==2.13.1
# ansible-test needs special directory structure.
- mkdir -p /work-dir/ansible_collections/scale_computing/
- cp -a ./ /work-dir/ansible_collections/scale_computing/hypercore
- pushd /work-dir/ansible_collections/scale_computing/hypercore
#
# - ansible-test coverage erase --venv
# Use venv, until we agree about dind - eventually we need to move to github anyway?
- ansible-test units --coverage
- ansible-test coverage html --requirements
- ansible-test coverage report --omit 'tests/*' --show-missing
- ls -al tests/output/reports/coverage
#
# Move artifacts back to initial dir, so they can be collected by gitlab.
- popd
- ART_DIR=tests/output/reports/coverage/
- mkdir -p $ART_DIR
- cp -a /work-dir/ansible_collections/scale_computing/hypercore/$ART_DIR $ART_DIR
- ls -al $ART_DIR
artifacts:
name: hypercore_html_coverage
paths:
- tests/output/reports/coverage
expose_as: html_coverage
expire_in: 10 week
sanity:
stage: test
needs: []
image: python:3.8.12-slim-buster
script:
- pip install ansible-core==2.13.1
# ansible-test needs special directory structure.
- mkdir -p /work-dir/ansible_collections/scale_computing/
- cp -a ./ /work-dir/ansible_collections/scale_computing/hypercore
- pushd /work-dir/ansible_collections/scale_computing/hypercore
#
# Same as "make sanity"
# TODO reuse Makefile
- black -t py38 --check --diff --color plugins tests/unit
- ansible-lint
- flake8 --exclude tests/output/
- ansible-test sanity
docs:
stage: test
needs: []
image: python:3.8.12-slim-buster
script:
# ansible-test needs special directory structure.
- mkdir -p /work-dir/ansible_collections/scale_computing/
- cp -a ./ /work-dir/ansible_collections/scale_computing/hypercore
- pushd /work-dir/ansible_collections/scale_computing/hypercore
#
- make docs
#
# Move artifacts back to initial dir, so they can be collected by gitlab.
- popd
- ART_DIR=docs/build/html
- mkdir -p $ART_DIR
- cp -a /work-dir/ansible_collections/scale_computing/hypercore/$ART_DIR $ART_DIR
- ls -al $ART_DIR
artifacts:
name: hypercore_html_docs
paths:
- docs/build/html/
expose_as: html_docs
expire_in: 10 week
# This takes about 30 minutes
# Run it manually if serial integration tests execution is needed.
integration:
stage: test
needs: []
when: manual
image: python:3.8.12-slim-buster
# we have a single HC3 cluster, so run at most one "ansible-test integration" at a time.
resource_group: hc3_cluster_0
script:
- pip install ansible-core==2.13.1
# ansible-test needs special directory structure.
- mkdir -p /work-dir/ansible_collections/scale_computing/
- cp -a ./ /work-dir/ansible_collections/scale_computing/hypercore
- pushd /work-dir/ansible_collections/scale_computing/hypercore
#
- |
cat <<EOF >tests/integration/integration_config.yml
# Generated by .gitlab-ci.yml
sc_host: ${SC_HOST}
sc_username: ${SC_USERNAME}
sc_password: ${SC_PASSWORD}
smb_server: ${SMB_SERVER}
smb_share: ${SMB_SHARE}
smb_username: ${SMB_USERNAME}
smb_password: ${SMB_PASSWORD}
EOF
- cat tests/integration/integration_config.yml
- ansible-test integration
generate-child-pipeline:
stage: test-child-pipeline-generator
needs: []
image: python:3.8.12-slim-buster
script:
- pip install jinja2
- python3 ./ci-infra/gitlab-dynamic-pipeline/generate_integration_pipeline.py
- cat child-pipeline-gitlab-ci.yml
artifacts:
paths:
- child-pipeline-gitlab-ci.yml
trigger-child-pipeline:
stage: test-child-pipeline-trigger
needs:
- generate-child-pipeline
trigger:
include:
- artifact: child-pipeline-gitlab-ci.yml
job: generate-child-pipeline
strategy: depend
build-tar-gz:
stage: build
needs: []
image: python:3.8.12-slim-buster
only:
- develop
- master
- tags
- build-collection
script:
- pip install ansible-core==2.13.1
- ansible-galaxy collection build
artifacts:
paths:
- scale_computing-hypercore-*.tar.gz