From 26f72f4beb26e4c4c57dd76035941767583a062c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Barcarol=20Guimar=C3=A3es?= Date: Wed, 20 Feb 2019 12:03:50 +0000 Subject: [PATCH 1/2] hack/mkpjpod.sh: defaulting, general improvements --- hack/mkpjpod.sh | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/hack/mkpjpod.sh b/hack/mkpjpod.sh index 79ebb5a09fbb..d1d6c5d64bdc 100755 --- a/hack/mkpjpod.sh +++ b/hack/mkpjpod.sh @@ -1,7 +1,13 @@ #!/bin/bash # Create a pod from a Prow job using the test-infra mkpj and mkpod utilities. -# Requires the following environment variables (see the pj_env.py script for a -# way to set them automatically): +# The required information about the pull request can be passed in a few +# different ways: +# +# 1. Passing the pull request number as the only argument. `mkpj`'s defaulting +# behavior will use Github's API to fetch the required information. +# Convenient, but has been victim of API throttling in the past. +# 2. Passing the required information as environment variables. See the +# `pj_env.py` script for a way to set them using `git`. The variables are: # # - BASE_REF # - BASE_SHA @@ -10,19 +16,24 @@ # - PULL_AUTHOR set -euo pipefail -if [[ "$#" -ne 1 ]]; then - echo >&2 "Usage: $0 job_name" - exit 1 -fi -job=$1 -img=registry.svc.ci.openshift.org/ci/test-infra:binaries -docker run --rm -iv "$PWD:/tmp/release:z" -w /tmp/release "$img" bash <<-EOF - /go/bin/mkpj \ - --config-path cluster/ci/config/prow/config.yaml \ - --job-config-path ci-operator/jobs/ \ - --job "$job" \ - --base-ref "$BASE_REF" --base-sha "$BASE_SHA" \ - --pull-number "$PULL_NUMBER" --pull-sha "$PULL_SHA" \ - --pull-author "$PULL_AUTHOR" \ - | /go/bin/mkpod --prow-job - -EOF +run() { + docker run \ + --rm \ + --volume "$PWD:/tmp/release:z" \ + --volume ~/go/bin:/go/bin:z \ + --workdir /tmp/release \ + registry.svc.ci.openshift.org/ci/test-infra:binaries \ + bash -c '/go/bin/mkpj "$@" | /go/bin/mkpod --prow-job -' -- \ + --config-path cluster/ci/config/prow/config.yaml \ + --job-config-path ci-operator/jobs/ \ + "$@" +} + +case "$#" in +1) run --job "$1" \ + --base-ref "$BASE_REF" --base-sha "$BASE_SHA" \ + --pull-number "$PULL_NUMBER" --pull-sha "$PULL_SHA" \ + --pull-author "$PULL_AUTHOR";; +2) run --job "$1" --pull-number "$2";; +*) echo >&2 "Usage: $0 job_name [pull_number]"; exit 1;; +esac From e95bb62f1e18198ac54b1ccb4dc15f759221f1ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Barcarol=20Guimar=C3=A3es?= Date: Thu, 21 Feb 2019 13:24:28 +0000 Subject: [PATCH 2/2] asciinema demos --- ci-operator/README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ci-operator/README.md b/ci-operator/README.md index f37500bf9bd1..2f299da85c2e 100644 --- a/ci-operator/README.md +++ b/ci-operator/README.md @@ -320,10 +320,13 @@ available in the `registry.svc.ci.openshift.org/ci/test-infra:binaries` image or in the [upstream repository](https://github.com/kubernetes/test-infra/tree/master/prow/cmd#dev-tools). The [`mkpjpod.sh`](../hack/mkpjpod.sh) script can be used to streamline that -process. It expects information about the base and pull request git references -to be passed via environment variables, which can be set manually or using the -[`pj_env.py`](../hack/pj_env.py) helper script (check the script files for -detailed information). +process. See the documentation in the script file and the following screencasts +for details: + +- Basic usage of the script to reproduce container and template tests: + [![asciicast](https://asciinema.org/a/231019.svg)](https://asciinema.org/a/231019) +- Making changes to the job or ci-operator configuration file: + [![asciicast](https://asciinema.org/a/231020.svg)](https://asciinema.org/a/231020) The output of the script is a regular Pod that can be executed in the staging namespace in the [CI cluster](https://api.ci.openshift.org) and will report the