Skip to content

Commit bd995ae

Browse files
committed
RANCHER-2751 Enable CI pipeline for release branches in platform-lsp
1 parent 7fbdc31 commit bd995ae

File tree

7 files changed

+148
-162
lines changed

7 files changed

+148
-162
lines changed

.github/actions/calculate-version-increment/action.yml

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ inputs:
1010
description: 'Whether changes were detected (true/false)'
1111
required: true
1212
version_pattern:
13-
description: 'Regex pattern for version matching (default: FOLIO pattern R<iteration>-<year>.<patch>)'
13+
description: 'Regex pattern for version matching (default: FOLIO pattern R<iteration>-<year>[-<suffix>].<patch>)'
1414
required: false
15-
default: '^(R[0-9]+-[0-9]+)\.([0-9]+)$'
15+
default: '^(R[0-9]+-[0-9]+)(-[a-z0-9-]+)?\.([0-9]+)$'
1616
increment_type:
1717
description: 'Type of increment to apply (currently only "patch" is supported)'
1818
required: false
@@ -32,48 +32,48 @@ outputs:
3232
runs:
3333
using: 'composite'
3434
steps:
35-
- name: 'Calculate version increment'
36-
id: calculate
37-
shell: bash
38-
env:
39-
CURRENT_VERSION: ${{ inputs.current_version }}
40-
CHANGES_DETECTED: ${{ inputs.changes_detected }}
41-
VERSION_PATTERN: ${{ inputs.version_pattern }}
42-
INCREMENT_TYPE: ${{ inputs.increment_type }}
43-
run: |
44-
set -euo pipefail
45-
IFS=$'\n\t'
35+
- name: 'Calculate version increment'
36+
id: calculate
37+
shell: bash
38+
env:
39+
CURRENT_VERSION: ${{ inputs.current_version }}
40+
CHANGES_DETECTED: ${{ inputs.changes_detected }}
41+
VERSION_PATTERN: ${{ inputs.version_pattern }}
42+
INCREMENT_TYPE: ${{ inputs.increment_type }}
43+
run: |
44+
set -euo pipefail
45+
IFS=$'\n\t'
4646
47-
UPDATED=false
48-
FAILURE_REASON=''
49-
NEW_VERSION="$CURRENT_VERSION"
47+
UPDATED=false
48+
FAILURE_REASON=''
49+
NEW_VERSION="$CURRENT_VERSION"
5050
51-
if [ "$CHANGES_DETECTED" = 'true' ]; then
52-
if [[ "$CURRENT_VERSION" =~ $VERSION_PATTERN ]]; then
53-
BASE_VERSION="${BASH_REMATCH[1]}"
54-
PATCH_VERSION="${BASH_REMATCH[2]}"
51+
if [ "$CHANGES_DETECTED" = 'true' ]; then
52+
if [[ "$CURRENT_VERSION" =~ $VERSION_PATTERN ]]; then
53+
# Group 1: R1-2025, Group 2: -ci|-csp5|-path|etc (optional), Group 3: patch number
54+
BASE_VERSION="${BASH_REMATCH[1]}${BASH_REMATCH[2]}"
55+
PATCH_VERSION="${BASH_REMATCH[3]}"
5556
56-
case "$INCREMENT_TYPE" in
57-
patch)
58-
NEW_VERSION="${BASE_VERSION}.$((PATCH_VERSION + 1))"
59-
UPDATED=true
60-
echo "::notice::Calculated new version $NEW_VERSION from previous $CURRENT_VERSION"
61-
;;
62-
*)
63-
FAILURE_REASON="Unsupported increment type: $INCREMENT_TYPE"
64-
echo "::warning::$FAILURE_REASON"
65-
;;
66-
esac
67-
else
68-
FAILURE_REASON="Previous version '$CURRENT_VERSION' does not match expected format 'R<iteration>-<year>.<patch>'"
69-
echo "::warning::$FAILURE_REASON (no update applied)"
70-
UPDATED=false
71-
fi
57+
case "$INCREMENT_TYPE" in
58+
patch)
59+
NEW_VERSION="${BASE_VERSION}.$((PATCH_VERSION + 1))"
60+
UPDATED=true
61+
echo "::notice::Calculated new version $NEW_VERSION from previous $CURRENT_VERSION"
62+
;;
63+
*)
64+
FAILURE_REASON="Unsupported increment type: $INCREMENT_TYPE"
65+
echo "::warning::$FAILURE_REASON"
66+
;;
67+
esac
7268
else
73-
echo '::notice::No component/application changes detected; version unchanged'
69+
FAILURE_REASON="Previous version '$CURRENT_VERSION' does not match expected format 'R<iteration>-<year>[-<suffix>].<patch>'"
70+
echo "::warning::$FAILURE_REASON (no update applied)"
71+
UPDATED=false
7472
fi
73+
else
74+
echo '::notice::No component/application changes detected; version unchanged'
75+
fi
7576
76-
echo "updated=$UPDATED" >> "$GITHUB_OUTPUT"
77-
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
78-
echo "failure_reason=$FAILURE_REASON" >> "$GITHUB_OUTPUT"
79-
77+
echo "updated=$UPDATED" >> "$GITHUB_OUTPUT"
78+
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
79+
echo "failure_reason=$FAILURE_REASON" >> "$GITHUB_OUTPUT"
Lines changed: 75 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
name: 'Check Branch and PR Status'
2-
description: 'Determines source branch and checks for existing pull request'
2+
description: 'Determines source branch, update branch, and checks for existing pull request'
33
author: 'FOLIO DevOps'
44

5+
branding:
6+
icon: 'git-branch'
7+
color: 'blue'
8+
59
inputs:
610
repo:
7-
description: 'Repository in org/repo format'
11+
description: 'Repository in org/repo format (e.g., folio-org/platform-lsp)'
812
required: true
913
release_branch:
10-
description: 'Base release branch name'
14+
description: 'Base release branch name (e.g., R1-2025)'
1115
required: true
1216
update_branch:
13-
description: 'Update branch name to check'
17+
description: 'Update branch name to check (e.g., R1-2025-update)'
1418
required: true
1519
github_token:
16-
description: 'GitHub token for API access'
20+
description: 'GitHub token for API access with repo scope'
1721
required: false
1822
default: ${{ github.token }}
23+
fail_on_orphan_branch:
24+
description: 'Fail if update branch exists without an associated PR (default: true)'
25+
required: false
26+
default: 'true'
1927

2028
outputs:
2129
source_branch:
@@ -37,53 +45,73 @@ outputs:
3745
runs:
3846
using: 'composite'
3947
steps:
40-
- name: 'Check branch and PR status'
41-
id: check
42-
shell: bash
43-
env:
44-
GH_TOKEN: ${{ inputs.github_token }}
45-
REPO: ${{ inputs.repo }}
46-
RELEASE_BRANCH: ${{ inputs.release_branch }}
47-
UPDATE_BRANCH: ${{ inputs.update_branch }}
48-
run: |
49-
set -euo pipefail
50-
IFS=$'\n\t'
48+
- name: 'Check branch and PR status'
49+
id: check
50+
shell: bash
51+
env:
52+
GH_TOKEN: ${{ inputs.github_token }}
53+
REPO: ${{ inputs.repo }}
54+
RELEASE_BRANCH: ${{ inputs.release_branch }}
55+
UPDATE_BRANCH: ${{ inputs.update_branch }}
56+
FAIL_ON_ORPHAN: ${{ inputs.fail_on_orphan_branch }}
57+
run: |
58+
set -euo pipefail
59+
IFS=$'\n\t'
5160
52-
# Check if update branch exists
53-
echo "::notice::Checking if update branch exists: $UPDATE_BRANCH"
54-
if gh api "repos/$REPO/branches/$UPDATE_BRANCH" >/dev/null 2>&1; then
55-
echo "::notice::Update branch exists, will scan: $UPDATE_BRANCH"
56-
echo "source_branch=$UPDATE_BRANCH" >> "$GITHUB_OUTPUT"
57-
echo "update_branch_exists=true" >> "$GITHUB_OUTPUT"
61+
# Validate inputs
62+
if [[ ! "$REPO" =~ ^[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+$ ]]; then
63+
echo "::error::Invalid repo format: '$REPO'. Expected format: org/repo"
64+
exit 1
65+
fi
5866
59-
# Check for existing PR
60-
echo "::notice::Checking for existing PR from $UPDATE_BRANCH to $RELEASE_BRANCH"
61-
pr_json=$(gh pr list \
62-
--repo "$REPO" \
63-
--base "$RELEASE_BRANCH" \
64-
--head "$UPDATE_BRANCH" \
65-
--json number,url \
66-
--jq '.[0]' || echo '{}')
67+
if [ -z "$RELEASE_BRANCH" ] || [ -z "$UPDATE_BRANCH" ]; then
68+
echo "::error::Branch names cannot be empty"
69+
exit 1
70+
fi
6771
68-
if [ "$pr_json" != "{}" ] && [ -n "$pr_json" ] && [ "$(echo "$pr_json" | jq -r '.url // ""')" != "" ]; then
69-
pr_number=$(echo "$pr_json" | jq -r '.number // ""')
70-
pr_url=$(echo "$pr_json" | jq -r '.url // ""')
71-
echo "::notice::Found existing PR #$pr_number: $pr_url"
72-
echo "pr_exists=true" >> "$GITHUB_OUTPUT"
73-
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
74-
echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT"
75-
else
76-
echo "::notice::No existing PR found"
77-
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
78-
echo "pr_number=" >> "$GITHUB_OUTPUT"
79-
echo "pr_url=" >> "$GITHUB_OUTPUT"
80-
fi
72+
# Check if update branch exists
73+
echo "::notice::Checking if update branch exists: $UPDATE_BRANCH"
74+
if gh api "repos/$REPO/branches/$UPDATE_BRANCH" >/dev/null 2>&1; then
75+
echo "::notice::Update branch exists, will scan: $UPDATE_BRANCH"
76+
echo "source_branch=$UPDATE_BRANCH" >> "$GITHUB_OUTPUT"
77+
echo "update_branch_exists=true" >> "$GITHUB_OUTPUT"
78+
79+
# Check for existing PR
80+
echo "::notice::Checking for existing PR from $UPDATE_BRANCH to $RELEASE_BRANCH"
81+
pr_json=$(gh pr list \
82+
--repo "$REPO" \
83+
--base "$RELEASE_BRANCH" \
84+
--head "$UPDATE_BRANCH" \
85+
--json number,url,state \
86+
--jq '.[0]' || echo '{}')
87+
88+
pr_number=$(echo "$pr_json" | jq -r '.number // empty')
89+
90+
if [ -n "$pr_number" ]; then
91+
pr_url=$(echo "$pr_json" | jq -r '.url')
92+
pr_state=$(echo "$pr_json" | jq -r '.state')
93+
echo "::notice::Found existing PR #$pr_number ($pr_state): $pr_url"
94+
echo "pr_exists=true" >> "$GITHUB_OUTPUT"
95+
echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT"
96+
echo "pr_url=$pr_url" >> "$GITHUB_OUTPUT"
8197
else
82-
echo "::notice::Update branch does not exist, will scan: $RELEASE_BRANCH"
83-
echo "source_branch=$RELEASE_BRANCH" >> "$GITHUB_OUTPUT"
84-
echo "update_branch_exists=false" >> "$GITHUB_OUTPUT"
98+
echo "::notice::No existing PR found"
8599
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
86100
echo "pr_number=" >> "$GITHUB_OUTPUT"
87101
echo "pr_url=" >> "$GITHUB_OUTPUT"
102+
103+
# Check for orphan branch if validation is enabled
104+
if [[ "${FAIL_ON_ORPHAN,,}" == "true" ]]; then
105+
echo "::error::Orphan branch detected: '$UPDATE_BRANCH' exists but no associated PR found"
106+
echo "::error::Please either create a PR or delete the orphan branch: $UPDATE_BRANCH"
107+
exit 1
108+
fi
88109
fi
89-
110+
else
111+
echo "::notice::Update branch does not exist, will scan: $RELEASE_BRANCH"
112+
echo "source_branch=$RELEASE_BRANCH" >> "$GITHUB_OUTPUT"
113+
echo "update_branch_exists=false" >> "$GITHUB_OUTPUT"
114+
echo "pr_exists=false" >> "$GITHUB_OUTPUT"
115+
echo "pr_number=" >> "$GITHUB_OUTPUT"
116+
echo "pr_url=" >> "$GITHUB_OUTPUT"
117+
fi

.github/update-config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ update_config:
99
branches:
1010
- snapshot:
1111
enabled: false
12-
name: "FOLIO Sunflower Version"
12+
name: "FOLIO Snapshot Version"
1313
description: "FOLIO Snapshot LSP (Library Services Platform) is a set of microservices and applications that provide a complete library management system."
1414
need_pr: false
1515
pre_release: "only"
16-
- R1-1994:
16+
- R1-2025-ci:
1717
enabled: true
18-
name: "FOLIO R1-1994 Version"
19-
description: "FOLIO R1-1994 is a major release that includes significant updates and new features for the FOLIO platform."
18+
name: "FOLIO R1-2025 (Sunflower) Version"
19+
description: "FOLIO R1-2025 (Sunflower) is a major release that includes significant updates and new features for the FOLIO platform."
2020
need_pr: true
2121
pre_release: "false"

.github/workflows/release-pr-check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Release PR Check
22

33
run-name: >-
4-
Release platform check • PR #${{ inputs.pr_number || github.event.pull_request.number }} • ${{ inputs.repo_name || github.event.repository.name }}
4+
${{ inputs.pr_number != '' && format('PR check #{0} - {1}', inputs.pr_number, inputs.repo_name) || format('PR check - {0}', inputs.repo_name) }}
55
66
on:
77
# TODO: Re-enable pull_request trigger when ready

.github/workflows/release-scan.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Platform scan for release scheduler
1+
name: Release Update Scheduler
22

33
run-name: Release update scheduler ${{ github.event_name == 'workflow_dispatch' && '[manual]' || '' }}
44

@@ -33,41 +33,29 @@ jobs:
3333
name: Get Configuration
3434
runs-on: ubuntu-latest
3535
outputs:
36-
branches: ${{ steps.get-config.outputs.release_branches }}
36+
branches: ${{ steps.get-config.outputs.branches }}
3737
branch_count: ${{ steps.get-config.outputs.branch_count }}
3838
pr_reviewers: ${{ steps.get-config.outputs.pr_reviewers }}
3939
pr_labels: ${{ steps.get-config.outputs.pr_labels }}
40-
matrix_includes: ${{ steps.build-matrix.outputs.includes }}
40+
branch_config: ${{ steps.get-config.outputs.branch_config }}
4141
steps:
4242
- name: Ensure gh CLI # TODO: Remove before merging if using a self-hosted runner with gh pre-installed
4343
run: sudo apt-get update && sudo apt-get install -y gh
4444

45-
- name: Get Release Configuration
45+
- name: Get Update Configuration
4646
id: get-config
4747
uses: folio-org/kitfox-github/.github/actions/get-update-config@master
4848
with:
4949
repo: ${{ github.repository }}
50-
branch: ${{ github.ref_name }}
5150
github_token: ${{ github.token }}
5251

53-
- name: Build Matrix Includes
54-
id: build-matrix
55-
env:
56-
UPDATE_MAP: ${{ steps.get-config.outputs.update_branches_map }}
57-
run: |
58-
INCLUDES=$(echo "$UPDATE_MAP" | jq -c '[to_entries[] | {branch: .key, update_branch: .value}]')
59-
60-
echo "includes=$INCLUDES" >> "$GITHUB_OUTPUT"
61-
echo "::notice::Matrix includes: $INCLUDES"
62-
6352
update-branches:
6453
name: Update ${{ matrix.branch }}
6554
needs: get-config
6655
if: needs.get-config.outputs.branch_count > 0
6756
strategy:
6857
matrix:
69-
branch: ${{ fromJson(needs.get-config.outputs.branches) }}
70-
include: ${{ fromJson(needs.get-config.outputs.matrix_includes) }}
58+
include: ${{ fromJson(needs.get-config.outputs.branch_config) }}
7159
fail-fast: false
7260
max-parallel: 3
7361
uses: ./.github/workflows/release-update.yml

0 commit comments

Comments
 (0)