|
| 1 | +#### Setting up Component Builds in Konflux on New Branch |
| 2 | + |
| 3 | +**Prerequisites:** |
| 4 | + |
| 5 | +- Configuration added in konflux-ci/build-definitions repo |
| 6 | +- Existing Konflux-configured branch to copy files from (e.g., `release-0.21`) |
| 7 | + |
| 8 | +**Placeholders:** |
| 9 | +- `<target-branch>`: Your target branch (e.g., `release-0.22`) |
| 10 | +- `<X-Y>`: Version with dashes (e.g., `0-22`) |
| 11 | +- `<component>`: Component name (gateway, globalnet, or route-agent) |
| 12 | + |
| 13 | +**Repeat steps 1-9 for each component:** |
| 14 | + |
| 15 | +##### 1. Checkout Bot's PR Branch |
| 16 | + |
| 17 | +Bot creates PRs on branches named `konflux-submariner-<component>-<X-Y>`. |
| 18 | + |
| 19 | +```bash |
| 20 | +git checkout konflux-submariner-<component>-<X-Y> |
| 21 | +``` |
| 22 | + |
| 23 | +##### 2. Configure YAMLlint to Ignore Generated Directories |
| 24 | + |
| 25 | +Add `.tekton` and `.rpm-lockfiles` to yamllint ignore list (idempotent, preserves existing rules). |
| 26 | + |
| 27 | +```bash |
| 28 | +grep -q "\.tekton" .yamllint.yml || sed -i '/^ignore: |$/a\ .tekton' .yamllint.yml |
| 29 | +grep -q "\.rpm-lockfiles" .yamllint.yml || sed -i '/^ignore: |$/a\ .rpm-lockfiles' .yamllint.yml |
| 30 | +git add .yamllint.yml |
| 31 | +git commit -s -m "Configure yamllint to ignore .tekton and .rpm-lockfiles" |
| 32 | +``` |
| 33 | + |
| 34 | +##### 3. Add RPM Lockfile Support |
| 35 | + |
| 36 | +```bash |
| 37 | +# Extract target version once, validate once, derive previous version |
| 38 | +TARGET_VERSION=$(echo "<target-branch>" | grep -oP '(?<=release-0\.)\d+$') |
| 39 | +[ -z "$TARGET_VERSION" ] && { echo "ERROR: Invalid target branch format. Expected release-0.XX"; exit 1; } |
| 40 | +PREV_VERSION=$((TARGET_VERSION - 1)) |
| 41 | +git checkout origin/release-0.${PREV_VERSION} -- .rpm-lockfiles/update-lockfile.sh .rpm-lockfiles/<component>/ |
| 42 | +chmod +x .rpm-lockfiles/update-lockfile.sh |
| 43 | +.rpm-lockfiles/update-lockfile.sh <component> |
| 44 | +ls .rpm-lockfiles/<component>/rpms.lock.yaml || { echo "ERROR: Lockfile generation failed"; exit 1; } |
| 45 | +git add .rpm-lockfiles/ |
| 46 | +git commit -s -m "Add RPM lockfile support for <component>" |
| 47 | +``` |
| 48 | + |
| 49 | +**Note:** Script copied per-component; Git deduplicates on merge. |
| 50 | + |
| 51 | +##### 4. Add Konflux Dockerfile and Configure Tekton to Use It |
| 52 | + |
| 53 | +```bash |
| 54 | +# Extract target version once, validate once, derive all version values |
| 55 | +# Formula: Submariner 0.X → ACM 2.(X-7), so 0.22 → 2.15 |
| 56 | +TARGET_VERSION=$(echo "<target-branch>" | grep -oP '(?<=release-0\.)\d+$') |
| 57 | +[ -z "$TARGET_VERSION" ] && { echo "ERROR: Invalid target branch format. Expected release-0.XX"; exit 1; } |
| 58 | +PREV_VERSION=$((TARGET_VERSION - 1)) |
| 59 | +ACM_VERSION=$((TARGET_VERSION - 7)) |
| 60 | + |
| 61 | +git checkout origin/release-0.${PREV_VERSION} -- package/Dockerfile.submariner-<component>.konflux |
| 62 | +sed -i "s/release-0.${PREV_VERSION}/<target-branch>/g" package/Dockerfile.submariner-<component>.konflux |
| 63 | +sed -i "s/cpe=\"cpe:\/a:redhat:acm:[0-9.]*::el9\"/cpe=\"cpe:\/a:redhat:acm:2.${ACM_VERSION}::el9\"/" package/Dockerfile.submariner-<component>.konflux |
| 64 | + |
| 65 | +sed -i 's|package/Dockerfile.submariner-<component>|package/Dockerfile.submariner-<component>.konflux|g' .tekton/*.yaml |
| 66 | +git add package/Dockerfile.submariner-<component>.konflux .tekton/*.yaml |
| 67 | +git commit -s -m "Add Konflux dockerfile for <component> and configure tekton to use it" |
| 68 | +``` |
| 69 | + |
| 70 | +##### 5. Enable Hermetic Builds |
| 71 | + |
| 72 | +```bash |
| 73 | +# Only add if not already present (idempotent) |
| 74 | +# Check for hermetic in spec.params (not pipelineSpec.params definitions) |
| 75 | +if ! grep -q "^ - name: hermetic$" .tekton/*.yaml; then |
| 76 | + sed -i '/^ pipelineSpec:$/i\ - name: prefetch-input\n value: '\''[{"type": "gomod", "path": "."}, {"type": "gomod", "path": "tools"}, {"type": "rpm", "path": "./.rpm-lockfiles/<component>"}]'\''\n - name: hermetic\n value: "true"' .tekton/*.yaml |
| 77 | +fi |
| 78 | +git add .tekton/*.yaml |
| 79 | +git commit -s -m "Enable hermetic builds with gomod and RPM prefetching for <component>" |
| 80 | +``` |
| 81 | + |
| 82 | +##### 6. Add Multi-Platform Support |
| 83 | + |
| 84 | +```bash |
| 85 | +# Only add if not already present (idempotent) |
| 86 | +grep -q "linux/arm64" .tekton/*.yaml || sed -i '/^ - linux\/x86_64$/a\ - linux/arm64' .tekton/*.yaml |
| 87 | +git add .tekton/*.yaml |
| 88 | +git commit -s -m "Add multi-platform build support for <component>" |
| 89 | +``` |
| 90 | + |
| 91 | +##### 7. Enable SBOM Generation |
| 92 | + |
| 93 | +```bash |
| 94 | +# Only add if not already present (idempotent) |
| 95 | +# Check for build-source-image in spec.params (not pipelineSpec.params definitions) |
| 96 | +if ! grep -q "^ - name: build-source-image$" .tekton/*.yaml; then |
| 97 | + sed -i '/ - name: hermetic$/,/ value: "true"$/{/ value: "true"$/a\ - name: build-source-image\n value: "true" |
| 98 | +}' .tekton/*.yaml |
| 99 | +fi |
| 100 | +git add .tekton/*.yaml |
| 101 | +git commit -s -m "Enable SBOM generation for <component>" |
| 102 | +``` |
| 103 | + |
| 104 | +##### 8. Update Task References |
| 105 | + |
| 106 | +```bash |
| 107 | +bash << 'EOF' |
| 108 | +set -e |
| 109 | +
|
| 110 | +PATCHER_SHA="b001763bb1cd0286a894cfb570fe12dd7f4504bd" |
| 111 | +EXPECTED_SHA256="080ad5d7cf7d0cee732a774b7e4dda0e2ccf26b58e08a8516a3b812bc73beb53" |
| 112 | +
|
| 113 | +SCRIPT=$(curl -sL "https://raw.githubusercontent.com/simonbaird/konflux-pipeline-patcher/${PATCHER_SHA}/pipeline-patcher") |
| 114 | +ACTUAL_SHA256=$(echo "$SCRIPT" | sha256sum | cut -d' ' -f1) |
| 115 | +
|
| 116 | +if [[ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]]; then |
| 117 | + echo "ERROR: Script checksum mismatch!" |
| 118 | + exit 1 |
| 119 | +fi |
| 120 | +
|
| 121 | +echo "$SCRIPT" | bash -s bump-task-refs |
| 122 | +EOF |
| 123 | +git diff --quiet .tekton/*.yaml || { git add .tekton/*.yaml && git commit -s -m "Update Tekton task references to latest versions for <component>"; } |
| 124 | +``` |
| 125 | + |
| 126 | +**Note:** Updates task references if outdated. |
| 127 | + |
| 128 | +##### 9. Review and Push |
| 129 | + |
| 130 | +```bash |
| 131 | +git log origin/<target-branch>..HEAD |
| 132 | +git status |
| 133 | +git push |
| 134 | +``` |
| 135 | + |
| 136 | +Expected: 7-8 commits (bot's initial + 6-7 from steps 2-8), clean working tree. |
| 137 | + |
| 138 | +##### 10. Verify All Component PRs |
| 139 | + |
| 140 | +After completing all 3 components: |
| 141 | + |
| 142 | +```bash |
| 143 | +for component in gateway globalnet route-agent; do |
| 144 | + gh pr list --head konflux-submariner-$component-<X-Y> |
| 145 | +done |
| 146 | +``` |
| 147 | + |
| 148 | +Expected: 3 PRs (one per component). |
0 commit comments