Skip to content

Commit

Permalink
feat: allow for selective pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
danistrebel committed Dec 20, 2024
1 parent a4c4f8d commit 506aebc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion tools/endpoints-oas-importer/import-endpoints.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function client_authentication() {

# normalizing yaml and json OAS file types
if [[ $oas == *.yaml || $oas == *.yml ]]; then
oas_json_content=$(yq -o json "$oas")
oas_json_content=$(yq e -o json "$oas")
elif [[ $oas == *.json ]]; then
oas_json_content=$(cat "$oas")
else
Expand Down
12 changes: 3 additions & 9 deletions tools/pipeline-runner/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -46,6 +46,7 @@ RUN apk add --no-cache \
zip \
make \
go \
yq \
protobuf-dev

# Reduce nighly log (note: -ntp requires maven 3.6.1+)
Expand All @@ -60,18 +61,11 @@ RUN chmod +x /usr/local/bin/claat
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser

RUN npm install --global [email protected]
RUN npm install --global [email protected] [email protected]

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

# install apgieelint
RUN npm install --global [email protected]

# yq because the apk is too old
RUN wget -q -O /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/v4.29.2/yq_linux_amd64"
RUN chmod +x /usr/local/bin/yq

# Run script
WORKDIR /home
CMD ["run-pipelines.sh"]
17 changes: 15 additions & 2 deletions tools/pipeline-runner/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,23 @@ steps:
args:
- '-c'
- |-
set -e
max_duration=8760 # cloud build timeout minus 4m
if [ -n "$_PR_NUMBER" ]; then
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")' )
PROJECTS=$(list-repo-changes.sh)
PR_DATA="$(curl "https://api.github.com/repos/$_REPO_GH_ISSUE/issues/$_PR_NUMBER")"
FULL_PIPELINE_REQUIRED=$(printf '%s' "$$PR_DATA" | jq '.body |= ascii_downcase | .body | contains("[x] pr requires full pipeline run")' )
SELECTED_PROJECTS_FLAG=$(printf '%s' "$$PR_DATA" | jq '.body |= ascii_downcase | .body | contains("[x] test following projects (comma separated list):")')
CHANGED_PROJECTS=$(list-repo-changes.sh)
if [ "$$SELECTED_PROJECTS_FLAG" = "true" ]; then
PROJECTS=$(printf "$$PR_DATA" | grep -o -i -E "test following projects \(comma separated list\): *.*" | cut -d ':' -f 2 | tr -d '[:space:]')
if [[ -z "$$PROJECTS" ]]; then
echo "SELECTED PROJECTS is empty. Please provide a list"
PROJECTS="$$CHANGED_PROJECTS"
fi
else
PROJECTS=$$CHANGED_PROJECTS
if [ "$$FULL_PIPELINE_REQUIRED" = "true" ]; then
echo "Running Full Pipeline as required in the PR"
timeout "$$max_duration" run-pipelines.sh || true
Expand Down

0 comments on commit 506aebc

Please sign in to comment.