From 520c18dcec842f83f719e54828a66992315b3e36 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 3 Nov 2022 09:56:06 -0700 Subject: [PATCH] test: add owlbot nodejs container tests (#1693) --- docker/owlbot/nodejs/cloudbuild.yaml | 1 + docker/owlbot/nodejs/cloudbuild_test.yaml | 33 +++++++++++++++++++ docker/owlbot/nodejs/container_test.yaml | 8 +++++ .../owlbot/nodejs_mono_repo/cloudbuild.yaml | 1 + .../nodejs_mono_repo/cloudbuild_test.yaml | 33 +++++++++++++++++++ .../nodejs_mono_repo/container_test.yaml | 8 +++++ 6 files changed, 84 insertions(+) create mode 100644 docker/owlbot/nodejs/cloudbuild_test.yaml create mode 100644 docker/owlbot/nodejs/container_test.yaml create mode 100644 docker/owlbot/nodejs_mono_repo/cloudbuild_test.yaml create mode 100644 docker/owlbot/nodejs_mono_repo/container_test.yaml diff --git a/docker/owlbot/nodejs/cloudbuild.yaml b/docker/owlbot/nodejs/cloudbuild.yaml index 66d9d9019..2ea79a654 100644 --- a/docker/owlbot/nodejs/cloudbuild.yaml +++ b/docker/owlbot/nodejs/cloudbuild.yaml @@ -15,6 +15,7 @@ steps: sed -i "s/\!:/:/g" post-processor-changes.txt # Build the docker image. - name: 'gcr.io/cloud-builders/docker' + id: 'build' args: [ 'build', '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs:$SHORT_SHA', '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs:latest', diff --git a/docker/owlbot/nodejs/cloudbuild_test.yaml b/docker/owlbot/nodejs/cloudbuild_test.yaml new file mode 100644 index 000000000..da73e3c34 --- /dev/null +++ b/docker/owlbot/nodejs/cloudbuild_test.yaml @@ -0,0 +1,33 @@ +steps: + # Write the latest commit message to a file in the workspace. + - name: 'gcr.io/cloud-builders/git' + entrypoint: '/bin/sh' + args: + - '-c' + # Get the last commit in synthtool and write it to post-processor-changes.txt. + # If the commit message ends with parenthesis, remove them. + # If the commit message starts with feat or fix, replace it with chore. + # If the commit message includes ! followed by a colon to signal a breaking change, remove the !. + - > + git log -1 --format="%B%n%nSource-Link: https://github.com/googleapis/synthtool/commit/%H" > post-processor-changes.txt && + sed -i "s/([^()]*)$//g" post-processor-changes.txt && + sed -i "s/^\(feat\|fix\)/chore/g" post-processor-changes.txt && + sed -i "s/\!:/:/g" post-processor-changes.txt + # Build the docker image. + - name: 'gcr.io/cloud-builders/docker' + id: 'build' + args: [ 'build', + '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs:$SHORT_SHA', + '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs:latest', + '-t', 'gcr.io/cloud-devrel-public-resources/owlbot-nodejs:$SHORT_SHA', + '-t', 'gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest', + '-f', 'docker/owlbot/nodejs/Dockerfile', '.' ] + # Run container tests + - name: gcr.io/gcp-runtimes/container-structure-test + args: + - 'test' + - '--image' + - 'gcr.io/repo-automation-bots/owlbot-nodejs:$SHORT_SHA' + - '--config' + - 'docker/owlbot/nodejs/container_test.yaml' + waitFor: ['build'] diff --git a/docker/owlbot/nodejs/container_test.yaml b/docker/owlbot/nodejs/container_test.yaml new file mode 100644 index 000000000..ef043afc7 --- /dev/null +++ b/docker/owlbot/nodejs/container_test.yaml @@ -0,0 +1,8 @@ +schemaVersion: 1.0.0 +commandTests: +- name: "node" + command: ["node", "--version"] + expectedOutput: ["v15.14.0"] +- name: "python" + command: ["python", "--version"] + expectedOutput: ["Python 3.10.6"] diff --git a/docker/owlbot/nodejs_mono_repo/cloudbuild.yaml b/docker/owlbot/nodejs_mono_repo/cloudbuild.yaml index 2a9373e51..ca5f81209 100644 --- a/docker/owlbot/nodejs_mono_repo/cloudbuild.yaml +++ b/docker/owlbot/nodejs_mono_repo/cloudbuild.yaml @@ -15,6 +15,7 @@ steps: sed -i "s/\!:/:/g" post-processor-changes.txt # Build the docker image. - name: 'gcr.io/cloud-builders/docker' + id: 'build' args: [ 'build', '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo:$SHORT_SHA', '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo:latest', diff --git a/docker/owlbot/nodejs_mono_repo/cloudbuild_test.yaml b/docker/owlbot/nodejs_mono_repo/cloudbuild_test.yaml new file mode 100644 index 000000000..80e44916b --- /dev/null +++ b/docker/owlbot/nodejs_mono_repo/cloudbuild_test.yaml @@ -0,0 +1,33 @@ +steps: + # Write the latest commit message to a file in the workspace. + - name: 'gcr.io/cloud-builders/git' + entrypoint: '/bin/sh' + args: + - '-c' + # Get the last commit in synthtool and write it to post-processor-changes.txt. + # If the commit message ends with parenthesis, remove them. + # If the commit message starts with feat or fix, replace it with chore. + # If the commit message includes ! followed by a colon to signal a breaking change, remove the !. + - > + git log -1 --format="%B%n%nSource-Link: https://github.com/googleapis/synthtool/commit/%H" > post-processor-changes.txt && + sed -i "s/([^()]*)$//g" post-processor-changes.txt && + sed -i "s/^\(feat\|fix\)/chore/g" post-processor-changes.txt && + sed -i "s/\!:/:/g" post-processor-changes.txt + # Build the docker image. + - name: 'gcr.io/cloud-builders/docker' + id: 'build' + args: [ 'build', + '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo:$SHORT_SHA', + '-t', 'gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo:latest', + '-t', 'gcr.io/cloud-devrel-public-resources/owlbot-nodejs-mono-repo:$SHORT_SHA', + '-t', 'gcr.io/cloud-devrel-public-resources/owlbot-nodejs-mono-repo:latest', + '-f', 'docker/owlbot/nodejs_mono_repo/Dockerfile', '.' ] + # Run container tests + - name: gcr.io/gcp-runtimes/container-structure-test + args: + - 'test' + - '--image' + - 'gcr.io/repo-automation-bots/owlbot-nodejs-mono-repo:$SHORT_SHA' + - '--config' + - 'docker/owlbot/nodejs_mono_repo/container_test.yaml' + waitFor: ['build'] diff --git a/docker/owlbot/nodejs_mono_repo/container_test.yaml b/docker/owlbot/nodejs_mono_repo/container_test.yaml new file mode 100644 index 000000000..ef043afc7 --- /dev/null +++ b/docker/owlbot/nodejs_mono_repo/container_test.yaml @@ -0,0 +1,8 @@ +schemaVersion: 1.0.0 +commandTests: +- name: "node" + command: ["node", "--version"] + expectedOutput: ["v15.14.0"] +- name: "python" + command: ["python", "--version"] + expectedOutput: ["Python 3.10.6"]