forked from openebs-archive/maya
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
82 lines (78 loc) · 3.3 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
stages:
- build
- baseline
- cleanup
build-maya:
stage: build
only:
refs:
- /^(v[0-9][.][0-9][.]x|master)?$/
before_script:
- export COMMIT=${CI_COMMIT_SHORT_SHA}
- export GOPATH=$HOME/go
- export PATH=$HOME/go/bin:$PATH
- mkdir -p $HOME/go/src/github.com/openebs/maya
- rsync -az --delete ${CI_PROJECT_DIR}/ ${HOME}/go/src/github.com/openebs/maya/ #CI_PROJECT_DIR is full path where project is cloned
- go env
- ls $GOPATH
- cd ${HOME}/go/src/github.com/openebs/maya
- make bootstrap
- make format
# Download kubectl, which is a requirement for using minikube.
- curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/v1.10.0/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
# Download minikube.
- curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.28.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
- export MINIKUBE_WANTUPDATENOTIFICATION=false
- export MINIKUBE_WANTREPORTERRORPROMPT=false
- export MINIKUBE_HOME=$HOME
- export CHANGE_MINIKUBE_NONE_USER=true
- mkdir $HOME/.kube || true
- touch $HOME/.kube/config
- export KUBECONFIG=$HOME/.kube/config
- sudo minikube start --vm-driver=none --bootstrapper=localkube --kubernetes-version=v1.10.0 --extra-config=apiserver.Authorization.Mode=RBAC --feature-gates=MountPropagation=false
# Fix the kubectl context, as it's often stale.
- sudo minikube update-context
# Wait for Kubernetes to be up and ready.
- JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'; until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do sleep 1; done
script:
- echo "Building Maya"
- kubectl cluster-info
- kubectl get deployment -n openebs
- sleep 20
- make all
# - ./ci/travis-ci.sh
- make deploy-images
baseline-image:
stage: baseline
only:
refs:
- /^(v[0-9][.][0-9][.]x|master)?$/
script:
- pwd
- export BRANCH=${CI_COMMIT_REF_NAME}
- echo $BRANCH
- export COMMIT=${CI_COMMIT_SHORT_SHA}
- echo $COMMIT
- git clone https://github.com/openebs/e2e-infrastructure.git
- git checkout $BRANCH
- cd e2e-infrastructure/baseline
- ansible-playbook commit-writer.yml --extra-vars "branch=$BRANCH repo=$CI_PROJECT_NAME commit=$COMMIT"
- git status
- git add baseline
- git status
- git commit -m "updated $CI_PROJECT_NAME commit:$COMMIT"
- git push https://$user:[email protected]/openebs/e2e-infrastructure.git --all
- curl -X POST -F variable[INFRA_BRANCH]=$BRANCH -F token=$PACKET -F ref=k8s-1-11 https://gitlab.openebs.ci/api/v4/projects/27/trigger/pipeline
- curl -X POST -F variable[INFRA_BRANCH]=$BRANCH -F token=$PACKET -F ref=k8s-1-12 https://gitlab.openebs.ci/api/v4/projects/27/trigger/pipeline
- curl -X POST -F variable[INFRA_BRANCH]=$BRANCH -F token=$PACKET -F ref=k8s-1-13 https://gitlab.openebs.ci/api/v4/projects/27/trigger/pipeline
clean-maya:
when: always
stage: cleanup
only:
refs:
- /^(v[0-9][.][0-9][.]x|master)?$/
script:
- sudo minikube delete || true
- sudo rm -r ~/go
- sudo docker images
- sudo docker image prune -a --force