Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into SRVLOGIC-196
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartinol committed Jan 15, 2024
2 parents 05c4628 + 1972557 commit 27fbf01
Show file tree
Hide file tree
Showing 34 changed files with 936 additions and 998 deletions.
22 changes: 10 additions & 12 deletions .ci/jenkins/Jenkinsfile.deploy
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ helper = null

commitDone = false

def localRegistryUrl = '';

pipeline {
agent {
docker {
Expand All @@ -25,6 +23,8 @@ pipeline {
PR_BRANCH_HASH = "${util.generateHash(10)}"

IMAGE_BUILD_PLATFORMS = 'linux/amd64,linux/arm64'

CONTAINER_ENGINE = 'docker'
}

stages {
Expand Down Expand Up @@ -55,11 +55,10 @@ pipeline {

// Prepare for multiplatform build
int freePort = cloud.findFreePort()
localRegistryUrl = cloud.startLocalRegistry(freePort)
env.localRegistryUrl = cloud.startLocalRegistry(freePort)

// TODO docker buildx could be preinstalled onto the docker image
cloud.prepareForDockerMultiplatformBuild([localRegistryUrl],[cloud.getDockerIOMirrorRegistryConfig()], false)
cloud.installSkopeo()
cloud.prepareForDockerMultiplatformBuild([env.localRegistryUrl],[cloud.getDockerIOMirrorRegistryConfig()], false)
}
}
post {
Expand All @@ -81,7 +80,7 @@ pipeline {
steps {
script {
if (githubscm.isBranchExist('origin', helper.getPRBranch())) {
githubscm.removeRemoteBranch('origin', helper.getPRBranch())
githubscm.removeRemoteBranch('origin', helper.getPRBranch(), helper.getGitAuthorPushCredsId())
}
githubscm.createBranch(helper.getPRBranch())
}
Expand All @@ -96,6 +95,7 @@ pipeline {
script {
runPythonCommand("make bump-version new_version=${helper.getProjectVersion()}")

githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
// Commit changes
githubscm.commitChanges(getCommitMessage(), {
sh '''
Expand Down Expand Up @@ -206,14 +206,14 @@ pipeline {
}
steps {
script {
githubscm.pushObject('origin', helper.getPRBranch(), helper.getGitAuthorCredsID())
githubscm.pushObject('origin', helper.getPRBranch(), helper.getGitAuthorPushCredsId())

def prMsg = getCommitMessage()
def prBody = "Generated by build ${BUILD_TAG}: ${BUILD_URL}.\nPlease do not merge, it shoud be merged automatically."
String prLink = githubscm.createPR(prMsg, prBody, helper.getBuildBranch(), helper.getGitAuthorCredsID())
String prLink = githubscm.createPR(prMsg, prBody, helper.getBuildBranch(), helper.getGitAuthorPushCredsId())
properties.add("${helper.getRepoName()}.pr.link", prLink)

properties.add("${helper.getRepoName()}.pr.source.uri", "https://github.com/${helper.getGitAuthorCredsID()}/${helper.getRepoName()}")
properties.add("${helper.getRepoName()}.pr.source.uri", "https://github.com/${helper.getGitAuthor()}/${helper.getRepoName()}")
properties.add("${helper.getRepoName()}.pr.source.ref", helper.getPRBranch())
properties.add("${helper.getRepoName()}.pr.target.uri", "https://github.com/${helper.getGitAuthor()}/${helper.getRepoName()}")
properties.add("${helper.getRepoName()}.pr.target.ref", helper.getBuildBranch())
Expand All @@ -236,8 +236,6 @@ pipeline {
helper.cleanGoPath()
util.cleanNode(env.CONTAINER_ENGINE)
cloud.cleanDockerMultiplatformBuild()
cloud.cleanLocalRegistry()
cloud.cleanSkopeo()
}
}
}
Expand All @@ -264,7 +262,7 @@ String getBuiltImage() {
}

String getTempBuiltImageTag() {
return "${localRegistryUrl}/kogito-serverless-operator:${getOperatorVersion()}"
return "${env.localRegistryUrl}/kogito-serverless-operator:${getOperatorVersion()}"
}

void runPythonCommand(String cmd, boolean stdout = false) {
Expand Down
20 changes: 9 additions & 11 deletions .ci/jenkins/Jenkinsfile.promote
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ pipeline {
// Login old and new registries
helper.loginRegistry(baseImageParamsPrefix)
helper.loginRegistry(promoteImageParamsPrefix)

cloud.installSkopeo()
}
}
}
Expand Down Expand Up @@ -86,8 +84,8 @@ pipeline {
// Merge PR
String prLink = properties.retrieve("${helper.getRepoName()}.pr.link")
if (prLink) {
githubscm.mergePR(prLink, helper.getGitAuthorCredsID())
githubscm.pushObject('origin', helper.getBuildBranch(), helper.getGitAuthorCredsID())
githubscm.mergePR(prLink, helper.getGitAuthorPushCredsId())
githubscm.pushObject('origin', helper.getBuildBranch(), helper.getGitAuthorPushCredsId())
}

// Tag api / container-builder
Expand Down Expand Up @@ -117,13 +115,13 @@ pipeline {
steps {
script {
dir(helper.getRepoName()) {
if(githubscm.isReleaseExist(helper.getGitTag(), helper.getGitAuthorCredsID())) {
githubscm.deleteReleaseAndTag(helper.getGitTag(), helper.getGitAuthorCredsID())
if(githubscm.isReleaseExist(helper.getGitTag(), helper.getGitAuthorCredsId())) {
githubscm.deleteReleaseAndTag(helper.getGitTag(), helper.getGitAuthorPushCredsId())
}
githubscm.createReleaseWithGeneratedReleaseNotes(helper.getGitTag(), helper.getBuildBranch(), githubscm.getPreviousTagFromVersion(helper.getProjectVersion(), 'v', '', ['/']), helper.getGitAuthorCredsID())
githubscm.updateReleaseBody(helper.getGitTag(), helper.getGitAuthorCredsID())
githubscm.createReleaseWithGeneratedReleaseNotes(helper.getGitTag(), helper.getBuildBranch(), githubscm.getPreviousTagFromVersion(helper.getProjectVersion(), 'v', '', ['/']), helper.getGitAuthorPushCredsId())
githubscm.updateReleaseBody(helper.getGitTag(), helper.getGitAuthorPushCredsId())

withCredentials([usernamePassword(credentialsId: helper.getGitAuthorCredsID(), usernameVariable: 'GH_USER', passwordVariable: 'GH_TOKEN')]) {
withCredentials([usernamePassword(credentialsId: helper.getGitAuthorPushCredsId(), usernameVariable: 'GH_USER', passwordVariable: 'GH_TOKEN')]) {
sh """
gh release upload ${helper.getGitTag()} "operator.yaml"
"""
Expand All @@ -141,7 +139,6 @@ pipeline {
script {
helper.cleanGoPath()
util.cleanNode(containerEngine)
cloud.cleanSkopeo()
}
}
}
Expand All @@ -168,8 +165,9 @@ void updateInternalGoModuleWithTag(String moduleName, String tagName) {

void commitAndPush(String remote, String commitMsg, Closure preCommit) {
if (githubscm.isThereAnyChanges()) {
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges(commitMsg, preCommit)
githubscm.pushObject(remote, helper.getBuildBranch(), helper.getGitAuthorCredsID())
githubscm.pushObject(remote, helper.getBuildBranch(), helper.getGitAuthorPushCredsId())
} else {
echo "No change... Skipping commit and push"
}
Expand Down
3 changes: 2 additions & 1 deletion .ci/jenkins/Jenkinsfile.setup-branch
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ pipeline {
git checkout -- go.sum
'''
if (githubscm.isThereAnyChanges()) {
githubscm.setUserConfigFromCreds(getGitAuthorPushCredsId())
githubscm.commitChanges("[${helper.getBuildBranch()}] Update version to ${helper.getProjectVersion()}", {
sh '''
git add .
'''
})
githubscm.pushObject('origin', helper.getBuildBranch(), helper.getGitAuthorCredsID())
githubscm.pushObject('origin', helper.getBuildBranch(), helper.getGitAuthorPushCredsId())
} else {
println '[WARN] no changes to commit'
}
Expand Down
14 changes: 8 additions & 6 deletions .ci/jenkins/dsl/jobs.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ void createSetupBranchJob() {
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",

IS_MAIN_BRANCH: "${Utils.isMainBranch(this)}"
])
Expand All @@ -86,8 +86,8 @@ void setupDeployJob(JobType jobType) {
JENKINS_EMAIL_CREDS_ID: "${JENKINS_EMAIL_CREDS_ID}",

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",
AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",

OPERATOR_IMAGE_NAME: 'kogito-serverless-operator',
MAX_REGISTRY_RETRIES: 3,
Expand Down Expand Up @@ -137,8 +137,8 @@ void setupPromoteJob(JobType jobType) {

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",

AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GITHUB_TOKEN_CREDS_ID: "${GIT_AUTHOR_TOKEN_CREDENTIALS_ID}",
GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",
GIT_AUTHOR_PUSH_CREDS_ID: "${GIT_AUTHOR_PUSH_CREDENTIALS_ID}",
])
KogitoJobTemplate.createPipelineJob(this, jobParams)?.with {
parameters {
Expand Down Expand Up @@ -182,6 +182,8 @@ void setupE2EJob(JobType jobType, String clusterName, Map extraEnv = [:]) {

GIT_AUTHOR: "${GIT_AUTHOR_NAME}",

GIT_AUTHOR_CREDS_ID: "${GIT_AUTHOR_CREDENTIALS_ID}",

OPERATOR_IMAGE_NAME: 'kogito-serverless-operator',
MAX_REGISTRY_RETRIES: 3,
PROPERTIES_FILE_NAME: 'deployment.properties',
Expand Down
20 changes: 13 additions & 7 deletions .ci/jenkins/scripts/helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void initPipeline() {
openshift.openshiftApiCredsKey = env.OPENSHIFT_CREDS_KEY

container = load '.ci/jenkins/scripts/container.groovy'
container.containerEngine = env.CONTAINER_ENGINE
container.containerEngine = env.CONTAINER_ENGINE ?: 'docker'
container.containerEngineTlsOptions = env.CONTAINER_ENGINE_TLS_OPTIONS ?: ''
container.containerOpenshift = openshift

Expand Down Expand Up @@ -48,14 +48,16 @@ String getTempTag() {
void checkoutRepo(String repoName = '', String directory = '') {
repoName = repoName ?: getRepoName()
closure = {
deleteDir()
checkout(githubscm.resolveRepository(repoName, getGitAuthor(), getBuildBranch(), false))
checkout(githubscm.resolveRepository(repoName, getGitAuthor(), getBuildBranch(), false, getGitAuthorCredsId()))
// need to manually checkout branch since on a detached branch after checkout command
//sh "git checkout ${getBuildBranch()}"
}

if (directory) {
dir(directory, closure)
dir(directory) {
deleteDir()
closure()
}
} else {
closure()
}
Expand All @@ -70,7 +72,7 @@ void loginRegistry(String paramsPrefix = defaultImageParamsPrefix) {
}

void createTag(String tagName = getGitTag()) {
githubscm.tagLocalAndRemoteRepository('origin', tagName, getGitAuthorCredsID(), '', true)
githubscm.tagLocalAndRemoteRepository('origin', tagName, getGitAuthorPushCredsId(), '', true)
}

// Set images public on quay. Useful when new images are introduced.
Expand Down Expand Up @@ -237,8 +239,12 @@ String getGitAuthor() {
return "${GIT_AUTHOR}"
}

String getGitAuthorCredsID() {
return env.AUTHOR_CREDS_ID
String getGitAuthorCredsId() {
return env.GIT_AUTHOR_CREDS_ID
}

String getGitAuthorPushCredsId() {
return env.GIT_AUTHOR_PUSH_CREDS_ID
}

String getPRBranch() {
Expand Down
4 changes: 2 additions & 2 deletions .ci/jenkins/scripts/minikube.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ void preChecks() {
${minikubeContainerEngine} info
if [[ ! \$(command -v minikube) ]]; then
curl -LO https://github.com/kubernetes/minikube/releases/download/v${minikubeVersion}/minikube-${minikubeVersion}-0.x86_64.rpm
sudo yum localinstall -y minikube-${minikubeVersion}-0.x86_64.rpm
sudo ./hack/ci/install-minikube.sh /usr/local/bin
sudo chmod +x /usr/local/bin/minikube
fi
"""
}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ generate-all: generate generate-deploy bundle addheaders vet fmt

.PHONY: test-e2e # You will need to have a Minikube/Kind cluster up in running to run this target, and run container-builder before the test
test-e2e: install-operator-sdk
go test ./test/e2e/* -v -ginkgo.v
go test ./test/e2e/* -v -ginkgo.v -timeout 30m

.PHONY: before-pr
before-pr: test generate-all
56 changes: 27 additions & 29 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ go 1.19

require (
github.com/serverlessworkflow/sdk-go/v2 v2.2.5
k8s.io/api v0.27.2
k8s.io/apimachinery v0.27.2
knative.dev/pkg v0.0.0-20230525143525-9bda38b21643
k8s.io/api v0.27.6
k8s.io/apimachinery v0.27.6
knative.dev/pkg v0.0.0-20231023151236-29775d7c9e5c
sigs.k8s.io/controller-runtime v0.15.0
sigs.k8s.io/yaml v1.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
Expand All @@ -32,8 +32,9 @@ require (
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/google/pprof v0.0.0-20230705174524-200ffdc848b8 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
Expand All @@ -45,37 +46,34 @@ require (
github.com/onsi/ginkgo/v2 v2.13.0 // indirect
github.com/onsi/gomega v1.30.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/relvacode/iso8601 v1.3.0 // indirect
github.com/senseyeio/duration v0.0.0-20180430131211-7c2a214ada46 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.8.3 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.27.2 // indirect
k8s.io/client-go v0.27.2 // indirect
k8s.io/component-base v0.27.2 // indirect
k8s.io/apiextensions-apiserver v0.27.6 // indirect
k8s.io/client-go v0.27.6 // indirect
k8s.io/component-base v0.27.6 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230313181309-38a27ef9d749 // indirect
k8s.io/kube-openapi v0.0.0-20230525220651-2546d827e515 // indirect
k8s.io/utils v0.0.0-20230711102312-30195339c3c7 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
)
Loading

0 comments on commit 27fbf01

Please sign in to comment.