Skip to content

Commit 6e03cf6

Browse files
authored
Merge pull request #768 from apigee/feature/fix-go-pipeline
feat: base pipeline builder off alpine
2 parents ec557e3 + 6c3ada5 commit 6e03cf6

File tree

9 files changed

+67
-33
lines changed

9 files changed

+67
-33
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,19 @@ What's changed, or what was fixed?
1212
- [ ] I have run all the tests locally and they all pass.
1313
- [ ] I have followed the relevant style guide for my changes.
1414

15-
## Full Repo Validation Required
16-
(please check all that apply [x], do not edit the text)
15+
## ADVANCED Settings
16+
17+
For most PRs you most likely do not have to edit anything in this section.
18+
19+
### Test Scope
20+
21+
By default the PR pipeline tests all projects that were edited in the PR.
22+
23+
Some PRs might have side-effects on other projects such as changes to the test pipeline or shared tooling and need tests beyond the projects edited in this PR.
24+
25+
To customize the PR testing scope check [x] either option below and replace the sub-projects as needed.
26+
1727
- [ ] PR requires full pipeline run (Run for changes only by default).
28+
- [ ] Test following projects (comma separated list): references/cicd-pipeline,tools/apigee-sackmesser
1829

1930
**CC:** @apigee-devrel-reviewers

references/common-shared-flows/error-handling-v1/sharedflowbundle/resources/jsc/PopulateDefaultErrorVariables.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,6 @@ switch (context.getVariable("fault.name")) {
9898
// }
9999
}
100100

101-
if (context.getVariable("flow.error.code") == null || !context.getVariable("custom.error.code")) {
101+
if (!context.getVariable("custom.error.code")) {
102102
setFault(500, "Internal Server Error", "500.99", "Internal Server Error");
103103
}

references/identity-facade/test/integration/features/step_definitions/ui.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Given('I navigate to the authorize page', async function() {
3636
this.browser = await puppeteer.launch({
3737
ignoreHTTPSErrors: true,
3838
headless: true,
39-
args: ["--no-sandbox"]
39+
args: ["--no-sandbox", "--disable-gpu"]
4040
})
4141
this.page = await this.browser.newPage()
4242
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -49,7 +49,7 @@ Given('I navigate to the authorize page with query params that must be sanitized
4949
this.browser = await puppeteer.launch({
5050
ignoreHTTPSErrors: true,
5151
headless: true,
52-
args: ["--no-sandbox"]
52+
args: ["--no-sandbox", "--disable-gpu"]
5353
})
5454
this.page = await this.browser.newPage()
5555
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + ' ' + this.apickli.scenarioVariables.clientId
@@ -62,7 +62,7 @@ Given('I navigate to the authorize page with an invalid response type', async fu
6262
this.browser = await puppeteer.launch({
6363
ignoreHTTPSErrors: true,
6464
headless: true,
65-
args: ["--no-sandbox"]
65+
args: ["--no-sandbox", "--disable-gpu"]
6666
})
6767
this.page = await this.browser.newPage()
6868
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -75,7 +75,7 @@ Given('I navigate to the authorize page without a scope parameter', async functi
7575
this.browser = await puppeteer.launch({
7676
ignoreHTTPSErrors: true,
7777
headless: true,
78-
args: ["--no-sandbox"]
78+
args: ["--no-sandbox", "--disable-gpu"]
7979
})
8080
this.page = await this.browser.newPage()
8181
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -88,7 +88,7 @@ Given('I navigate to the authorize page without a state parameter', async functi
8888
this.browser = await puppeteer.launch({
8989
ignoreHTTPSErrors: true,
9090
headless: true,
91-
args: ["--no-sandbox"]
91+
args: ["--no-sandbox", "--disable-gpu"]
9292
})
9393
this.page = await this.browser.newPage()
9494
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -102,7 +102,7 @@ if (isPkceEnabled) {
102102
this.browser = await puppeteer.launch({
103103
ignoreHTTPSErrors: true,
104104
headless: true,
105-
args: ["--no-sandbox"]
105+
args: ["--no-sandbox", "--disable-gpu"]
106106
})
107107
this.page = await this.browser.newPage()
108108
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -114,7 +114,7 @@ if (isPkceEnabled) {
114114
this.browser = await puppeteer.launch({
115115
ignoreHTTPSErrors: true,
116116
headless: true,
117-
args: ["--no-sandbox"]
117+
args: ["--no-sandbox", "--disable-gpu"]
118118
})
119119
this.page = await this.browser.newPage()
120120
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -126,7 +126,7 @@ if (isPkceEnabled) {
126126
this.browser = await puppeteer.launch({
127127
ignoreHTTPSErrors: true,
128128
headless: true,
129-
args: ["--no-sandbox"]
129+
args: ["--no-sandbox", "--disable-gpu"]
130130
})
131131
this.page = await this.browser.newPage()
132132
return await this.page.goto('https://' + hostname + basePath + '/authorize?client_id=' + this.apickli.scenarioVariables.clientId

references/oidc-mock/test/integration/features/step_definitions/ui.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Given('I navigate to the authorize page', async function() {
3131
this.browser = await puppeteer.launch({
3232
ignoreHTTPSErrors: true,
3333
headless: true,
34-
args: ["--no-sandbox"]
34+
args: ["--no-sandbox", "--disable-gpu"]
3535
})
3636
this.page = await this.browser.newPage()
3737
return await this.page.goto('https://' + hostname + '/v1/openid-connect/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -42,7 +42,7 @@ Given('I navigate to the authorize page with an invalid response type', async fu
4242
this.browser = await puppeteer.launch({
4343
ignoreHTTPSErrors: true,
4444
headless: true,
45-
args: ["--no-sandbox"]
45+
args: ["--no-sandbox", "--disable-gpu"]
4646
})
4747
this.page = await this.browser.newPage()
4848
return await this.page.goto('https://' + hostname + '/v1/openid-connect/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -53,7 +53,7 @@ Given('I navigate to the authorize page without a scope parameter', async functi
5353
this.browser = await puppeteer.launch({
5454
ignoreHTTPSErrors: true,
5555
headless: true,
56-
args: ["--no-sandbox"]
56+
args: ["--no-sandbox", "--disable-gpu"]
5757
})
5858
this.page = await this.browser.newPage()
5959
return await this.page.goto('https://' + hostname + '/v1/openid-connect/authorize?client_id=' + this.apickli.scenarioVariables.clientId
@@ -64,7 +64,7 @@ Given('I navigate to the authorize page without a state parameter', async functi
6464
this.browser = await puppeteer.launch({
6565
ignoreHTTPSErrors: true,
6666
headless: true,
67-
args: ["--no-sandbox"]
67+
args: ["--no-sandbox", "--disable-gpu"]
6868
})
6969
this.page = await this.browser.newPage()
7070
return await this.page.goto('https://' + hostname + '/v1/openid-connect/authorize?client_id=' + this.apickli.scenarioVariables.clientId

references/openapi-mock/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ apigeecli apis create bundle \
6060

6161
If you just need to quickly generate a mock API proxy from your OpenAPI 3 spec, the [apigee-go-gen](https://apigee.github.io/apigee-go-gen/installation/) tool can help.
6262

63-
The tool's [mock oas](https://apigee.github.io/apigee-go-gen/mock/mock-openapi-spec/) command automates the process, saving you time and effort.
63+
The tool's [mock oas](https://apigee.github.io/apigee-go-gen/mock/mock-openapi-description/) command automates the process, saving you time and effort.
6464

6565
Here is an example of how to generate a mock API proxy using the `apigee-go-gen` tool.
6666

tools/endpoints-oas-importer/import-endpoints.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function client_authentication() {
131131

132132
# normalizing yaml and json OAS file types
133133
if [[ $oas == *.yaml || $oas == *.yml ]]; then
134-
oas_json_content=$(yq -o json "$oas")
134+
oas_json_content=$(yq e -o json "$oas")
135135
elif [[ $oas == *.json ]]; then
136136
oas_json_content=$(cat "$oas")
137137
else

tools/pipeline-runner/Dockerfile

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2020 Google LLC
1+
# Copyright 2024 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -12,10 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
FROM google/cloud-sdk:alpine
15+
FROM google/cloud-sdk:alpine AS gcloud-sdk
16+
17+
FROM alpine:3.21
18+
19+
COPY --from=gcloud-sdk /google-cloud-sdk /google-cloud-sdk
20+
ENV PATH="/google-cloud-sdk/bin:${PATH}"
1621

1722
# Install additional tools
1823
RUN apk add --no-cache \
24+
bash \
25+
docker \
26+
git \
27+
curl \
1928
jq \
2029
libxml2-utils \
2130
maven \
@@ -38,7 +47,9 @@ RUN apk add --no-cache \
3847
zip \
3948
make \
4049
go \
41-
protobuf-dev
50+
yq \
51+
protobuf-dev \
52+
dbus
4253

4354
# Reduce nighly log (note: -ntp requires maven 3.6.1+)
4455
RUN mv /usr/bin/mvn /usr/bin/_mvn &&\
@@ -52,18 +63,11 @@ RUN chmod +x /usr/local/bin/claat
5263
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
5364
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser
5465

55-
RUN npm install --global [email protected]
66+
RUN npm install --global [email protected] [email protected]
5667

5768
# add our tooling scripts
5869
COPY *.sh /usr/bin/
5970

60-
# install apgieelint
61-
RUN npm install --global [email protected]
62-
63-
# yq because the apk is too old
64-
RUN wget -q -O /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/v4.29.2/yq_linux_amd64"
65-
RUN chmod +x /usr/local/bin/yq
66-
6771
# Run script
6872
WORKDIR /home
6973
CMD ["run-pipelines.sh"]

tools/pipeline-runner/cloudbuild.yaml

+22-4
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,37 @@ steps:
5656
args:
5757
- '-c'
5858
- |-
59+
set -e
5960
max_duration=8760 # cloud build timeout minus 4m
6061
if [ -n "$_PR_NUMBER" ]; then
61-
FULL_PIPELINE_REQUIRED=$(curl "https://api.github.com/repos/$_REPO_GH_ISSUE/issues/$_PR_NUMBER" | jq '.body |= ascii_downcase | .body | contains("[x] pr requires full pipeline run")' )
62-
PROJECTS=$(list-repo-changes.sh)
62+
PR_DATA="$(curl "https://api.github.com/repos/$_REPO_GH_ISSUE/issues/$_PR_NUMBER")"
63+
FULL_PIPELINE_REQUIRED=$(printf '%s' "$$PR_DATA" | jq '.body |= ascii_downcase | .body | contains("[x] pr requires full pipeline run")' )
64+
SELECTED_PROJECTS_FLAG=$(printf '%s' "$$PR_DATA" | jq '.body |= ascii_downcase | .body | contains("[x] test following projects (comma separated list):")')
65+
66+
# get a comma-separated list of folders of changed sub-projects
67+
CHANGED_PROJECTS=$(list-repo-changes.sh)
68+
69+
# test only explicity subset of projects
70+
if [ "$$SELECTED_PROJECTS_FLAG" = "true" ]; then
71+
PROJECTS=$(printf "$$PR_DATA" | grep -o -i -E "test following projects \(comma separated list\): *.*" | cut -d ':' -f 2 | tr -d '[:space:]')
72+
if [ -z "$$PROJECTS" ]; then
73+
echo "SELECTED PROJECTS is empty. Please provide a list"
74+
PROJECTS="$$CHANGED_PROJECTS"
75+
fi
76+
else
77+
PROJECTS=$$CHANGED_PROJECTS
78+
fi
79+
6380
if [ "$$FULL_PIPELINE_REQUIRED" = "true" ]; then
6481
echo "Running Full Pipeline as required in the PR"
6582
timeout "$$max_duration" run-pipelines.sh || true
66-
elif [ -z "$$PROJECTS"]; then
83+
elif [ -z "$$PROJECTS" ]; then
6784
echo "TOTAL PIPELINE (no change);pass;0" > ./pipeline-result.txt
6885
else
69-
echo "PR includes changes in $$PROJECTS"
86+
echo "PR testing changes in the following projects: $$PROJECTS"
7087
timeout "$$max_duration" run-pipelines.sh "$$PROJECTS" || true
7188
fi
89+
7290
elif [ "$_CI_PROJECT" = "all" ]; then
7391
timeout "$$max_duration" run-pipelines.sh || true
7492
else

tools/pipeline-runner/github-api.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
buildresult=$(cat)
2020

21-
REPORT_ROWS=$(echo "$buildresult" | awk -F";" '$0="|"$1"|"$2"|"$3"|"' OFS="|")
21+
REPORT_ROWS=$(echo "$buildresult" | awk -F\; -v OFS='|' '{gsub(/pass/, "✅"); gsub(/fail/, "❌"); print "|" $1 "|" $2 "|" $3 "|"}')
22+
2223
REPORT=$(cat <<EOF
2324
### Pipeline Report
2425

0 commit comments

Comments
 (0)