.gitlab-ci.yml 8.43 KB
Newer Older
ethiraj krishnamanaidu's avatar
ethiraj krishnamanaidu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Copyright 2021 Schlumberger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

15
16
17
18
19
20
21
22
23
24
25
26
.osdu-gcp-variables-k8s:
  variables:
    # OSDU Infrastructure variables
    OSDU_GCP_PROJECT_NAME: osdu-service-prod
    OSDU_GCP_ZONE: us-central1-c
    OSDU_GCP_TENANT: odesprod
    OSDU_GCP_CLUSTER: osdu-service-prod-gke-wellbore
    OSDU_GCP_LEGAL_TAG: odesprod-demo-legaltag
    OSDU_GCP_PROJECT_SA: $OSDU_GCP_SA_PROD
    # OSDU Service & Int test variables
    OSDU_GCP_WELLBORE_DDMS_URL: https://wellbore-ddms-preship.osdu-gcp.go3-nrg.projects.epam.com/api/os-wellbore-ddms
    OSDU_GCP_APPLICATION_HEALTH_URL: https://wellbore-ddms-preship.osdu-gcp.go3-nrg.projects.epam.com/api/os-wellbore-ddms/healthz
27
    #OSDU_GCP_ENV_HELM_EXTRA_VARS: --set secret.gcpSA=$osdu_gcp_sa_encode --set namespace=$OSDU_GCP_APPLICATION_NAME --set configMap.data.projectId=$OSDU_GCP_PROJECT_NAME --set configMap.data.searchEndpoint="https://search-drgfbg5txq-uc.a.run.app/api/search" --set configMap.data.storageEndpoint="https://storage-drgfbg5txq-uc.a.run.app/api/storage" --set image.repository=gcr.io/osdu-service-prod/wellbore-ddms/wellbore-ddms-gcp --set image.tag=latest
28
    OSDU_GCP_ENV_HELM_EXTRA_VARS: --set secret.gcpSA=$osdu_gcp_sa_encode --set namespace=$OSDU_GCP_APPLICATION_NAME --set configMap.data.projectId=$OSDU_GCP_PROJECT_NAME --set configMap.data.searchEndpoint="https://search-drgfbg5txq-uc.a.run.app/api/search" --set configMap.data.storageEndpoint="https://storage-drgfbg5txq-uc.a.run.app/api/storage" #--set image.repository=$CI_REGISTRY_IMAGE --set image.tag=gcp-
29
30
31
32
    OSDU_GCP_APPLICATION_NAME: wellbore-ddms
    OSDU_GCP_HELM_DEPLOYMENT_DIR: devops/gcp
    OSDU_GCP_HELM_CHART: wellbore

33
34
35
.osdu-gcp-variables-community:
  variables:

36
variables:
37
  PIP_REQUIREMENTS: "requirements.txt requirements_dev.txt"
fabian serin's avatar
fabian serin committed
38

Yunhua Koglin's avatar
Yunhua Koglin committed
39
40
41
42
  AZURE_SERVICE: wellbore-ddms
  AZURE_DOCKER_SUBDIR: build/Dockerfile
  AZURE_TEST_SUBDIR: tests/integration
  AZURE_TEST_TYPE: python
Mykola Zamkovyi (EPAM)'s avatar
Mykola Zamkovyi (EPAM) committed
43
44
45
46
47
48
49
  
  AWS_SERVICE: wellbore-ddms
  AWS_ENVIRONMENT: dev
  AWS_BUILD_SUBDIR: provider/os-wellbore-ddms-aws/build-aws
  AWS_TEST_SUBDIR: tests/aws-test/build-aws
  AWS_INT_TEST_TYPE: python

50
51
52
53
include:
  - project: "osdu/platform/ci-cd-pipelines"
    file: "standard-setup.yml"

54
55
56
57
58
  - project: "osdu/platform/ci-cd-pipelines"
    file: "build/python.yml"

  - project: "osdu/platform/ci-cd-pipelines"
    file: "scanners/fossa-python.yml"
59

60
61
62
  - project: "osdu/platform/ci-cd-pipelines"
    file: "scanners/gitlab-ultimate.yml"

Yunhua Koglin's avatar
Yunhua Koglin committed
63
  - project: 'osdu/platform/ci-cd-pipelines'
64
    ref: "GONRG-2066_release_common_pipe_k8s"
Mykola Zamkovyi (EPAM)'s avatar
Mykola Zamkovyi (EPAM) committed
65
    file: 'cloud-providers/osdu-gcp-stateful-k8s.yml'
vladislav's avatar
vladislav committed
66

67
68
69
70
71
72
73
#  - project: 'osdu/platform/ci-cd-pipelines'
#    file: 'cloud-providers/ibm-wellbore.yml'
#
#  - local: "/devops/azure/azure-wellbore.yml"
#
#  - project: 'osdu/platform/ci-cd-pipelines'
#    file: 'cloud-providers/aws.yml'
Mykola Zamkovyi (EPAM)'s avatar
Mykola Zamkovyi (EPAM) committed
74

75
# --------------------------------------------------------------------------------
76
77
78
containerize:
  extends:
    - .skipForTriggeringMergeRequests
fabian serin's avatar
fabian serin committed
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
  stage: containerize
  image: docker:19.03
  tags: ['osdu-medium']
  variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
  script:
    - echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
    - apk update
    - apk add git
    - echo ---- ---- ---- BUILD IMAGE ---- ---- ----
    - commit_id=$(git log -n 1 --pretty="%h")
    - echo ---- ---- TAG NAME
    - tag_name="_gitlab_$commit_id"
    - echo $tag_name
    - echo ---- ---- DATE
    - current_utc_date=`date --utc`
    - echo $current_utc_date
    - echo ---- ---- COMMIT BRANCH
    - commit_branch=$commit_id
    - echo $commit_branch
    - echo ---- ---- BUILD IMAGE
    - docker build -t $IMAGE_TAG -t=$CI_REGISTRY_IMAGE:latest --rm . -f ./build/Dockerfile --build-arg PIP_WHEEL_DIR=python-packages --build-arg build_date="$current_utc_date" --build-arg build_number=$commit_id --build-arg commit_id=$commit_id --build-arg build_origin="Gitlab" --build-arg commit_branch=$commit_branch
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - echo ---- ---- PUSH IMAGE
    - docker push $IMAGE_TAG
    - docker push $CI_REGISTRY_IMAGE:latest

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
#osdu-gcp-containerize:
#  stage: containerize
#  cache: {}
#  tags: [ 'osdu-medium' ]
#  only:
#    variables:
#      - $OSDU_GCP == 'true'
#  script:
#  variables:
#      IMAGE_TAG: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:$CI_COMMIT_SHA
#  script:
#    - echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
#    - apk update
#    - apk add git
#    - echo ---- ---- ---- BUILD IMAGE ---- ---- ----
#    - commit_id=$(git log -n 1 --pretty="%h")
#    - echo ---- ---- TAG NAME
#    - tag_name="_gitlab_$commit_id"
#    - echo $tag_name
#    - echo ---- ---- DATE
#    - current_utc_date=`date --utc`
#    - echo $current_utc_date
#    - echo ---- ---- COMMIT BRANCH
#    - commit_branch=$commit_id
#    - echo $commit_branch
#    - echo ---- ---- BUILD IMAGE
#    - docker build -t $IMAGE_TAG -t=$CI_REGISTRY_IMAGE:latest --rm . -f ./build/Dockerfile --build-arg PIP_WHEEL_DIR=python-packages --build-arg build_date="$current_utc_date" --build-arg build_number=$commit_id --build-arg commit_id=$commit_id --build-arg build_origin="Gitlab" --build-arg commit_branch=$commit_branch
#    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
#    - echo ---- ---- PUSH IMAGE
#    - docker push $IMAGE_TAG
#    - docker push $CI_REGISTRY_IMAGE:gcp-latest
138
139

osdu-gcp-containerize-for-release:
140
  stage: containerize
141
  image: docker:19.03
142
143
144
145
146
147
  extends:
    - .osdu-gcp-variables-k8s
  cache: {}
  tags: [ 'osdu-medium' ]
  only:
    variables:
148
149
      #- $OSDU_GCP == 'true' && $RELEASE =~ /(v)(\d+\.)(\d+\.)\w+/i
      - $OSDU_GCP == 'true'
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  script:
  variables:
      IMAGE_TAG: $CI_REGISTRY_IMAGE/gcp-$CI_COMMIT_REF_SLUG:gcp-$RELEASE
  script:
    - echo ---- ---- ---- SYSTEM DEPENDENCIES ---- ---- ----
    - apk update
    - apk add git
    - echo ---- ---- ---- BUILD IMAGE ---- ---- ----
    - commit_id=$(git log -n 1 --pretty="%h")
    - echo ---- ---- TAG NAME
    - tag_name="_gitlab_$commit_id"
    - echo $tag_name
    - echo ---- ---- DATE
    - current_utc_date=`date --utc`
    - echo $current_utc_date
    - echo ---- ---- COMMIT BRANCH
    - commit_branch=$commit_id
    - echo $commit_branch
    - echo ---- ---- BUILD IMAGE
    - docker build -t $IMAGE_TAG -t=$CI_REGISTRY_IMAGE:latest --rm . -f ./build/Dockerfile --build-arg PIP_WHEEL_DIR=python-packages --build-arg build_date="$current_utc_date" --build-arg build_number=$commit_id --build-arg commit_id=$commit_id --build-arg build_origin="Gitlab" --build-arg commit_branch=$commit_branch
    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
    - echo ---- ---- PUSH IMAGE
    - docker push $IMAGE_TAG

#----------------------------------------------------
Yunhua Koglin's avatar
Yunhua Koglin committed
175

176
osdu-gcp-test-python:
177
  stage: integration
178
  image: gcr.io/google.com/cloudsdktool/cloud-sdk
179
  extends: .osdu-gcp-variables-k8s
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
  allow_failure: true
  only:
    variables:
      - $OSDU_GCP == 'true' && $OSDU_GCP_INT_TEST_TYPE == 'python'
  script:
    - apt-get install -y python3-venv
    - python3 -m venv env
    - source env/bin/activate
    - pip install --upgrade pip
    - pip install wheel pytest pytest-cov
    - pip install -r requirements.txt
    - pip install -r requirements_dev.txt
    - cd tests/integration
    - echo $OSDU_GCP_INTEGRATION_TESTER_PROD | base64 -d > file.json
    - gcloud auth activate-service-account --key-file file.json
195
    - gcloud config set project $OSDU_GCP_PROJECT_NAME
196
197
    - python gen_postman_env.py --token $(gcloud auth print-identity-token) --base_url $OSDU_GCP_WELLBORE_DDMS_URL --cloud_provider $OSDU_GCP_VENDOR --data_partition $OSDU_GCP_TENANT --acl_domain $DOMAIN --legal_tag $OSDU_GCP_LEGAL_TAG
    - pytest ./functional --environment="./generated/postman_environment.json" --filter-tag=basic
Yunhua Koglin's avatar
Yunhua Koglin committed
198

199
200
201
202
203
204
205
206
207
208
#osdu-gcp-test:
#  stage: integration
#  extends: []
#  image: gcr.io/google.com/cloudsdktool/cloud-sdk
#  allow_failure: true
#  stage: integration
#  needs: ["osdu-gcp-deploy"]
#  only:
#    variables:
#      - $OSDU_GCP == 'true' && $OSDU_GCP_INT_TEST_TYPE != 'python'