This is an automated email from the ASF dual-hosted git repository. rantunes pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-kie-tools-temporary-rnd-do-not-use.git
commit df17fc16cc0f9d9f2e995768acbb15258924f2b7 Author: Rodrigo Antunes <[email protected]> AuthorDate: Mon Nov 27 09:22:03 2023 -0300 CI - Sync changes (#22) * CI - Disable workflows migrated to Jenkins (#20) * CI - Disable workflows migrated to Jenkins * Update CI Build workflow name * Remove disallowed actions * CI - Jenkins shared scripts (#21) * CI - Jenkins shared scripts * Update openshift get route utility * CI - Daily dev publish Jenkins job (#10) * CI - Daily dev publish Jenkins job * Fix artifacts and build date * Add env debug * remove env debug * Small code improvements * remove unecessary code * Start using the kie-tools-pipeline-lib utilities * Fix identation * Reflect library changes * Use shared scripts * Use shared scripts * Update image tag * Update Jenkinsfile name * Add DOCKER_CONFIG env var --- .ci/jenkins/Jenkinsfile.daily-dev-publish | 417 +++++++++++++++++++++ .ci/jenkins/shared-scripts/buildUtils.groovy | 110 ++++++ .ci/jenkins/shared-scripts/chromeStoreUtils.groovy | 52 +++ .ci/jenkins/shared-scripts/dockerUtils.groovy | 32 ++ .ci/jenkins/shared-scripts/githubUtils.groovy | 180 +++++++++ .ci/jenkins/shared-scripts/openShiftUtils.groovy | 77 ++++ .ci/jenkins/shared-scripts/pipelineVars.groovy | 20 + .ci/jenkins/shared-scripts/zipUtils.groovy | 37 ++ .github/actions/checkout-pr/action.yml | 2 +- .github/actions/setup-env/action.yml | 22 +- .github/workflows/ci_build.yml | 8 +- .github/workflows/ci_check_code_formatting.yml | 9 +- .../ci_check_dependencies_consistency.yaml | 9 +- .github/workflows/ci_codeql.yml | 10 +- .../ci_sonar_analysis_stunner_editors.yml | 13 +- .github/workflows/daily_dev_publish.yml | 10 +- .github/workflows/jenkins-tests-PR.yml | 13 +- .github/workflows/publish_jitexecutor_native.yml | 6 +- .../workflows/release_build_extended_services.yml | 87 +++++ .github/workflows/release_dry_run.yml | 14 +- ...n.yml => release_dry_run_extended_services.yml} | 10 +- .../release_publish_extended_services.yml | 47 +++ .../workflows/staging_build_extended_services.yml | 89 +++++ .github/workflows/staging_dry_run.yml | 14 +- ...n.yml => staging_dry_run_extended_services.yml} | 4 +- .github/workflows/staging_publish.yml | 5 +- .../staging_publish_extended_services.yml | 51 +++ 27 files changed, 1266 insertions(+), 82 deletions(-) diff --git a/.ci/jenkins/Jenkinsfile.daily-dev-publish b/.ci/jenkins/Jenkinsfile.daily-dev-publish new file mode 100644 index 0000000000..138d3daefc --- /dev/null +++ b/.ci/jenkins/Jenkinsfile.daily-dev-publish @@ -0,0 +1,417 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +pipeline { + agent { + docker { + image 'quay.io/kie-tools/kie-tools-ci-build:latest' + args '--shm-size=2g --privileged --group-add docker' + } + } + + options { + timeout(time: 240, unit: 'MINUTES') + } + + environment { + KIE_SANDBOX_EXTENDED_SERVICES_VERSION = '0.0.0' + + KIE_TOOLS_BUILD__buildContainerImages = 'true' + KIE_TOOLS_BUILD__runLinters = 'false' + KIE_TOOLS_BUILD__runTests = 'false' + KIE_TOOLS_BUILD__runEndToEndTests = 'false' + + DMN_DEV_DEPLOYMENT_BASE_IMAGE__registry = 'quay.io' + DMN_DEV_DEPLOYMENT_BASE_IMAGE__account = 'kie-tools' + DMN_DEV_DEPLOYMENT_BASE_IMAGE__name = 'dmn-dev-deployment-base-image' + DMN_DEV_DEPLOYMENT_BASE_IMAGE__buildTags = 'daily-dev' + + ONLINE_EDITOR__dmnDevDeploymentBaseImageRegistry = 'quay.io' + ONLINE_EDITOR__dmnDevDeploymentBaseImageAccount = 'kie-tools' + ONLINE_EDITOR__dmnDevDeploymentBaseImageName = 'dmn-dev-deployment-base-image' + ONLINE_EDITOR__dmnDevDeploymentBaseImageTag = 'daily-dev' + ONLINE_EDITOR__corsProxyUrl = 'https://daily-dev-cors-proxy-kie-sandbox.rhba-0ad6762cc85bcef5745bb684498c2436-0000.us-south.containers.appdomain.cloud' + + EXTENDED_SERVICES__kieSandboxUrl = 'https://kiegroup.github.io/kogito-online/dev' + + KIE_SANDBOX__imageRegistry = 'quay.io' + KIE_SANDBOX__imageAccount = 'kie-tools' + KIE_SANDBOX__imageName = 'kie-sandbox-image' + KIE_SANDBOX__imageBuildTags = 'daily-dev' + + KIE_SANDBOX_EXTENDED_SERVICES__imageRegistry = 'quay.io' + KIE_SANDBOX_EXTENDED_SERVICES__imageAccount = 'kie-tools' + KIE_SANDBOX_EXTENDED_SERVICES__imageName = 'kie-sandbox-extended-services-image' + KIE_SANDBOX_EXTENDED_SERVICES__imageBuildTags = 'daily-dev' + + CORS_PROXY_IMAGE__imageRegistry = 'quay.io' + CORS_PROXY_IMAGE__imageAccount = 'kie-tools' + CORS_PROXY_IMAGE__imageName = 'cors-proxy-image' + CORS_PROXY_IMAGE__imageBuildTags = 'daily-dev' + + OPENSHIFT_NAMESPACE = 'kie-sandbox' + OPENSHIFT_PART_OF = 'daily-dev-kie-sandbox-app' + DEPLOY_TAG = 'daily-dev' + + DASHBUILDER__viewerImageRegistry = 'quay.io' + DASHBUILDER__viewerImageAccount = 'kie-tools' + DASHBUILDER__viewerImageName = 'dashbuilder-viewer-image' + DASHBUILDER__viewerImageBuildTags = 'daily-dev' + + SERVERLESS_LOGIC_WEB_TOOLS__dashbuilderViewerImageTag = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageRegistry = 'quay.io' + SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageAccount = 'kie-tools' + SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageName = 'serverless-logic-web-tools-swf-builder-image' + SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageTag = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageBuildTags = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageRegistry = 'quay.io' + SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageAccount = 'kie-tools' + SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageName = 'serverless-logic-web-tools-base-builder-image' + SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageTag = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageBuildTags = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageRegistry = 'quay.io' + SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageAccount = 'kie-tools' + SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageName = 'serverless-logic-web-tools-swf-dev-mode-image' + SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageTag = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageBuildTags = 'daily-dev' + SERVERLESS_LOGIC_WEB_TOOLS__corsProxyUrl = 'https://daily-dev-cors-proxy-kie-sandbox.rhba-0ad6762cc85bcef5745bb684498c2436-0000.us-south.containers.appdomain.cloud' + + BUILD_DATE = sh(script: "echo `date +'%Y-%m-%d %T'`", returnStdout: true).trim() + + DOCKER_CONFIG = "${WORKSPACE}/.docker" + } + + stages { + stage('Load local shared scripts') { + steps { + script { + pipelineVars = load '.ci/jenkins/shared-scripts/pipelineVars.groovy' + buildUtils = load '.ci/jenkins/shared-scripts/buildUtils.groovy' + githubUtils = load '.ci/jenkins/shared-scripts/githubUtils.groovy' + openShiftUtils = load '.ci/jenkins/shared-scripts/openShiftUtils.groovy' + dockerUtils = load '.ci/jenkins/shared-scripts/dockerUtils.groovy' + } + } + } + + stage('Start required services for build and tests (DinD, Xvfb, Fluxbox)') { + steps { + script { + buildUtils.startRequiredServices() + } + } + } + + stage('Clean workspace before build') { + steps { + cleanWs(deleteDirs: true, disableDeferredWipeout: true) + } + } + + stage('Checkout kie-tools') { + steps { + dir('kie-tools') { + checkout scm + } + } + } + + stage('Output version') { + steps { + dir('kie-tools') { + script { + env.VERSION = sh(returnStdout: true, script: "#!/bin/bash -el \n node -e \"console.log(require('./package.json').version);\"").trim() + } + } + } + } + + stage('Setup PNPM') { + steps { + dir('kie-tools') { + script { + buildUtils.setupPnpm() + } + } + } + } + + stage('PNPM Bootstrap') { + steps { + dir('kie-tools') { + script { + buildUtils.pnpmBootstrap() + } + } + } + } + + stage('Build') { + steps { + dir('kie-tools') { + sh """#!/bin/bash -el + export WEBPACK__minimize=true + export WEBPACK__tsLoaderTranspileOnly=false + export CHROME_EXTENSION__routerTargetOrigin=https://kiegroup.github.io + export CHROME_EXTENSION__routerRelativePath=kogito-online/dev/editors/ + export SWF_CHROME_EXTENSION__routerTargetOrigin=https://kiegroup.github.io + export SWF_CHROME_EXTENSION__routerRelativePath=kogito-online/dev/editors/ + export ONLINE_EDITOR__extendedServicesDownloadUrlLinux=https://github.com/kiegroup/kie-tools/releases/download/${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}/kie_sandbox_extended_services_linux_${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}.tar.gz + export ONLINE_EDITOR__extendedServicesDownloadUrlMacOs=https://github.com/kiegroup/kie-tools/releases/download/${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}/kie_sandbox_extended_services_macos_${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}.dmg + export ONLINE_EDITOR__extendedServicesDownloadUrlWindows=https://github.com/kiegroup/kie-tools/releases/download/${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}/kie_sandbox_extended_services_windows_${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION}.exe + export ONLINE_EDITOR__extendedServicesCompatibleVersion=${env.KIE_SANDBOX_EXTENDED_SERVICES_VERSION} + export ONLINE_EDITOR__buildInfo="${env.VERSION} (daily-dev) @ ${env.GIT_COMMIT} (${env.BUILD_DATE})" + export SERVERLESS_LOGIC_WEB_TOOLS__buildInfo="${env.VERSION} (daily-dev) @ ${env.GIT_COMMIT} (${env.BUILD_DATE})" + pnpm -r --workspace-concurrency=1 build:prod + """.trim() + } + } + } + + stage('Push dmn-dev-deployment-base-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.DMN_DEV_DEPLOYMENT_BASE_IMAGE__registry}/${env.DMN_DEV_DEPLOYMENT_BASE_IMAGE__account}", + "${env.DMN_DEV_DEPLOYMENT_BASE_IMAGE__name}", + "${env.DMN_DEV_DEPLOYMENT_BASE_IMAGE__buildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Push kie-sandbox-extended-services-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.KIE_SANDBOX_EXTENDED_SERVICES__imageRegistry}/${env.KIE_SANDBOX_EXTENDED_SERVICES__imageAccount}", + "${env.KIE_SANDBOX_EXTENDED_SERVICES__imageName}", + "${env.KIE_SANDBOX_EXTENDED_SERVICES__imageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Deploy kie-sandbox-extended-services-image to OpenShift') { + steps { + script { + appName = 'daily-dev-kie-sandbox-extended-services' + openShiftUtils.createOrUpdateApp( + "${env.OPENSHIFT_NAMESPACE}", + "${appName}", + "${env.DEPLOY_TAG}", + "${env.KIE_SANDBOX_EXTENDED_SERVICES__imageRegistry}/${env.KIE_SANDBOX_EXTENDED_SERVICES__imageAccount}/${env.KIE_SANDBOX_EXTENDED_SERVICES__imageName}:${env.DEPLOY_TAG}", + "${env.OPENSHIFT_PART_OF}", + 'golang', + "${pipelineVars.openshiftCredentialsId}" + ) + env.KIE_SANDBOX_EXTENDED_SERVICES_URL = openShiftUtils.getAppRoute("${env.OPENSHIFT_NAMESPACE}", "${appName}", "${pipelineVars.openshiftCredentialsId}") + } + } + } + + stage('Push cors-proxy-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.CORS_PROXY_IMAGE__imageRegistry}/${env.CORS_PROXY_IMAGE__imageAccount}", + "${env.CORS_PROXY_IMAGE__imageName}", + "${env.CORS_PROXY_IMAGE__imageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Deploy cors-proxy-image to OpenShift') { + steps { + script { + appName = 'daily-dev-cors-proxy' + openShiftUtils.createOrUpdateApp( + "${env.OPENSHIFT_NAMESPACE}", + "${appName}", + "${env.DEPLOY_TAG}", + "${env.CORS_PROXY_IMAGE__imageRegistry}/${env.CORS_PROXY_IMAGE__imageAccount}/${env.CORS_PROXY_IMAGE__imageName}:${env.DEPLOY_TAG}", + "${env.OPENSHIFT_PART_OF}", + 'nodejs', + "${pipelineVars.openshiftCredentialsId}" + ) + env.KIE_SANDBOX_CORS_PROXY_URL = openShiftUtils.getAppRoute("${env.OPENSHIFT_NAMESPACE}", "${appName}", "${pipelineVars.openshiftCredentialsId}") + } + } + } + + stage('Push kie-sandbox-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.KIE_SANDBOX__imageRegistry}/${env.KIE_SANDBOX__imageAccount}", + "${env.KIE_SANDBOX__imageName}", + "${env.KIE_SANDBOX__imageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Prepare environment variables for OpenShift deployment') { + steps { + sh """#!/bin/bash -el + echo "KIE_SANDBOX_EXTENDED_SERVICES_URL=${env.KIE_SANDBOX_EXTENDED_SERVICES_URL}" >> deployment.env + echo "KIE_SANDBOX_CORS_PROXY_URL=${env.KIE_SANDBOX_CORS_PROXY_URL}" >> deployment.env + """.trim() + } + } + + stage('Deploy kie-sandbox-image to OpenShift') { + steps { + script { + openShiftUtils.createOrUpdateApp( + "${env.OPENSHIFT_NAMESPACE}", + 'daily-dev-kie-sandbox', + "${env.DEPLOY_TAG}", + "${env.KIE_SANDBOX__imageRegistry}/${env.KIE_SANDBOX__imageAccount}/${env.KIE_SANDBOX__imageName}:${env.DEPLOY_TAG}", + "${env.OPENSHIFT_PART_OF}", + 'js', + "${pipelineVars.openshiftCredentialsId}", + './deployment.env' + ) + } + } + } + + stage('Push serverless-logic-web-tools-swf-builder-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageRegistry}/${env.SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageAccount}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageName}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfBuilderImageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Push serverless-logic-web-tools-base-builder-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageRegistry}/${env.SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageAccount}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageName}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__baseBuilderImageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Push serverless-logic-web-tools-swf-dev-mode-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageRegistry}/${env.SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageAccount}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageName}", + "${env.SERVERLESS_LOGIC_WEB_TOOLS__swfDevModeImageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Push dashbuilder-viewer-image to quay.io') { + steps { + script { + dockerUtils.pushImageToRegistry( + "${env.DASHBUILDER__viewerImageRegistry}/${env.DASHBUILDER__viewerImageAccount}", + "${env.DASHBUILDER__viewerImageName}", + "${env.DASHBUILDER__viewerImageBuildTags}", + "${pipelineVars.quayPushCredentialsId}" + ) + } + } + } + + stage('Update kogito-online resources') { + steps { + dir('kogito-online') { + script { + githubUtils.checkoutRepo( + 'https://github.com/kiegroup/kogito-online.git', + 'gh-pages', + "${pipelineVars.kieToolsBotGithubCredentialsId}" + ) + + sh """#!/bin/bash -el + git config --global user.email '[email protected]' + git config --global user.name 'KIE Tools Bot (kiegroup)' + git checkout gh-pages + rm -rf dev && mkdir -p dev/editors + cp -RL ../kie-tools/packages/stunner-editors/dist/dmn dev/editors/ + cp -RL ../kie-tools/packages/stunner-editors/dist/bpmn dev/editors/ + cp -RL ../kie-tools/packages/stunner-editors/dist/scesim dev/editors/ + cp -r ../kie-tools/packages/online-editor/dist/* dev/ + rm -rf dev/gwt-editors + ln -s editors dev/gwt-editors + git add . && git commit -m "KIE Tools Daily Dev Build resources - ${env.BUILD_DATE}" || echo 'No changes.' + """.trim() + + withCredentials([usernamePassword(credentialsId: "${pipelineVars.kieToolsBotGithubCredentialsId}", usernameVariable: 'GH_USER', passwordVariable: 'GH_PASSWORD')]) { + sh('set +x && git push https://$GH_USER:[email protected]/kiegroup/kogito-online.git gh-pages') + } + } + } + } + } + + stage('Update serverless-logic-sandbox-deployment') { + steps { + dir('serverless-logic-sandbox-deployment') { + script { + githubUtils.checkoutRepo( + 'https://github.com/kiegroup/serverless-logic-sandbox-deployment.git', + 'gh-pages', + "${pipelineVars.kieToolsBotGithubCredentialsId}" + ) + + sh """#!/bin/bash -el + git config --global user.email '[email protected]' + git config --global user.name 'KIE Tools Bot (kiegroup)' + git checkout gh-pages + rm -rf dev && mkdir dev + cp -r ../kie-tools/packages/serverless-logic-web-tools/dist/* dev/ + git add . && git commit -m "KIE Tools Daily Dev Build resources - ${env.BUILD_DATE}" || echo 'No changes.' + """.trim() + + withCredentials([usernamePassword(credentialsId: "${pipelineVars.kieToolsBotGithubCredentialsId}", usernameVariable: 'GH_USER', passwordVariable: 'GH_PASSWORD')]) { + sh('set +x && git push https://$GH_USER:[email protected]/kiegroup/serverless-logic-sandbox-deployment.git gh-pages') + } + } + } + } + } + } + + post { + always { + archiveArtifacts artifacts: "kie-tools/packages/serverless-workflow-vscode-extension/dist/serverless_workflow_vscode_extension_${env.VERSION}.vsix, kie-tools/packages/vscode-extension-dashbuilder-editor/dist/vscode_extension_dashbuilder_editor_${env.VERSION}.vsix, kie-tools/packages/kie-editors-dev-vscode-extension/dist/kie_editors_dev_vscode_extension_${env.VERSION}.vsix, kie-tools/packages/chrome-extension-pack-kogito-kie-editors/dist/chrome_extension_kogito_kie_editors_${e [...] + + cleanWs(deleteDirs: true, disableDeferredWipeout: true) + } + } +} diff --git a/.ci/jenkins/shared-scripts/buildUtils.groovy b/.ci/jenkins/shared-scripts/buildUtils.groovy new file mode 100644 index 0000000000..9a01314af9 --- /dev/null +++ b/.ci/jenkins/shared-scripts/buildUtils.groovy @@ -0,0 +1,110 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Start Docker in Docker (DinD) +*/ +def startDockerInDocker() { + sh '''#!/bin/bash -el + sudo entrypoint.sh + sudo service dbus start + '''.trim() +} + +/** +* Start Xvfb X server required for KIE-Tools E2E tests +*/ +def startXvfb() { + sh '''#!/bin/bash -el + Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 & + '''.trim() +} + +/** +* Start Fluxbox window manager required for KIE-Tools E2E tests +*/ +def startFluxbox() { + sh '''#!/bin/bash -el + fluxbox -display :99 > /dev/null 2>&1 & + '''.trim() +} + +/** +* Setup PNPM parameters for building KIE-Tools +*/ +def setupPnpm() { + sh """#!/bin/bash -el + pnpm config set network-timeout 1000000 + pnpm -r exec 'bash' '-c' 'mkdir .mvn' + pnpm -r exec 'bash' '-c' 'echo -B > .mvn/maven.config' + pnpm -r exec 'bash' '-c' 'echo -ntp >> .mvn/maven.config' + pnpm -r exec 'bash' '-c' 'echo -Xmx2g > .mvn/jvm.config' + pnpm -F *-image exec sed -i 's/\\("build:prod.*".*\\)podman:build\\(.*\\)/\\1docker:build\\2/g' package.json + """.trim() +} + +/** +* PNPM Bootsrap +*/ +def pnpmBootstrap(String filters = '') { + sh """#!/bin/bash -el + pnpm bootstrap ${filters} + """.trim() +} + +/** +* PNPM build all packages +*/ +def pnpmBuildFull(Integer workspaceConcurrency = 1) { + sh """#!/bin/bash -el + pnpm -r --workspace-concurrency=${workspaceConcurrency} build:prod + """.trim() +} + +/** +* PNPM build a set of packages +*/ +def pnpmBuild(String filters, Integer workspaceConcurrency = 1) { + sh """#!/bin/bash -el + pnpm ${filters} --workspace-concurrency=${workspaceConcurrency} build:prod + """.trim() +} + +/** +* Start KIE-Tools required services for build and test +*/ +def startRequiredServices() { + startDockerInDocker() + startXvfb() + startFluxbox() +} + +/** +* @return String build datetime - format (%Y-%m-%d %T) +*/ +def buildDateTime() { + return sh(script: "echo `date +'%Y-%m-%d %T'`", returnStdout: true).trim() +} + +/** +* @return String the Apache Jenkins agent nodes with higher capacity (builds22 to builds40) +**/ +def apacheAgentLabels() { + return (22..40).collect{"builds$it"}.join(' || ') +} + +return this; diff --git a/.ci/jenkins/shared-scripts/chromeStoreUtils.groovy b/.ci/jenkins/shared-scripts/chromeStoreUtils.groovy new file mode 100644 index 0000000000..610df262af --- /dev/null +++ b/.ci/jenkins/shared-scripts/chromeStoreUtils.groovy @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Upload an extension to Chrome Store +* +* @return String status +*/ +def uploadExtension(String chromeStoreCredentialsId, String chromeStoreRefreshTokenCredentialsId, String file, String extensionId) { + withCredentials([usernamePassword(credentialsId: chromeStoreCredentialsId, usernameVariable: 'CLIENT_ID', passwordVariable: 'CLIENT_SECRET')]) { + withCredentials([string(credentialsId: "${pipelineVars.chromeStoreRefreshTokenCredentialsId}", variable: 'REFRESH_TOKEN')]) { + accessToken = sh(returnStdout: true, script: "curl -X POST -fsS \"https://oauth2.googleapis.com/token\" -d \"client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&refresh_token=${REFRESH_TOKEN}&grant_type=refresh_token\" | jq -r '.access_token'").trim() + uploadResponse = sh(returnStdout: true, script: "curl -X PUT -sS \"https://www.googleapis.com/upload/chromewebstore/v1.1/items/${extensionId}\" -H \"Authorization: Bearer ${accessToken}\" -H \"x-goog-api-version:2\" -T ${file}").trim() + + return sh(returnStdout: true, script: "echo \"${uploadResponse}\" | jq -r '.uploadState'").trim() + } + } +} + +/** +* Publish an extension to Chrome Store +* +* @return String status +*/ +def publishExtension(String chromeStoreCredentialsId, String chromeStoreRefreshTokenCredentialsId, String extensionId) { + withCredentials([usernamePassword(credentialsId: "${pipelineVars.chromeStoreCredentialsId}", usernameVariable: 'CLIENT_ID', passwordVariable: 'CLIENT_SECRET')]) { + withCredentials([string(credentialsId: "${pipelineVars.chromeStoreRefreshTokenCredentialsId}", variable: 'REFRESH_TOKEN')]) { + script { + accessToken = sh(returnStdout: true, script: "curl -X POST -fsS \"https://oauth2.googleapis.com/token\" -d \"client_id=${CLIENT_ID}&client_secret=${CLIENT_SECRET}&refresh_token=${REFRESH_TOKEN}&grant_type=refresh_token\" | jq -r '.access_token'").trim() + publishResponse = sh(returnStdout: true, script: "curl -X POST -sS \"https://www.googleapis.com/chromewebstore/v1.1/items/${extensionId}/publish\" -H \"Authorization: Bearer ${accessToken}\" -H \"x-goog-api-version:2\" -H \"Content-Length:\"").trim() + + return sh(returnStdout: true, script: "echo \"${publishResponse}\" | jq -r '.status | .[0]'").trim() + } + } + } +} + +return this; diff --git a/.ci/jenkins/shared-scripts/dockerUtils.groovy b/.ci/jenkins/shared-scripts/dockerUtils.groovy new file mode 100644 index 0000000000..9f78c06dac --- /dev/null +++ b/.ci/jenkins/shared-scripts/dockerUtils.groovy @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Push an image to a given registry +*/ +def pushImageToRegistry(String registry, String image, String tags, String credentialsId) { + withCredentials([usernamePassword(credentialsId: credentialsId, usernameVariable: 'REGISTRY_USER', passwordVariable: 'REGISTRY_PWD')]) { + sh "set +x && docker login -u $REGISTRY_USER -p $REGISTRY_PWD $registry" + tagList = tags.split(' ') + for (tag in tagList) { + sh "docker push $registry/$image:$tag" + } + sh 'docker logout' + } +} + +return this; diff --git a/.ci/jenkins/shared-scripts/githubUtils.groovy b/.ci/jenkins/shared-scripts/githubUtils.groovy new file mode 100644 index 0000000000..b5378ab021 --- /dev/null +++ b/.ci/jenkins/shared-scripts/githubUtils.groovy @@ -0,0 +1,180 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Create a Github release +* +* @return String with the release information +*/ +def createRelease(String repository, String name, String tag, String commit, Boolean draft, Boolean preRelease, String credentialsId) { + withCredentials([string(credentialsId: credentialsId, variable: 'GITHUB_TOKEN')]) { + response = sh returnStdout: true, script: """ + set +x + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${repository}/releases \ + -d '{"tag_name": "${tag}", "target_commitish": "${commit}", "name": "${name}", "draft": ${draft}, "prerelease": ${preRelease}' + """.trim() + + return response + } +} + +/** +* Fetch a Github Release by tag +* +* @return String with the release information +*/ +def fetchRelease(String repository, String tag, String credentialsId) { + withCredentials([string(credentialsId: credentialsId, variable: 'GITHUB_TOKEN')]) { + response = sh returnStdout: true, script: """ + set +x + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${repository}/releases/tags/${tag} + """.trim() + + return response + } +} + +/** +* Upload an asset to a GitHub release +* +* @return String with the release asset information +*/ +def uploadReleaseAsset(String uploadUrl, String assetPath, String assetName, String assetContentType, String credentialsId) { + withCredentials([string(credentialsId: credentialsId, variable: 'GITHUB_TOKEN')]) { + response = sh returnStdout: true, script: """ + set +x + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: ${assetContentType}" \ + "${uploadUrl}?name=${assetName}" \ + --data-binary "@${assetPath}" + """.trim() + + return response + } +} + +/** +* Set build status +*/ +def commitStatus(String repository, String commit, String context, String state, String jobUrl) { + withCredentials([string(credentialsId: credentialsId, variable: 'GITHUB_TOKEN')]) { + response = sh returnStdout: true, script: """ + set +x + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/${repository}/statuses/${commit} \ + -d '{"state":"${state}","target_url":"${jobUrl}","description":"${message}","context":"${context}"}' + """.trim() + + return response + } +} + +/** +* Parse an release upload asset url to remove unecessary strings +*/ +def parseReleaseAssetUploadUrl(String uploadUrl) { + return uploadUrl.replace('{?name,label}', '') +} + +/** +* Checkout a github repository using GitSCM class +*/ +def checkoutRepo(String url, String branch, String credentialsId) { + checkout([$class: 'GitSCM', + branches: [[name: "${branch}"]], + doGenerateSubmoduleConfigurations: false, + extensions: [[$class: 'CleanCheckout']], + submoduleCfg: [], + userRemoteConfigs: [[credentialsId: credentialsId, url: "${url}"]] + ]) +} + +/** +* Perform a squashed merge on a local repository +*/ +def squashedMerge(String author, String branch, String url) { + sh """#!/bin/bash -el + git config --global user.email "[email protected]" + git config --global user.name "KIE Tools Bot (kiegroup)" + git remote add ${author} ${url} + git fetch ${author} ${branch} + git merge --squash ${author}/${branch} + git commit --no-edit + """.trim() +} + +/** +* Checkout a github repository and perform a squashed merge on a local repository +*/ +def checkoutRepoSquashedMerge(String author, String branch, String url, String targetBranch, String targetUrl, String credentialsId) { + checkoutRepo(targetUrl, targetBranch, credentialsId) + if (author && branch && url) { + squashedMerge(author, branch, url) + } else { + echo 'Skip squashed merge, not a pull request' + } +} + +/** +* @return the Github repository slug (org/repo) from an URL +*/ +def getRepoSlug(String url) { + tokens = url.tokenize('/') + org = tokens[tokens.size()-4] + repo = tokens[tokens.size()-3] + + return "${org}/${repo}" +} + +/** +* @return the files changed in the last commit +*/ +def getChangesetLastCommit() { + changeset = sh returnStdout: true, script: ''' + git diff --name-only HEAD HEAD~1 + '''.trim() + + return changeset +} + +/** +* @return if a given file is in the changeset of the last commit +*/ +def fileIsInChangeset(String file) { + changeset = getChangesetLastCommit() + + return changeset.contains(file) +} + +return this; diff --git a/.ci/jenkins/shared-scripts/openShiftUtils.groovy b/.ci/jenkins/shared-scripts/openShiftUtils.groovy new file mode 100644 index 0000000000..729c4d7671 --- /dev/null +++ b/.ci/jenkins/shared-scripts/openShiftUtils.groovy @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Create or update an existing application in a Openshift cluster +*/ +def createOrUpdateApp(String project, String appName, String imageTag, String imageUrl, String partOf, String deploymentIcon, String credentialsId, String deploymentEnvVarsPath='./deployment.env') { + withCredentials([usernamePassword(credentialsId: credentialsId, usernameVariable: 'OS_SERVER', passwordVariable: 'OS_TOKEN')]) { + sh 'set +x && oc login --token=$OS_TOKEN --server=$OS_SERVER --insecure-skip-tls-verify' + sh """#!/bin/bash -el + oc project ${project} + + if [ ! -f ${deploymentEnvVarsPath} ]; then + echo "ENV file does not exist" + touch ${deploymentEnvVarsPath} + fi + + if ! oc get deploy ${appName} > /dev/null 2>&1; then + echo "Create the app '${appName}'" + + oc create imagestream ${appName} + oc import-image ${appName}:${imageTag} --from=${imageUrl} --confirm + oc tag ${appName}:${imageTag} ${appName}:latest + + oc label imagestreams/${appName} app=${appName} + oc label imagestreams/${appName} app.kubernetes.io/component=${appName} + oc label imagestreams/${appName} app.kubernetes.io/instance=${appName} + oc label imagestreams/${appName} app.kubernetes.io/part-of=${partOf} + + oc new-app ${appName}:latest --name=${appName} --env-file=${deploymentEnvVarsPath} + oc create route edge --service=${appName} + + oc label services/${appName} app.kubernetes.io/part-of=${partOf} + oc label routes/${appName} app.kubernetes.io/part-of=${partOf} + oc label deployments/${appName} app.kubernetes.io/part-of=${partOf} + oc label deployments/${appName} app.openshift.io/runtime=${deploymentIcon} + else + echo "App '${appName}' already exists. Update the ImageStream instead." + oc tag -d ${appName}:latest + oc import-image ${appName}:${imageTag} --from=${imageUrl} --confirm + oc tag ${appName}:${imageTag} ${appName}:latest + cat ${deploymentEnvVarsPath} | oc set env deploy/${appName} - + fi + """.trim() + sh 'oc logout' + } +} + +/** +* @return String route to the OpenShift application +*/ +def getAppRoute(String project, String appName, String credentialsId) { + withCredentials([usernamePassword(credentialsId: credentialsId, usernameVariable: 'OS_SERVER', passwordVariable: 'OS_TOKEN')]) { + sh 'set +x && oc login --token=$OS_TOKEN --server=$OS_SERVER --insecure-skip-tls-verify' + sh "oc project ${project}" + route = sh(returnStdout: true, script: "oc get route ${appName} -o jsonpath='{.spec.host}'").trim() + sh 'oc logout' + + return "https://${route}" + } +} + +return this; diff --git a/.ci/jenkins/shared-scripts/pipelineVars.groovy b/.ci/jenkins/shared-scripts/pipelineVars.groovy new file mode 100644 index 0000000000..c278e882aa --- /dev/null +++ b/.ci/jenkins/shared-scripts/pipelineVars.groovy @@ -0,0 +1,20 @@ +class PipelineVars implements Serializable { + + String githubRepositoryOrg = 'apache'; + String githubRepositoryName = 'incubator-kie-tools-temporary-rnd-do-not-use'; + String githubRepositorySlug = 'apache/incubator-kie-tools-temporary-rnd-do-not-use'; + + String quayPushCredentialsId = 'quay-io-kie-tools-token'; + String openshiftCredentialsId = 'openshift-kie-tools-token'; + String kieToolsBotGithubCredentialsId = 'kie-tools-bot-gh'; + String kieToolsBotGithubTokenCredentialsId = 'kie-tools-bot-gh-token'; + String kieToolsGithubCodeQLTokenCredentialsId = 'kie-tools-gh-codeql-token'; + String chromeStoreCredentialsId = 'kie-tools-chome-store'; + String chromeStoreRefreshTokenCredentialsId = 'kie-tools-chome-store-refresh-token'; + String npmTokenCredentialsId = 'kie-tools-npm-token'; + + String defaultArtifactsTempDir = 'artifacts-tmp'; + +} + +return new PipelineVars(); diff --git a/.ci/jenkins/shared-scripts/zipUtils.groovy b/.ci/jenkins/shared-scripts/zipUtils.groovy new file mode 100644 index 0000000000..1521ce5312 --- /dev/null +++ b/.ci/jenkins/shared-scripts/zipUtils.groovy @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** +* Compress a build artifact to a zip file +*/ +def zipArtifact(String filePath, String patterns) { + sh """#!/bin/bash -el + output_empty_zip () { echo UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA== | base64 -d; } + zip -r ${filePath} ${patterns} || output_empty_zip > ${filePath} + """.trim() +} + +/** +* Unzip an build artifact +*/ +def unzipArtifact(String filePath, String targetDir) { + sh """#!/bin/bash -el + unzip ${filePath} -d ${targetDir} + """.trim() +} + +return this; diff --git a/.github/actions/checkout-pr/action.yml b/.github/actions/checkout-pr/action.yml index ae9136c5e4..5bda551c14 100644 --- a/.github/actions/checkout-pr/action.yml +++ b/.github/actions/checkout-pr/action.yml @@ -45,7 +45,7 @@ runs: user=$(node -e "console.log('${{ github.event.pull_request.head.label }}'.match(/(.+)\:(.+)$/)[1])") echo "Merge changes from $user/${{ github.head_ref }}" - git remote add $user https://github.com/$user/kie-tools.git + git remote add $user https://github.com/$user/incubator-kie-tools-temporary-rnd-do-not-use.git git fetch $user ${{ github.head_ref }} echo "Before merging..." diff --git a/.github/actions/setup-env/action.yml b/.github/actions/setup-env/action.yml index 85503c81fe..a55fa05fd7 100644 --- a/.github/actions/setup-env/action.yml +++ b/.github/actions/setup-env/action.yml @@ -10,22 +10,6 @@ inputs: runs: using: "composite" steps: - # This cleans up the GitHub action images, removing unnecessary packages such as Android Studio and DOTNet libraries. - # This can provide up to 7GB of free space for the rest of the build. - - name: "Clear storage usage from unnecessary packages" - uses: jlumbroso/free-disk-space@76866dbe54312617f00798d1762df7f43def6e5c - if: runner.os == 'Linux' - with: - # this might remove tools that are actually needed, - # if set to "true" but frees about 6 GB - tool-cache: false - # other packages - android: true - dotnet: true - haskell: true - large-packages: false - swap-storage: false - - name: "Print storage usage (before setup)" shell: bash run: | @@ -41,7 +25,7 @@ runs: mkdir tmp - name: "Setup pnpm" - uses: pnpm/action-setup@c3b53f6a16e57305370b4ae5a540c2077a1d50dd + uses: pnpm/action-setup@v2 with: version: 8.7.0 @@ -51,7 +35,7 @@ runs: node-version: 18.14.0 - name: "Setup JDK 11" - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc + uses: actions/setup-java@v3 with: java-version: 11 distribution: "zulu" @@ -62,7 +46,7 @@ runs: go-version: "1.21.1" - name: "Set up Maven" - uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f #v4.5 + uses: stCarolas/[email protected] with: maven-version: 3.8.6 diff --git a/.github/workflows/ci_build.yml b/.github/workflows/ci_build.yml index 33f65a21f7..6bbd52ba25 100644 --- a/.github/workflows/ci_build.yml +++ b/.github/workflows/ci_build.yml @@ -1,4 +1,4 @@ -name: "CI :: Build" +name: "CI :: Build (Windows and MacOS)" on: push: @@ -21,7 +21,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + os: [macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - name: "Support longpaths" @@ -71,10 +71,6 @@ jobs: echo "Done" - - name: "Start telemetry service (`main` only)" - if: steps.setup_build_mode.outputs.mode != 'none' && !github.event.pull_request - uses: runforesight/workflow-telemetry-action@6705383eabd01833acfe8412ec697384830e1455 #v1.8.7 - - name: "Setup environment" if: steps.setup_build_mode.outputs.mode != 'none' uses: ./.github/actions/setup-env diff --git a/.github/workflows/ci_check_code_formatting.yml b/.github/workflows/ci_check_code_formatting.yml index 6ab373da22..3a8f604444 100644 --- a/.github/workflows/ci_check_code_formatting.yml +++ b/.github/workflows/ci_check_code_formatting.yml @@ -1,10 +1,11 @@ name: "CI :: Code formatting" on: - push: - branches: [main] - pull_request: - branches: ["**"] + workflow_dispatch: + # push: + # branches: [main] + # pull_request: + # branches: ["**"] concurrency: group: ${{ github.event.pull_request && format('check-code-formatting-pr-{0}', github.event.pull_request.number) || format('check-code-formatting-push-main-{0}', github.sha) }} diff --git a/.github/workflows/ci_check_dependencies_consistency.yaml b/.github/workflows/ci_check_dependencies_consistency.yaml index 2105e1ea2a..7110803e5a 100644 --- a/.github/workflows/ci_check_dependencies_consistency.yaml +++ b/.github/workflows/ci_check_dependencies_consistency.yaml @@ -1,10 +1,11 @@ name: "CI :: Dependencies consistency" on: - push: - branches: [main] - pull_request: - branches: ["**"] + workflow_dispatch: + # push: + # branches: [main] + # pull_request: + # branches: ["**"] concurrency: group: ${{ github.event.pull_request && format('check-dependencies-consistency-pr-{0}', github.event.pull_request.number) || format('check-dependencies-consistency-push-main-{0}', github.sha) }} diff --git a/.github/workflows/ci_codeql.yml b/.github/workflows/ci_codeql.yml index 36584f7474..ebd69b7174 100644 --- a/.github/workflows/ci_codeql.yml +++ b/.github/workflows/ci_codeql.yml @@ -12,11 +12,11 @@ name: "CI :: CodeQL" on: - push: - branches: [main] - pull_request: - # The branches below must be a subset of the branches above - branches: [main] + # push: + # branches: [main] + # pull_request: + # # The branches below must be a subset of the branches above + # branches: [main] schedule: - cron: "31 15 * * 0" diff --git a/.github/workflows/ci_sonar_analysis_stunner_editors.yml b/.github/workflows/ci_sonar_analysis_stunner_editors.yml index 9f90939b5a..f9f05444fa 100644 --- a/.github/workflows/ci_sonar_analysis_stunner_editors.yml +++ b/.github/workflows/ci_sonar_analysis_stunner_editors.yml @@ -1,11 +1,12 @@ name: "CI :: Sonar :: stunner-editors" on: - push: - branches: - - main - paths: - - "packages/stunner-editors/**" - - ".github/workflows/ci_sonar_analysis_stunner_editors.yml" + workflow_dispatch: + # push: + # branches: + # - main + # paths: + # - "packages/stunner-editors/**" + # - ".github/workflows/ci_sonar_analysis_stunner_editors.yml" jobs: check: diff --git a/.github/workflows/daily_dev_publish.yml b/.github/workflows/daily_dev_publish.yml index 7b489c676b..1c184d8e0e 100644 --- a/.github/workflows/daily_dev_publish.yml +++ b/.github/workflows/daily_dev_publish.yml @@ -1,12 +1,12 @@ name: "Daily dev :: Publish" on: - schedule: - - cron: "0 2 * * *" # 2am UTC everyday + # schedule: + # - cron: "0 2 * * *" # 2am UTC everyday workflow_dispatch: - pull_request: - paths: - - ".github/workflows/daily_dev_publish.yml" + # pull_request: + # paths: + # - ".github/workflows/daily_dev_publish.yml" concurrency: group: ${{ github.event.pull_request && format('daily-dev-publish-pr-{0}', github.event.pull_request.number) || format('daily-dev-publish-ref-{0}', github.ref_name) }} diff --git a/.github/workflows/jenkins-tests-PR.yml b/.github/workflows/jenkins-tests-PR.yml index bea36579da..b667a5d4c6 100644 --- a/.github/workflows/jenkins-tests-PR.yml +++ b/.github/workflows/jenkins-tests-PR.yml @@ -2,12 +2,13 @@ # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven name: Jenkins Tests on: - pull_request: - branches: - - "main" - paths: - - ".ci/jenkins/**" - - ".github/workflows/jenkins-tests-PR.yml" + workflow_dispatch: + # pull_request: + # branches: + # - "main" + # paths: + # - ".ci/jenkins/**" + # - ".github/workflows/jenkins-tests-PR.yml" jobs: dsl-tests: diff --git a/.github/workflows/publish_jitexecutor_native.yml b/.github/workflows/publish_jitexecutor_native.yml index 9cf7482ecd..0dd09f4108 100644 --- a/.github/workflows/publish_jitexecutor_native.yml +++ b/.github/workflows/publish_jitexecutor_native.yml @@ -34,13 +34,13 @@ jobs: ref: ${{ github.event.inputs.kogito_runtime_version }} - name: "Set up Maven" - uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f #v4.5 + uses: stCarolas/[email protected] with: maven-version: 3.8.6 - name: "Set up JDK 11" if: runner.os != 'Windows' - uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc + uses: actions/setup-java@v3 with: java-version: "11" distribution: "zulu" @@ -78,7 +78,7 @@ jobs: - name: "Setup MSCV" if: runner.os == 'Windows' - uses: ilammy/msvc-dev-cmd@cec98b9d092141f74527d0afa6feb2af698cfe89 #v1.12.1 + uses: ilammy/msvc-dev-cmd@v1 - name: "Setup MSBUILD" if: runner.os == 'Windows' diff --git a/.github/workflows/release_build_extended_services.yml b/.github/workflows/release_build_extended_services.yml new file mode 100644 index 0000000000..1818f7af30 --- /dev/null +++ b/.github/workflows/release_build_extended_services.yml @@ -0,0 +1,87 @@ +name: "Release :: Build (Extended Services)" + +on: + workflow_call: + inputs: + dry_run: + type: boolean + required: true + base_ref: + type: string + required: true + tag: + type: string + required: false + default: "0.0.0" + upload_asset_url: + type: string + required: false + default: "" + secrets: + gh_token: + required: false + +env: + KIE_TOOLS_BUILD__runLinters: "false" + KIE_TOOLS_BUILD__runTests: "false" + KIE_TOOLS_BUILD__runEndToEndTests: "false" + KIE_TOOLS_BUILD__buildContainerImages: "true" + +jobs: + extended_services: + env: + EXTENDED_SERVICES__kieSandboxUrl: "https://kiegroup.github.io/kogito-online" + + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, windows-latest] + steps: + - name: "Support longpaths (Windows only)" + if: runner.os == 'Windows' + run: git config --system core.longpaths true + + - name: "Checkout @ GitHub default" + uses: actions/checkout@v3 + + - name: "Checkout @ Simulated squashed-merge if PR" + uses: ./.github/actions/checkout-pr + with: + ref: ${{ inputs.base_ref }} + + - name: "Setup environment" + id: setup_env + uses: ./.github/actions/setup-env + + - name: "Bootstrap" + id: bootstrap + uses: ./.github/actions/bootstrap + with: + pnpm_filter_string: -F @kie-tools/extended-services... + + - name: "Build" + shell: bash + run: | + pnpm ${{ steps.bootstrap.outputs.pnpm_filter_string }} build:prod + + - name: "Upload Extended Services for macOS (macOS only)" + if: ${{ runner.os == 'macOS' && !inputs.dry_run }} + uses: actions/[email protected] + env: + GITHUB_TOKEN: ${{ secrets.gh_token }} + with: + upload_url: ${{ inputs.upload_asset_url }} + asset_path: ./packages/extended-services/dist/darwin/Kogito.dmg + asset_name: kie_sandbox_extended_services_macos_${{ inputs.tag }}.dmg + asset_content_type: application/octet-stream + + - name: "Upload Extended Services for Windows (Windows only)" + if: ${{ runner.os == 'Windows' && !inputs.dry_run }} + uses: actions/[email protected] + env: + GITHUB_TOKEN: ${{ secrets.gh_token }} + with: + upload_url: ${{ inputs.upload_asset_url }} + asset_path: "./packages/extended-services/dist/win32/kie_sandbox_extended_services.exe" + asset_name: "kie_sandbox_extended_services_windows_${{ inputs.tag }}.exe" + asset_content_type: application/octet-stream diff --git a/.github/workflows/release_dry_run.yml b/.github/workflows/release_dry_run.yml index 612b4425b4..2ad86dbe0a 100644 --- a/.github/workflows/release_dry_run.yml +++ b/.github/workflows/release_dry_run.yml @@ -2,13 +2,13 @@ name: "Release :: Dry Run" on: workflow_dispatch: - schedule: - - cron: "0 4 * * *" # 4am UTC everyday - pull_request: - branches: ["**"] - paths: - - ".github/workflows/release*" - - ".github/actions/**" + # schedule: + # - cron: "0 4 * * *" # 4am UTC everyday + # pull_request: + # branches: ["**"] + # paths: + # - ".github/workflows/release*" + # - ".github/actions/**" concurrency: group: ${{ github.event.pull_request && format('release-dry-run-pr-{0}', github.event.pull_request.number) || format('release-dry-run-ref-{0}', github.ref_name) }} diff --git a/.github/workflows/staging_dry_run.yml b/.github/workflows/release_dry_run_extended_services.yml similarity index 50% copy from .github/workflows/staging_dry_run.yml copy to .github/workflows/release_dry_run_extended_services.yml index 240534b9bd..1f681d830c 100644 --- a/.github/workflows/staging_dry_run.yml +++ b/.github/workflows/release_dry_run_extended_services.yml @@ -1,22 +1,22 @@ -name: "Staging :: Dry Run" +name: "Release :: Dry Run (Extended Services)" on: workflow_dispatch: schedule: - - cron: "0 3 * * *" # 3am UTC everyday + - cron: "0 4 * * *" # 4am UTC everyday pull_request: branches: ["**"] paths: - - ".github/workflows/staging*" + - ".github/workflows/release*" - ".github/actions/**" concurrency: - group: ${{ github.event.pull_request && format('staging-dry-run-pr-{0}', github.event.pull_request.number) || format('staging-dry-run-ref-{0}', github.ref_name) }} + group: ${{ github.event.pull_request && format('release-dry-run-pr-{0}', github.event.pull_request.number) || format('release-dry-run-ref-{0}', github.ref_name) }} cancel-in-progress: true jobs: dry_run: - uses: ./.github/workflows/staging_build.yml + uses: ./.github/workflows/release_build_extended_services.yml with: dry_run: true base_ref: ${{ github.event.pull_request && github.base_ref || github.ref }} diff --git a/.github/workflows/release_publish_extended_services.yml b/.github/workflows/release_publish_extended_services.yml new file mode 100644 index 0000000000..0dfe102d3a --- /dev/null +++ b/.github/workflows/release_publish_extended_services.yml @@ -0,0 +1,47 @@ +name: "Release :: Publish (Extended Services)" + +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + description: "Tag associated with the release" + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + upload_asset_url: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).upload_url }} + release_ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }} + steps: + - name: "Fetch release for ${{ github.event.inputs.tag }}" + uses: octokit/[email protected] + id: fetch_release_for_tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + route: GET /repos/{repo}/releases/tags/{tag} + repo: ${{ github.repository }} + tag: ${{ github.event.inputs.tag }} + + - name: "Checkout" + uses: actions/checkout@v3 + with: + ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }} + + - name: "Check `tag` against `(package.json).version`" + shell: bash + run: | + [ "${{ github.event.inputs.tag }}" == "$(node -p "require('./package.json').version")" ] + + build_and_publish: + needs: [prepare] + uses: ./.github/workflows/release_build_extended_services.yml + with: + dry_run: false + base_ref: ${{ needs.prepare.outputs.release_ref }} + tag: ${{ github.event.inputs.tag }} + upload_asset_url: ${{ needs.prepare.outputs.upload_asset_url }} + secrets: + gh_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/staging_build_extended_services.yml b/.github/workflows/staging_build_extended_services.yml new file mode 100644 index 0000000000..77e748d85c --- /dev/null +++ b/.github/workflows/staging_build_extended_services.yml @@ -0,0 +1,89 @@ +name: "Staging :: Build (Extended Services)" + +on: + workflow_call: + inputs: + dry_run: + type: boolean + required: true + base_ref: + type: string + required: true + tag: + type: string + required: false + default: "0.0.0" + upload_asset_url: + type: string + required: false + default: "" + secrets: + gh_token: + required: false + +env: + TMPDIR: "${{ github.workspace }}/kie-tools/tmp" + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [macos-latest, windows-latest] + steps: + - name: "Support longpaths (Windows only)" + if: runner.os == 'Windows' + run: git config --system core.longpaths true + + - name: "Checkout @ GitHub default" + uses: actions/checkout@v3 + with: + path: kie-tools + + - name: "Checkout @ Simulated squashed-merge if PR" + uses: ./kie-tools/.github/actions/checkout-pr + with: + ref: ${{ inputs.base_ref }} + path: kie-tools + + - name: "Setup environment" + uses: ./kie-tools/.github/actions/setup-env + with: + working_dir: kie-tools + + - name: "Bootstrap" + id: bootstrap + uses: ./kie-tools/.github/actions/bootstrap + with: + working_dir: kie-tools + pnpm_filter_string: -F @kie-tools/extended-services... + + - name: "Build Extended Services" + working-directory: ${{ github.workspace }}/kie-tools + env: + EXTENDED_SERVICES__kieSandboxUrl: "https://kiegroup.github.io/kogito-online-staging/${{ inputs.tag }}-prerelease" + run: >- + pnpm ${{ steps.bootstrap.outputs.pnpm_filter_string }} build:prod + + - name: "STAGING: Upload Extended Services for macOS (macOS only)" + if: ${{ runner.os == 'macOS' && !inputs.dry_run }} + uses: actions/[email protected] + env: + GITHUB_TOKEN: ${{ secrets.gh_token }} + with: + upload_url: ${{ inputs.upload_asset_url }} + asset_path: ${{ github.workspace }}/kie-tools/packages/extended-services/dist/darwin/Kogito.dmg + asset_name: STAGING__kie_sandbox_extended_services_macos_${{ inputs.tag }}.dmg + asset_content_type: application/octet-stream + + - name: "STAGING: Upload Extended Services for Windows (Windows only)" + if: ${{ runner.os == 'Windows' && !inputs.dry_run }} + uses: actions/[email protected] + env: + GITHUB_TOKEN: ${{ secrets.gh_token }} + with: + upload_url: ${{ inputs.upload_asset_url }} + asset_path: "${{ github.workspace }}/kie-tools/packages/extended-services/dist/win32/kie_sandbox_extended_services.exe" + asset_name: "STAGING__kie_sandbox_extended_services_windows_${{ inputs.tag }}.exe" + asset_content_type: application/octet-stream diff --git a/.github/workflows/staging_dry_run.yml b/.github/workflows/staging_dry_run.yml index 240534b9bd..7b5ba4da0d 100644 --- a/.github/workflows/staging_dry_run.yml +++ b/.github/workflows/staging_dry_run.yml @@ -2,13 +2,13 @@ name: "Staging :: Dry Run" on: workflow_dispatch: - schedule: - - cron: "0 3 * * *" # 3am UTC everyday - pull_request: - branches: ["**"] - paths: - - ".github/workflows/staging*" - - ".github/actions/**" + # schedule: + # - cron: "0 3 * * *" # 3am UTC everyday + # pull_request: + # branches: ["**"] + # paths: + # - ".github/workflows/staging*" + # - ".github/actions/**" concurrency: group: ${{ github.event.pull_request && format('staging-dry-run-pr-{0}', github.event.pull_request.number) || format('staging-dry-run-ref-{0}', github.ref_name) }} diff --git a/.github/workflows/staging_dry_run.yml b/.github/workflows/staging_dry_run_extended_services.yml similarity index 82% copy from .github/workflows/staging_dry_run.yml copy to .github/workflows/staging_dry_run_extended_services.yml index 240534b9bd..6b04f976e6 100644 --- a/.github/workflows/staging_dry_run.yml +++ b/.github/workflows/staging_dry_run_extended_services.yml @@ -1,4 +1,4 @@ -name: "Staging :: Dry Run" +name: "Staging :: Dry Run (Extended Services)" on: workflow_dispatch: @@ -16,7 +16,7 @@ concurrency: jobs: dry_run: - uses: ./.github/workflows/staging_build.yml + uses: ./.github/workflows/staging_build_extended_services.yml with: dry_run: true base_ref: ${{ github.event.pull_request && github.base_ref || github.ref }} diff --git a/.github/workflows/staging_publish.yml b/.github/workflows/staging_publish.yml index 985a75e9cf..0336620102 100644 --- a/.github/workflows/staging_publish.yml +++ b/.github/workflows/staging_publish.yml @@ -1,8 +1,9 @@ name: "Staging :: Publish" on: - push: - branches: ["**-prerelease"] + workflow_dispatch: + # push: + # branches: ["**-prerelease"] concurrency: group: staging-publish diff --git a/.github/workflows/staging_publish_extended_services.yml b/.github/workflows/staging_publish_extended_services.yml new file mode 100644 index 0000000000..a644bf8db0 --- /dev/null +++ b/.github/workflows/staging_publish_extended_services.yml @@ -0,0 +1,51 @@ +name: "Staging :: Publish (Extended Services)" + +on: + workflow_dispatch: + inputs: + tag: + type: string + required: true + description: "Tag associated with the pre-release" + +concurrency: + group: staging-publish + cancel-in-progress: true + +jobs: + prepare: + runs-on: ubuntu-latest + outputs: + upload_asset_url: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).upload_url }} + release_ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }} + steps: + - name: "Fetch pre-release for ${{ github.event.inputs.tag }}" + uses: octokit/[email protected] + id: fetch_release_for_tag + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + route: GET /repos/{repo}/releases/tags/{tag} + repo: ${{ github.repository }} + tag: ${{ github.event.inputs.tag }} + + - name: "Checkout" + uses: actions/checkout@v3 + with: + ref: ${{ fromJSON(steps.fetch_release_for_tag.outputs.data).target_commitish }} + + - name: "Check `tag` against `(package.json).version`" + shell: bash + run: | + [ "${{ github.event.inputs.tag }}" == "$(node -p "require('./package.json').version")" ] + + build_and_publish: + needs: [prepare] + uses: ./.github/workflows/staging_build_extended_services.yml + with: + dry_run: false + base_ref: ${{ needs.prepare.outputs.release_ref }} + tag: ${{ github.event.inputs.tag }} + upload_asset_url: ${{ needs.prepare.outputs.upload_asset_url }} + secrets: + gh_token: ${{ secrets.GITHUB_TOKEN }} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
