Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mkpjpod demos #2928

Merged
merged 2 commits into from
Mar 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ci-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
47 changes: 29 additions & 18 deletions hack/mkpjpod.sh
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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