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

init: import code from rhods-operator 2.15 + new commits for 2.16 from incubation #1309

Merged
merged 20 commits into from
Nov 4, 2024
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
namespace: openshift
name: release
tag: golang-1.20
tag: golang-1.21
28 changes: 28 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!---
Many thanks for submitting your Pull Request ❤️!

Please complete the following sections for a smooth review.
-->

## Description
<!--- Describe your changes in detail -->

<!--- Link your JIRA and related links here for reference. -->

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment and the tests you ran to -->
<!--- see how your change affects other areas of the code, etc. -->

## Screenshot or short clip
<!--- If applicable, attach a screenshot or a short clip demonstrating the feature. -->

## Merge criteria
<!--- This PR will be merged by any repository approver when it meets all the points in the checklist -->
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->

- [ ] You have read the [contributors guide](https://github.com/opendatahub-io/opendatahub-operator/blob/incubation/CONTRIBUTING.md).
- [ ] Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
- [ ] Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
- [ ] Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
- [ ] The developer has manually tested the changes and verified that the changes work
14 changes: 14 additions & 0 deletions .github/actions/update-manifest-branches/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: "Create release pr"
description: "Updates get_all_manifests.sh with relavent tags and creates a pr"
runs:
using: "composite"
steps:
- name: Update branches in get_all_manifest.sh
uses: actions/github-script@v7
with:
script: |
const script = require('./.github/scripts/get-release-branches.js')
script({github, core})
- name: Update versions
shell: bash
run: ./.github/scripts/update-manifests-tags.sh
54 changes: 54 additions & 0 deletions .github/actions/update-release-version/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Update release versions and create pr"
description: "Update versions in the manifests/makefile and create a pr"
inputs:
version:
description: 'The release version'
required: true
token:
description: "GH token with required rights to create pr"
required: true
commit-message:
description: "Commit message for the pr"
required: true
title:
description: "Title for the pr"
required: true
branch-name:
description: "Temporary branch to host the changes"
required: true
base-branch:
description: "Set pr base branch."
required: true
outputs:
pull-request-number:
description: "Number of the pull request created"
value: ${{ steps.cpr.outputs.pull-request-number }}
runs:
using: "composite"
steps:
- name: Update versions in relevant files
shell: bash
run: ./.github/scripts/update-versions.sh ${{ inputs.version }}
- name: Run make manifests & bundle
shell: bash
run: make manifests bundle
- name: Clean up
shell: bash
run: |
sed -i -e "s|image: quay.io/opendatahub/opendatahub-operator:latest.*|image: REPLACE_IMAGE:latest|g" bundle/manifests/opendatahub-operator.clusterserviceversion.yaml
rm ./config/manager/kustomization.yaml
- name: Create pr
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ inputs.token }}
commit-message: ${{ inputs.commit-message }}
branch: ${{ inputs.branch-name }}
delete-branch: true
title: ${{ inputs.title }}
reviewers: "VaishnaviHire,zdtsw"
base: ${{ inputs.base-branch }}
- name: Set pr number in output
shell: bash
run: |
echo "pull-request-number=${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_OUTPUT"
72 changes: 72 additions & 0 deletions .github/scripts/get-component-release-notes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
function getModifiedComponentName(name) {
let modifiedWord = name.split("-").join(" ").replace(/[^a-zA-Z ]/g, "").trim()
modifiedWord = modifiedWord[0].toUpperCase() + modifiedWord.slice(1).toLowerCase()
return modifiedWord.replace("Odh", "ODH")
}
module.exports = async ({ github, core, context }) => {
const { TRACKER_URL: trackerUrl, VERSION: currentTag } = process.env
console.log(`The TRACKER_URL is ${trackerUrl}`)
const arr = trackerUrl.split("/")
const owner = arr[3]
const repo = arr[4]
const issue_number = arr[6]

try {
const latestReleaseResult = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json',
}
})
const previousTag = latestReleaseResult.data["tag_name"]
console.log(`The current tag is: ${previousTag}`)

const releaseNotesResult = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: currentTag,
previous_tag_name: previousTag,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github+json'
}
})
const releaseNotesString = releaseNotesResult.data["body"]

const commentsResult = await github.rest.issues.listComments({
owner,
repo,
issue_number,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github.text+json'
}
})
let outputStr = "## Component Release Notes\n"
commentsResult.data.forEach((issue) => {
let issueCommentBody = issue.body_text
if (issueCommentBody.includes("#Release#")) {
let components = issueCommentBody.split("\n")
const releaseIdx = components.indexOf("#Release#")
components = components.splice(releaseIdx + 1, components.length)
const regex = /\s*[A-Za-z-_0-9]+\s*\|\s*(https:\/\/github\.com\/.*(tree|releases).*){1}\s*\|?\s*(https:\/\/github\.com\/.*releases.*)?\s*/;
components.forEach(component => {
if (regex.test(component)) {
let [componentName, branchUrl, tagUrl] = component.split("|")
componentName = getModifiedComponentName(componentName.trim())
const releaseNotesUrl = (tagUrl || branchUrl).trim();
if (!outputStr.includes(componentName)) outputStr += `- **${componentName}**: ${releaseNotesUrl}\n`

}
})
}
})
outputStr += "\n" + releaseNotesString
console.log("Created component release notes successfully...")
core.setOutput('release-notes-body', outputStr);
} catch (error) {
core.setFailed(`Action failed with error ${error}`);
}
}
51 changes: 51 additions & 0 deletions .github/scripts/get-release-branches.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
module.exports = ({ github, core }) => {
const { TRACKER_URL } = process.env
console.log(`The tracker url is: ${TRACKER_URL}`)

const arr = TRACKER_URL.split("/")
const owner = arr[3]
const repo = arr[4]
const issue_number = arr[6]

github.request('GET /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner,
repo,
issue_number,
headers: {
'X-GitHub-Api-Version': '2022-11-28',
'Accept': 'application/vnd.github.text+json'
}
}).then((result) => {
result.data.forEach((issue) => {
let issueCommentBody = issue.body_text
if (issueCommentBody.includes("#Release#")) {
let components = issueCommentBody.split("\n")
const releaseIdx = components.indexOf("#Release#")
components = components.splice(releaseIdx + 1, components.length)
const regex = /\s*[A-Za-z-_0-9]+\s*\|\s*(https:\/\/github\.com\/.*(tree|releases).*){1}\s*\|?\s*(https:\/\/github\.com\/.*releases.*)?\s*/;
components.forEach(component => {
if (regex.test(component)) {
const [componentName, branchOrTagUrl] = component.split("|")
const splitArr = branchOrTagUrl.trim().split("/")
let idx = null
if (splitArr.includes("tag")) {
idx = splitArr.indexOf("tag")
} else if (splitArr.includes("tree")) {
idx = splitArr.indexOf("tree")
}
const branchName = splitArr.slice(idx + 1).join("/")
if (componentName.trim() === "notebook-controller") {
core.exportVariable("component_spec_odh-notebook-controller".toLowerCase(), branchName);
core.exportVariable("component_spec_kf-notebook-controller".toLowerCase(), branchName);
} else {
core.exportVariable("component_spec_" + componentName.trim().toLowerCase(), branchName);
}
}
})
}
})
console.log("Read release/tag from tracker issue successfully...")
}).catch(e => {
core.setFailed(`Action failed with error ${e}`);
})
}
17 changes: 17 additions & 0 deletions .github/scripts/update-manifests-tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euo pipefail

update_tags(){
sed -i -r "/\"$1\"/s|([^:]*):([^:]*):[^:]*:(.*)|\1:\2:$2:\3|" get_all_manifests.sh
}

prefix=component_spec_

echo
env | while IFS="=" read varname value; do
[[ $varname =~ "${prefix}" ]] || continue
component=${varname#${prefix}}
component=${component/_/-}
update_tags $component $value
done
12 changes: 12 additions & 0 deletions .github/scripts/update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -euo

NEW_VERSION=$1
CURRENT_VERSION=$(cat Makefile | grep -w "VERSION ?=" | cut -d ' ' -f 3)
sed -i -e "s/^VERSION ?=.*/VERSION ?= $NEW_VERSION/g" Makefile
sed -i -e "s|containerImage.*|containerImage: quay.io/opendatahub/opendatahub-operator:v$NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|createdAt.*|createdAt: \"$(date +"%Y-%-m-%dT00:00:00Z")\"|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|name: opendatahub-operator.v.*|name: opendatahub-operator.v$NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|version: $CURRENT_VERSION.*|version: $NEW_VERSION|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
sed -i -e "s|olm.skipRange:.*|olm.skipRange: \'>=1.0.0 <$NEW_VERSION\'|g" config/manifests/bases/opendatahub-operator.clusterserviceversion.yaml
23 changes: 23 additions & 0 deletions .github/scripts/validate-semver.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -euo pipefail

sem_ver_pattern="^[vV](0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(\\-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"

die () {
echo >&2 "$@"
exit 1
}

validate_semantic_versioning() {
version=$1

if [[ ${version} == "" ]]; then
die "Undefined version. Please use semantic versioning https://semver.org/."
fi

# Ensure defined version matches semver rules
if [[ ! "${version}" =~ $sem_ver_pattern ]]; then
die "\`${version}\` you defined as a version does not match semantic versioning. Please make sure it conforms with https://semver.org/ and make sure it starts with v prefix."
fi
}
5 changes: 4 additions & 1 deletion .github/workflows/check-file-updates.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Check config and readme updates
on:
pull_request:
pull_request_target:
jobs:
file-updates:
permissions:
Expand All @@ -9,6 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Generate files
id: generate-files
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
branches:
- main
- incubation
- rhoai_2
pull_request:
permissions:
contents: read
Expand All @@ -20,8 +21,7 @@ jobs:
with:
go-version-file: go.mod
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.0
skip-cache: true
version: v1.61.0
args: --timeout 5m0s
Loading