Skip to content

gcloud setup test pipeline

devonfw-core edited this page Dec 27, 2022 · 3 revisions

Setting up a Test pipeline on Google Cloud

In this section we will create a test pipeline on Google Cloud for running project test cases. This pipeline will be configured in order to be triggered every time the build pipeline is executed successfully on a commit, and consumes the artifact produced by the build pipeline.

The creation of this pipeline will follow the project workflow, so a new branch named feature/test-pipeline will be created and the YAML file for the pipeline will be pushed to it.

Then, the new branch will be merged into the appropriate branch (provided in -b flag).

The script located at /scripts/pipelines/gcloud/pipeline_generator.sh will automatically create new branch, create a test pipeline based on a YAML template appropriate for the project programming language or framework, create the Pull Request, and if it is possible, merge this new branch into the specified branch.

Prerequisites

  • This script will commit and push the corresponding YAML template into your repository, so please be sure your local repository is up-to-date (i.e you have pulled latest changes with git pull).

  • [Optional] Having some knowledge about the application, in particular knowing if, when tested, it produces a log file or some other blob (e.g. performance profiling data) interesting to be kept as an artifact.

Creating the pipeline using provided script

Usage

pipeline_generator.sh \
  -c <config file path> \
  -n <{pipeline_type} name> \
  -l <language or framework> \
  -d <project local path> \
  --build-pipeline-name <build {pipeline_type} name> \
  [--language-version <version>] \
  [-a <artifact source path>] \
  [-b <branch>] \
  [-m <machine type for {pipeline_type} runner>]
  [--env-vars <env vars list>]
  [--secret-vars <secret vars list>]
Note
The config file for the test pipeline is located at /scripts/pipelines/gcloud/templates/test/test-pipeline.cfg.

Flags

-c, --config-file           [Required] Configuration file containing {pipeline_type} definition.
-n, --pipeline-name         [Required] Name that will be set to the {pipeline_type}.
-l, --language              [Required] Language or framework of the project.
-d, --local-directory       [Required] Local directory of your project.
    --build-pipeline-name   [Required] Build {pipeline_type} name.
    --language-version      [Required, if Flutter or Python] Language or framework version.
-a, --artifact-path                    Path to be persisted as an artifact after {pipeline_type} execution, e.g. where the application stores logs or any other blob on runtime.
-b, --target-branch                    Name of the branch to which the Pull Request will target. PR is not created if the flag is not provided.
-m, --machine-type                     Machine type for {pipeline_type} runner. Accepted values: E2_HIGHCPU_8, E2_HIGHCPU_32, N1_HIGHCPU_8, N1_HIGHCPU_32.
    --env-vars                         List of environment variables to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".
    --secret-vars                      List of environment variables (saved as secrets in Secret Manager) to be made available in pipeline. Syntax: "var1=val1 var2=val2 ...".

Examples

Quarkus project

Quarkus native project
./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n quarkus-project-test -l quarkus -d C:/Users/$USERNAME/Desktop/quarkus-project {extra_args_quarkus} -b develop {openBrowserFlag}
Quarkus project using JVM
./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n quarkus-project-test -l quarkus-jvm -d C:/Users/$USERNAME/Desktop/quarkus-project {extra_args_quarkus} -b develop {openBrowserFlag}

Node.js project

./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n node-project-test -l node -d C:/Users/$USERNAME/Desktop/node-project {extra_args_node} -b develop {openBrowserFlag}

Angular project

./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n angular-project-test -l angular -d C:/Users/$USERNAME/Desktop/node-project {extra_args_angular} -b develop {openBrowserFlag}

Python project

./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n python-project-test -l python -d C:/Users/$USERNAME/Desktop/python-project {extra_args_python} -b develop {openBrowserFlag}

Flutter project

./pipeline_generator.sh -c ./templates/test/test-pipeline.cfg -n flutter-project-test -l flutter -d C:/Users/$USERNAME/Desktop/flutter-project {extra_args_flutter} -b develop {openBrowserFlag}

Guides per provider

Clone this wiki locally