Skip to content

Commit 5afebc1

Browse files
authored
Merge pull request #69848 from aireilly/add-prow-tools
Adding new prow job script tool and docs
2 parents 33b0a41 + b02726a commit 5afebc1

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed

scripts/prow/README.adoc

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
= Creating Prow jobs for openshift-docs branches
2+
3+
Use the `add-new-prow-config.sh` script to populate the `$HOME/release/ci-operator/config/openshift/openshift-docs` directory with a new Prow job branch configuration.
4+
The script uses the `./openshift-openshift-docs-BRANCH.yaml` template file to create the new job config.
5+
After you create the job config, you run the CI make jobs to create the Prow jobs.
6+
Then, open a pull request against the link:[email protected]:openshift/release.git[openshift/release] repository to make the Prow job live for that branch.
7+
8+
To add a new job to Prow CI, do the following:
9+
10+
. Install link:https://podman.io/docs/installation[podman].
11+
12+
. Fork and clone the link:[email protected]:openshift/release.git[openshift/release] repository to `$HOME/release`.
13+
14+
. Create the new branch config by running the `add-new-prow-config.sh` script passing the `$VERSION`, `$BRANCH` and `$DISTROS` variables.
15+
Open a shell prompt in the `openshift-docs/` directory, and run the script passing in the required variables, for example:
16+
+
17+
[source,terminal]
18+
----
19+
./scripts/prow/add-new-prow-config.sh 4.15 enterprise-4.15 "openshift-enterprise openshift-rosa openshift-dedicated microshift"
20+
----
21+
+
22+
[NOTE]
23+
====
24+
Quote multiple distros to include them as a single item in the build config.
25+
====
26+
+
27+
The script copies the new job YAML to the ci-operator config folder in the `$HOME/release` directory.
28+
+
29+
[IMPORTANT]
30+
====
31+
`openshift-rosa` and `openshift-osd` distros should be included in main, current, and future enterprise branch builds only.
32+
When you add a new enterprise branch, remember to remove `openshift-rosa` and `openshift-osd` distros from the most recent enterprise branch.
33+
34+
For example, when the current version is 4.15, and you create a enterprise-4.16 branch, remove `openshift-rosa` and `openshift-osd` distros from the enterprise-4.15 branch build.
35+
====
36+
37+
. Change to the `$HOME/release` directory and verify that the new build config has been added. For example:
38+
+
39+
[source,text]
40+
----
41+
$HOME/release/ci-operator/config/openshift/openshift-docs/openshift-openshift-docs-enterprise-4.15.yaml
42+
----
43+
44+
. Run the following commands from the root of the `$HOME/release` repository to generate the rest of the Prow build configuration:
45+
+
46+
[source,terminal]
47+
----
48+
make prow-config CONTAINER_ENGINE=podman WHAT=openshift/openshift-docs
49+
50+
make CONTAINER_ENGINE=podman ci-operator-config WHAT=openshift/openshift-docs
51+
52+
make jobs CONTAINER_ENGINE=podman WHAT=openshift/openshift-docs
53+
----
54+
55+
. Open a PR against the link:https://github.com/openshift/release[openshift/release] `master` branch.
56+
Ensure that all Prow CI tests pass. Add a `/pj-rehearse` comment in the pull request to verify the new build.
57+
58+
. Get an `/lgtm` approval from someone in the openshift-docs link:https://github.com/openshift/release/blob/master/ci-operator/config/openshift/openshift-docs/OWNERS[OWNERS] file.
59+
60+
. When you want to schedule the job for merge, add a `/pj-rehearse ack` comment to the pull request.
61+
The PR is merged automatically when all required approvals are provided and the PR passes all the required CI jobs.
62+
When the PR is merged, the job goes live on the relevant openshift-docs branch PRs.
63+
+
64+
[NOTE]
65+
====
66+
Rebase often on the release branch when you open a pull request.
67+
The repository is very busy and the underlying infrastructure changes daily.
68+
Every time you rebase, rerun the CI make jobs.
69+
====
70+
71+
For more information, see: link:https://docs.ci.openshift.org/docs/how-tos/contributing-openshift-release/[Contributing CI configuration to the openshift/release repository]

scripts/prow/add-new-prow-config.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# Script to update Prow configuration
4+
5+
# Check if required parameters are provided
6+
if [ $# -lt 3 ]; then
7+
echo "Provide values for \$VERSION \$BRANCH \$DISTROS"
8+
exit 1
9+
fi
10+
11+
# Assign input parameters to variables
12+
VERSION=$1
13+
BRANCH=$2
14+
DISTROS=$3
15+
16+
# Export variables for use in subshells
17+
export VERSION BRANCH DISTROS
18+
19+
# Define folder path
20+
folder="$(git rev-parse --show-toplevel)/scripts/prow"
21+
22+
# Check if the scripts/prow directory exists
23+
if [ ! -d "$folder" ]; then
24+
echo "The scripts/prow directory does not exist. Make sure your repository structure is correct."
25+
exit 1
26+
fi
27+
28+
# Define template and new Prow config paths
29+
template="${folder}/openshift-openshift-docs-BRANCH.yaml"
30+
new_prow_config="${folder}/openshift-openshift-docs-${BRANCH}.yaml"
31+
32+
# Check if the release directory exists
33+
if [ -d "$HOME/release" ]; then
34+
# Create a new Prow config using environment variables
35+
envsubst < "$template" > "$new_prow_config"
36+
37+
# Copy the new Prow config to the release directory
38+
cp "$new_prow_config" "$HOME/release/ci-operator/config/openshift/openshift-docs/"
39+
40+
# Remove the temporary Prow config file
41+
rm "$new_prow_config"
42+
43+
echo "New Prow job created: $HOME/release/ci-operator/config/openshift/openshift-docs/$(basename "$new_prow_config")"
44+
else
45+
echo "Fork and clone the [email protected]:openshift/release.git repo to $HOME/release and run the script again"
46+
exit 1
47+
fi
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
build_root:
2+
image_stream_tag:
3+
name: openshift-docs-asciidoc
4+
namespace: ocp
5+
tag: latest
6+
use_build_cache: true
7+
resources:
8+
'*':
9+
limits:
10+
memory: 4Gi
11+
requests:
12+
cpu: 200m
13+
memory: 400Mi
14+
tests:
15+
- as: deploy-preview
16+
steps:
17+
env:
18+
DISTROS: ${DISTROS}
19+
PREVIEW_SITE: ocpdocs-pr
20+
test:
21+
- ref: openshift-docs-build-docs
22+
- ref: openshift-docs-preview-comment
23+
- as: validate-asciidoc
24+
steps:
25+
env:
26+
BUILD: build.py
27+
DISTROS: ${DISTROS}
28+
VERSION: "${VERSION}"
29+
test:
30+
- ref: openshift-docs-asciidoctor
31+
- ref: openshift-docs-lint-topicmaps
32+
- ref: openshift-docs-portal
33+
zz_generated_metadata:
34+
branch: ${BRANCH}
35+
org: openshift
36+
repo: openshift-docs

0 commit comments

Comments
 (0)