-
Notifications
You must be signed in to change notification settings - Fork 18
/
.gitlab-ci.yml
76 lines (70 loc) · 2.91 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
variables:
POI_IMAGE_NAME: photon/installer:$CI_COMMIT_SHORT_SHA
GITHUB_BRANCH: master
POI_REGISTRY: poi-registry:5000
stages:
- build
- test
- github
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) .
iso-poi-harness:
variables:
ISO_OVF: photon5-iso-boot-${CI_COMMIT_SHORT_SHA}.ovf
VM_NAME: poi-iso-boot-${CI_COMMIT_SHORT_SHA}
stage: test
needs:
- build-container
script:
- 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)
- docker run --rm -v$(pwd):/workdir ${POI_IMAGE_NAME} ova-compose -i iso_ova.yaml -o ${ISO_OVF} -m --param ksdata64=$(base64 -w0 < minimal_ks.yaml)
# clone the harness code
- git clone 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 minimal_ks.yaml --ova_config iso_ova.yaml
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