|
13 | 13 | # limitations under the License.
|
14 | 14 |
|
15 | 15 | steps:
|
16 |
| - # Install node dependencies for linting and testing |
17 |
| -- name: node |
18 |
| - id: "Install Dependencies" |
19 |
| - entrypoint: npm |
20 |
| - args: |
21 |
| - - "install" |
22 |
| - - "--silent" |
23 |
| - - "--no-fund" |
24 |
| - # Run static code analysis and linting |
25 |
| -- name: node |
26 |
| - id: "Static Code Analysis" |
27 |
| - entrypoint: "bash" |
28 |
| - args: |
29 |
| - - "-c" |
30 |
| - - |- |
31 |
| - npm run apigeelint | tee report.apigeelint.html && \ |
32 |
| - if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi && \ |
33 |
| - npm run eslint | tee report.eslint.html && \ |
34 |
| - if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi |
35 |
| - # Run unit tests for custom policy implementations |
36 |
| -- name: node |
37 |
| - id: "Unit Test" |
38 |
| - entrypoint: "bash" |
39 |
| - args: |
40 |
| - - "-c" |
41 |
| - - "npm run unit-test" |
42 |
| - # Fetch Apigee credentials |
43 |
| - # and set branch specific config parameters |
44 |
| -- name: gcr.io/cloud-builders/gcloud |
45 |
| - entrypoint: "bash" |
46 |
| - id: "Fetch Credentials" |
47 |
| - args: |
48 |
| - - "-c" |
49 |
| - - |- |
50 |
| - # Config based on branch name |
51 |
| - if [ "$BRANCH_NAME" = "main" ] |
52 |
| - then |
53 |
| - echo "export APIGEE_ENV=$_APIGEE_TEST_ENV" >> env.txt |
54 |
| - echo "export APIGEE_DEPLOYMENT_SUFFIX=''" >> env.txt |
55 |
| - elif [ "$BRANCH_NAME" = "prod" ] |
56 |
| - then |
57 |
| - echo "export APIGEE_ENV=$_APIGEE_PROD_ENV" >> env.txt |
58 |
| - echo "export APIGEE_DEPLOYMENT_SUFFIX=''" >> env.txt |
59 |
| - else |
60 |
| - echo "export APIGEE_ENV=$_APIGEE_TEST_ENV" >> env.txt |
61 |
| - echo "export APIGEE_DEPLOYMENT_SUFFIX=\"-$(echo $BRANCH_NAME | \ |
62 |
| - sed "s/[^A-Za-z0-9]/-/g")\"" >> env.txt |
63 |
| - fi |
| 16 | + # Install node dependencies for linting and testing |
| 17 | + - name: node |
| 18 | + id: "Install Dependencies" |
| 19 | + entrypoint: npm |
| 20 | + args: |
| 21 | + - "install" |
| 22 | + - "--silent" |
| 23 | + - "--no-fund" |
| 24 | + # Run static code analysis and linting |
| 25 | + - name: node |
| 26 | + id: "Static Code Analysis" |
| 27 | + entrypoint: "bash" |
| 28 | + args: |
| 29 | + - "-c" |
| 30 | + - |- |
| 31 | + npm run apigeelint | tee report.apigeelint.html && \ |
| 32 | + if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi && \ |
| 33 | + npm run eslint | tee report.eslint.html && \ |
| 34 | + if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi |
| 35 | + # Run unit tests for custom policy implementations |
| 36 | + - name: node |
| 37 | + id: "Unit Test" |
| 38 | + entrypoint: "bash" |
| 39 | + args: |
| 40 | + - "-c" |
| 41 | + - "npm run unit-test" |
| 42 | + # Fetch Apigee credentials |
| 43 | + # and set branch specific config parameters |
| 44 | + - name: gcr.io/cloud-builders/gcloud |
| 45 | + entrypoint: "bash" |
| 46 | + id: "Fetch Credentials" |
| 47 | + args: |
| 48 | + - "-c" |
| 49 | + - |- |
| 50 | + # Config based on branch name |
| 51 | + if [ "$BRANCH_NAME" = "main" ] |
| 52 | + then |
| 53 | + echo "export APIGEE_ENV=$_APIGEE_TEST_ENV" >> env.txt |
| 54 | + echo "export APIGEE_DEPLOYMENT_SUFFIX=''" >> env.txt |
| 55 | + elif [ "$BRANCH_NAME" = "prod" ] |
| 56 | + then |
| 57 | + echo "export APIGEE_ENV=$_APIGEE_PROD_ENV" >> env.txt |
| 58 | + echo "export APIGEE_DEPLOYMENT_SUFFIX=''" >> env.txt |
| 59 | + else |
| 60 | + echo "export APIGEE_ENV=$_APIGEE_TEST_ENV" >> env.txt |
| 61 | + echo "export APIGEE_DEPLOYMENT_SUFFIX=\"-$(echo $BRANCH_NAME | \ |
| 62 | + sed "s/[^A-Za-z0-9]/-/g")\"" >> env.txt |
| 63 | + fi |
64 | 64 |
|
65 |
| - if [ "$_API_VERSION" = "apigee" ] |
66 |
| - then |
67 |
| - echo "export APIGEE_BUILD_PASS=\"$(gcloud secrets versions access latest \ |
68 |
| - --secret=devrel_apigee_pass --format="get(payload.data)" | \ |
69 |
| - base64 -d)\"" >> env.txt && |
70 |
| - echo "export APIGEE_BUILD_USER=\"$(gcloud secrets versions access latest \ |
71 |
| - --secret=devrel_apigee_user --format="get(payload.data)" | \ |
72 |
| - base64 -d)\"" >> env.txt |
73 |
| - else |
74 |
| - echo "export APIGEE_BUILD_TOKEN=\"$(gcloud auth application-default print-access-token)\"" >> env.txt |
75 |
| - fi |
| 65 | + if [ "$_API_VERSION" = "apigee" ] |
| 66 | + then |
| 67 | + echo "export APIGEE_BUILD_PASS=\"$(gcloud secrets versions access latest \ |
| 68 | + --secret=devrel_apigee_pass --format="get(payload.data)" | \ |
| 69 | + base64 -d)\"" >> env.txt && |
| 70 | + echo "export APIGEE_BUILD_USER=\"$(gcloud secrets versions access latest \ |
| 71 | + --secret=devrel_apigee_user --format="get(payload.data)" | \ |
| 72 | + base64 -d)\"" >> env.txt |
| 73 | + else |
| 74 | + echo "export APIGEE_BUILD_TOKEN=\"$(gcloud auth application-default print-access-token)\"" >> env.txt |
| 75 | + fi |
76 | 76 |
|
77 |
| - echo "[BUILD CONFIG]" |
78 |
| - echo |
79 |
| - cat env.txt | sed "s/APIGEE_BUILD_PASS=.*/APIGEE_BUILD_PASS=[hidden]/g" | \ |
80 |
| - sed "s/APIGEE_BUILD_TOKEN=.*/APIGEE_BUILD_TOKEN=[hidden]/g" |
| 77 | + echo "[BUILD CONFIG]" |
| 78 | + echo |
| 79 | + cat env.txt | sed "s/APIGEE_BUILD_PASS=.*/APIGEE_BUILD_PASS=[hidden]/g" | \ |
| 80 | + sed "s/APIGEE_BUILD_TOKEN=.*/APIGEE_BUILD_TOKEN=[hidden]/g" |
81 | 81 |
|
82 |
| - # Deploy using the Apigee credentials from above |
83 |
| -- name: "gcr.io/cloud-builders/mvn" |
84 |
| - id: "Proxy Deployment" |
85 |
| - entrypoint: "bash" |
86 |
| - args: |
87 |
| - - "-c" |
88 |
| - - |- |
89 |
| - if [ "$_API_VERSION" = "apigee" ] |
90 |
| - then |
| 82 | + # Deploy using the Apigee credentials from above |
| 83 | + - name: "gcr.io/cloud-builders/mvn" |
| 84 | + id: "Proxy Deployment" |
| 85 | + entrypoint: "bash" |
| 86 | + args: |
| 87 | + - "-c" |
| 88 | + - |- |
| 89 | + if [ "$_API_VERSION" = "apigee" ] |
| 90 | + then |
| 91 | + source env.txt && \ |
| 92 | + mvn clean install -ntp \ |
| 93 | + -P"apigeeapi" \ |
| 94 | + -Denv="$${APIGEE_ENV}" \ |
| 95 | + -Dpassword="$${APIGEE_BUILD_PASS}" \ |
| 96 | + -Dusername="$${APIGEE_BUILD_USER}" \ |
| 97 | + -Dorg="$_DEPLOYMENT_ORG" \ |
| 98 | + -Ddeployment.suffix="$${APIGEE_DEPLOYMENT_SUFFIX}" \ |
| 99 | + -Ddeployment.description="CloudRun Build: $BUILD_ID" |
| 100 | + else |
| 101 | + source env.txt && \ |
| 102 | + mvn clean install -ntp \ |
| 103 | + -P"googleapi" \ |
| 104 | + -Denv="$${APIGEE_ENV}" \ |
| 105 | + -Dtoken="$${APIGEE_BUILD_TOKEN}" \ |
| 106 | + -Dorg="$_DEPLOYMENT_ORG" \ |
| 107 | + -Ddeployment.suffix="$${APIGEE_DEPLOYMENT_SUFFIX}" \ |
| 108 | + -Ddeployment.description="CloudRun Build: $BUILD_ID" |
| 109 | + fi |
| 110 | + # Run integration tests |
| 111 | + - name: node |
| 112 | + id: "Integration Test" |
| 113 | + entrypoint: "bash" |
| 114 | + args: |
| 115 | + - "-c" |
| 116 | + - |- |
91 | 117 | source env.txt && \
|
92 |
| - mvn clean install -ntp \ |
93 |
| - -P"apigeeapi" \ |
94 |
| - -Denv="$${APIGEE_ENV}" \ |
95 |
| - -Dpassword="$${APIGEE_BUILD_PASS}" \ |
96 |
| - -Dusername="$${APIGEE_BUILD_USER}" \ |
97 |
| - -Dorg="$_DEPLOYMENT_ORG" \ |
98 |
| - -Ddeployment.suffix="$${APIGEE_DEPLOYMENT_SUFFIX}" \ |
99 |
| - -Ddeployment.description="CloudRun Build: $BUILD_ID" |
100 |
| - else |
101 |
| - source env.txt && \ |
102 |
| - mvn clean install -ntp \ |
103 |
| - -P"googleapi" \ |
104 |
| - -Denv="$${APIGEE_ENV}" \ |
105 |
| - -Dtoken="$${APIGEE_BUILD_TOKEN}" \ |
106 |
| - -Dorg="$_DEPLOYMENT_ORG" \ |
107 |
| - -Ddeployment.suffix="$${APIGEE_DEPLOYMENT_SUFFIX}" \ |
108 |
| - -Ddeployment.description="CloudRun Build: $BUILD_ID" |
109 |
| - fi |
110 |
| - # Run integration tests |
111 |
| -- name: node |
112 |
| - id: "Integration Test" |
113 |
| - entrypoint: "bash" |
114 |
| - args: |
115 |
| - - "-c" |
116 |
| - - |- |
117 |
| - source env.txt && \ |
118 |
| - npm run integration-test | tee report.e2e.html && \ |
119 |
| - if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi |
120 |
| - env: |
121 |
| - - "TEST_HOST=$_INT_TEST_HOST" |
122 |
| - # Copy coverage reports and other deployment artifacts to a storage bucket |
123 |
| -- name: "gcr.io/cloud-builders/gsutil" |
124 |
| - id: "Archive Report" |
125 |
| - entrypoint: "bash" |
126 |
| - args: |
127 |
| - - "-c" |
128 |
| - - |- |
129 |
| - gsutil cp -r coverage* \ |
130 |
| - gs://${PROJECT_ID}_cloudbuild/reports/$BUILD_ID/coverage && \ |
131 |
| - gsutil cp ./report.*.html \ |
132 |
| - gs://${PROJECT_ID}_cloudbuild/reports/$BUILD_ID |
| 118 | + npm run integration-test | tee report.e2e.html && \ |
| 119 | + if [ ${PIPESTATUS[0]} -ne "0" ]; then exit -1; fi |
| 120 | + env: |
| 121 | + - "TEST_HOST=$_INT_TEST_HOST" |
| 122 | + # Copy coverage reports and other deployment artifacts to a storage bucket |
| 123 | + - name: "gcr.io/cloud-builders/gsutil" |
| 124 | + id: "Archive Report" |
| 125 | + entrypoint: "bash" |
| 126 | + args: |
| 127 | + - "-c" |
| 128 | + - |- |
| 129 | + gsutil cp -r coverage* \ |
| 130 | + gs://${PROJECT_ID}_cloudbuild/reports/$BUILD_ID/coverage && \ |
| 131 | + gsutil cp ./report.*.html \ |
| 132 | + gs://${PROJECT_ID}_cloudbuild/reports/$BUILD_ID |
133 | 133 | substitutions:
|
134 |
| - # Apigee Org for where to deploy to |
135 |
| - _DEPLOYMENT_ORG: my-org |
136 |
| - # (Optional) Apigee Environment overrides |
137 |
| - _APIGEE_TEST_ENV: test |
138 |
| - _APIGEE_PROD_ENV: prod |
139 |
| - # Management API version use: |
140 |
| - # 'apigee' for current Apigee Edge |
141 |
| - # 'google' for Apigee X and hybrid |
142 |
| - _API_VERSION: apigee #apigee|google |
143 |
| - # Host name for the integration test |
144 |
| - _INT_TEST_HOST: org-env.apigee.net |
| 134 | + # Apigee Org for where to deploy to |
| 135 | + _DEPLOYMENT_ORG: my-org |
| 136 | + # (Optional) Apigee Environment overrides |
| 137 | + _APIGEE_TEST_ENV: test |
| 138 | + _APIGEE_PROD_ENV: prod |
| 139 | + # Management API version use: |
| 140 | + # 'apigee' for current Apigee Edge |
| 141 | + # 'google' for Apigee X and hybrid |
| 142 | + _API_VERSION: apigee #apigee|google |
| 143 | + # Host name for the integration test |
| 144 | + _INT_TEST_HOST: org-env.apigee.net |
0 commit comments