generated from oracle-quickstart/oci-quickstart-template
-
Notifications
You must be signed in to change notification settings - Fork 45
/
.gitlab-ci.yml
130 lines (121 loc) · 5.03 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
# A pipeline is composed of independent jobs that run scripts, grouped into stages.
# Stages run in sequential order, but jobs within stages run in parallel.
#
# For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
stages: # List of stages for jobs, and their order of execution
- test-unit
- TF-Plan-e2e
- TF-Apply-e2e
- TF-Workload-Apply-e2e
- TF-Reapply-e2e
- TF-Destroy-e2e
.testing_pipeline:
before_script:
- export http_proxy=http://www-proxy-hqdc.us.oracle.com:80
- export https_proxy=$http_proxy
- curl https://releases.hashicorp.com/terraform/1.2.2/terraform_1.2.2_linux_amd64.zip > terraform.zip
- unzip terraform.zip -d /bin
- terraform --version
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-add -l
- pip install -r test/requirements.txt
image: lab-runner
tags: [LZ]
unit-test-job: # This job runs in the test stage.
extends: .testing_pipeline
stage: test-unit
script:
- pytest -c test/pytest.ini -m "unit and not expensive" --junit-xml=pytest.xml
# # Orahub's artifact upload seems broken. Possibly a config issue...
# artifacts:
# when: always
# paths:
# - pytest.xml
# reports:
# junit: pytest.xml
rules:
- if: ($CI_COMMIT_BRANCH != "main")
e2e-full-plan-job: # This job runs terraform plan.
extends: .testing_pipeline
stage: TF-Plan-e2e
when: on_success
script:
- cd templates/enterprise-landing-zone
- ./BackEnd.sh
- cat backend.tf
- curl $BASE_LAST_OUTPUT > base_output.json
- curl $WE_LAST_OUTPUT > we_output.json
- cp $ENV_TFVARS_FILE_NAME updated-$ENV_TFVARS_FILE_NAME
- python3 read_workload_vars.py -f base_output.json -p we_output.json >> updated-$ENV_TFVARS_FILE_NAME
- terraform init -backend-config="address=$REMOTE_STATE_BACKEND" -backend-config="update_method=PUT"
- terraform validate
- terraform plan -var-file=updated-$ENV_TFVARS_FILE_NAME
rules:
- if: ($CI_COMMIT_BRANCH == "LANZ-Integration")
e2e-full-deploy-job: # This job runs terraform apply.
extends: .testing_pipeline
stage: TF-Apply-e2e
when: on_success
script:
- cd templates/enterprise-landing-zone
- ./BackEnd.sh
- cat backend.tf
- curl $BASE_LAST_OUTPUT > base_output.json
- curl $WE_LAST_OUTPUT > we_output.json
- cp $ENV_TFVARS_FILE_NAME updated-$ENV_TFVARS_FILE_NAME
- python3 read_workload_vars.py -f base_output.json -p we_output.json >> updated-$ENV_TFVARS_FILE_NAME
- terraform init -backend-config="address=$REMOTE_STATE_BACKEND" -backend-config="update_method=PUT"
- terraform validate
- terraform apply -var-file=updated-$ENV_TFVARS_FILE_NAME -auto-approve #neeed to look at pasing a plan file but have to understan gitlab artifiacts issue
- terraform output -json > base_output.json
- 'curl -X PUT -H "Content-Type: application/json" -d @base_output.json $BASE_LAST_OUTPUT'
rules:
- if: ($CI_COMMIT_BRANCH == "LANZ-Integration")
retry: 1
e2e-redeploy-job:
extends: e2e-full-deploy-job
stage: TF-Reapply-e2e
e2e-full-destroy-job: # This job runs terraform destroy.
extends: .testing_pipeline
stage: TF-Destroy-e2e
when: manual
allow_failure: true
script:
- cd templates/enterprise-landing-zone
- ./BackEnd.sh
- cat backend.tf
- curl $BASE_LAST_OUTPUT > base_output.json
- curl $WE_LAST_OUTPUT > we_output.json
- cp $ENV_TFVARS_FILE_NAME updated-$ENV_TFVARS_FILE_NAME
- python3 read_workload_vars.py -f base_output.json -p we_output.json >> updated-$ENV_TFVARS_FILE_NAME
- terraform init -backend-config="address=$REMOTE_STATE_BACKEND" -backend-config="update_method=PUT"
- terraform validate
- terraform destroy -var-file=updated-$ENV_TFVARS_FILE_NAME -auto-approve #neeed to look at pasing a plan file but have to understand gitlab artifiacts issue
- terraform output -json > base_output.json
- 'curl -X PUT -H "Content-Type: application/json" -d @base_output.json $BASE_LAST_OUTPUT'
rules:
- if: ($CI_COMMIT_BRANCH == "LANZ-Integration")
e2e-workload-deploy-job: # This job runs terraform apply on Workload Expansion.
extends: .testing_pipeline
stage: TF-Workload-Apply-e2e
when: on_success
script:
- cd templates
- elz-workload/add_workload.sh TestWE P
- cd elz-workload-P-TestWE
- ./BackEnd.sh
- cat backend.tf
- curl $BASE_LAST_OUTPUT > base_output.json
- curl $WE_LAST_OUTPUT > we_output.json
- python3 read_base_vars.py -e P -f base_output.json >> $ENV_TFVARS_FILE_NAME
- terraform init -backend-config="address=$WE_REMOTE_STATE_BACKEND" -backend-config="update_method=PUT"
- terraform validate
- terraform apply -var-file=$ENV_TFVARS_FILE_NAME -auto-approve #need to look at pasing a plan file but have to understan gitlab artifiacts issue
- terraform output -json > we_output.json
- 'curl -X PUT -H "Content-Type: application/json" -d @we_output.json $WE_LAST_OUTPUT'
rules:
- if: ($CI_COMMIT_BRANCH == "LANZ-Integration")
retry: 1