-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path.gitlab-ci.yml
142 lines (131 loc) · 5.73 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
variables:
POI_IMAGE_NAME: photon/installer:$CI_COMMIT_SHORT_SHA
GITHUB_BRANCH: master
POI_REGISTRY: poi-registry:5000
stages:
- build
- test
- github
- deploy
build-container:
stage: build
needs: []
script:
- cd docker && docker build -t ${POI_IMAGE_NAME} --build-context poi-helper=$(realpath $(pwd)/..) .
- docker tag ${POI_IMAGE_NAME} ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker push ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker system prune -f
cayman_poi:
stage: build
needs: []
script:
- ./ci/gitlab/submodule_ci.py --private-token=$CAYMAN_POI_CICD_API_TOKEN --project-id core-build/cayman_photon-os-installer --branch test/poi-submodule/$CI_COMMIT_SHORT_SHA --parent-branch vmware-master --submodule-path poi/src --submodule-sha $CI_COMMIT_SHA
pytest:
stage: test
needs:
- build-container
script:
- docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME}
- pytest-3 -x tests/poi-container-test.py
after_script:
# change ownerships for cleanup
- cd tests/
- sudo chown -R $(id -u -n):$(id -g -n) .
ova-poi-harness:
variables:
VM_NAME_BASE: ova-poi-harness-${CI_COMMIT_SHORT_SHA}
stage: test
needs:
- build-container
parallel:
matrix:
- NAME:
- minimal
- minimal_lvm
OVA_CONFIG: minimal_ova.yaml
- NAME: gitlab-runner
OVA_CONFIG: gitlab-runner_ova.yaml
- NAME: minimal
OVA_CONFIG: minimal_ova.yaml
PHOTON_RELEASE: "4.0"
script:
- KS_FILE=${NAME}_ks.yaml
- PHOTON_RELEASE="${PHOTON_RELEASE:-5.0}"
- VM_NAME=${VM_NAME_BASE}-${NAME}-${PHOTON_RELEASE}
- docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME}
- cd examples/ova
- docker run --rm --privileged -v/dev:/dev -v$(pwd):/workdir ${POI_IMAGE_NAME} create-image --repo-paths= -c ${KS_FILE} -v ${PHOTON_RELEASE}
- docker run --rm -v$(pwd):/workdir -w/workdir ${POI_IMAGE_NAME} create-ova --ovf --mf --vmdk --installer-config ${KS_FILE} --ova-config ${OVA_CONFIG}
# clone the harness code
- git clone --depth=1 https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git
- (cd poi-harness && echo "poi-harness sha is $(git rev-parse --short HEAD)")
- pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf *.ovf --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config ${KS_FILE} --ova_config ${OVA_CONFIG}
after_script:
# change ownerships for cleanup
- cd examples/ova
- sudo chown -R $(id -u -n):$(id -g -n) .
iso-poi-harness:
variables:
ISO_OVF: photon5-iso-boot-${CI_COMMIT_SHORT_SHA}.ovf
VM_NAME_BASE: poi-iso-boot-${CI_COMMIT_SHORT_SHA}
stage: test
needs:
- build-container
parallel:
matrix:
- NAME:
- minimal
- ostree
script:
- VM_NAME=${VM_NAME_BASE}-${NAME}
- KS_FILE=${NAME}_ks.yaml
- docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME}
- cd examples/iso
# create ISO
- docker run --rm --privileged -v/dev:/dev -v$(pwd):/workdir ${POI_IMAGE_NAME} photon-iso-builder --config iso.yaml
# create OVF that includes that ISO, and a blank hard disk
# base64 encode the ks file, must have no new lines (-w0)
- KSDATA64=$(base64 -w0 < ${KS_FILE})
- docker run --rm -v$(pwd):/workdir ${POI_IMAGE_NAME} ova-compose -i iso_ova.yaml -o ${ISO_OVF} -m --param ksdata64=${KSDATA64}
# clone the harness code
- git clone --depth=1 https://:${POI_HARNESS_PULL_TOKEN}@${CI_SERVER_HOST}/photon/poi-harness.git
# POI harness will deploy OVF on a VC and run tests
- pytest ./poi-harness/ci/pytest/ -rs --deploy --ovf ${ISO_OVF} --name ${VM_NAME} --vc_config ${VC_CONFIG_FILE} --ks_config ${KS_FILE} --ova_config iso_ova.yaml --param ksdata64=${KSDATA64}
after_script:
# change ownerships for cleanup
- cd examples/iso
- sudo chown -R $(id -u -n):$(id -g -n) .
github:
stage: github
rules:
# only for the master branch
- if: $CI_COMMIT_REF_NAME == $GITHUB_BRANCH
variables:
# need clone strategy or adding a remote will fail if it exists
GIT_STRATEGY: clone
GITHUB_USER: gerrit-photon
script:
- git checkout $CI_COMMIT_REF_NAME
- git remote add github https://$GITHUB_USER:[email protected]/vmware/photon-os-installer.git
- git push github
push-image:
# no `needs` entry - this should run at last job, only when all others have succeeded
stage: deploy
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
variables:
ARTIFACTORY_SERVER: photon-docker-prod-local.usw5.packages.broadcom.com
script:
- set -e
- docker pull ${POI_REGISTRY}/${POI_IMAGE_NAME}
- docker tag ${POI_REGISTRY}/${POI_IMAGE_NAME} ${POI_IMAGE_NAME}
- echo ${ARTIFACTORY_TOKEN} | docker login --username ${ARTIFACTORY_USER} --password-stdin ${ARTIFACTORY_SERVER}
# this will be available in public as projects.packages.broadcom.com/photon/installer:$CI_COMMIT_SHORT_SHA
- docker tag $POI_IMAGE_NAME ${ARTIFACTORY_SERVER}/$POI_IMAGE_NAME
- docker push ${ARTIFACTORY_SERVER}/$POI_IMAGE_NAME
# also as latest
- docker tag ${ARTIFACTORY_SERVER}/$POI_IMAGE_NAME ${ARTIFACTORY_SERVER}/photon/installer:latest
- docker push ${ARTIFACTORY_SERVER}/photon/installer:latest