From ff5e6ded23153fbe6361514128032a09ff6cfc85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 16 Dec 2024 11:27:47 +0100 Subject: [PATCH 1/3] Move snapshot publishing to a separate Jenkinsfile --- CONTRIBUTING.md | 1 - Jenkinsfile | 37 ++--------------------- MAINTAINERS.md | 11 +++++++ ci/snapshot-publish/Jenkinsfile | 53 +++++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 35 deletions(-) create mode 100644 ci/snapshot-publish/Jenkinsfile diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d90060611a..983ec858baf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -507,7 +507,6 @@ For primary branches, it may also re-execute the same build in different environ See [this section](#building-from-source) for information on how to execute similar builds from the commandline. The job can be triggered manually, which is particularly useful to test more environments on a pull request. - ### Release pipeline https://ci.hibernate.org/job/hibernate-search/ diff --git a/Jenkinsfile b/Jenkinsfile index 5d3622ae392..26782c046c7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,15 +51,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap * * ### Integrations * - * #### Nexus deployment - * - * This job is only able to deploy snapshot artifacts, - * for every non-PR build on "primary" branches (main and maintenance branches), - * but the name of a Maven settings file must be provided in the job configuration file - * (see below). - * - * For actual releases, see jenkins/release.groovy. - * * #### AWS * * This job will trigger integration tests against an Elasticsearch service hosted on AWS. @@ -140,11 +131,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap * # See https://docs.gradle.com/enterprise/gradle-plugin/#via_environment_variable * # WARNING: These credentials should not give write access to the build cache! * pr: ... - * deployment: - * maven: - * # String containing the ID of a Maven settings file registered using the config-file-provider Jenkins plugin. - * # The settings must provide credentials to the server with ID 'ossrh'. - * settingsId: ... */ @Field final String DEFAULT_JDK_TOOL = 'OpenJDK 21 Latest' @@ -162,7 +148,6 @@ import org.hibernate.jenkins.pipeline.helpers.alternative.AlternativeMultiMap @Field boolean enableDefaultBuild = false @Field boolean enableDefaultBuildIT = false -@Field boolean deploySnapshot = false @Field boolean incrementalBuild = false this.helper = new JobHelper(this) @@ -375,15 +360,6 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast ]) ]) - if (helper.scmSource.branch.primary && !helper.scmSource.pullRequest) { - if (helper.configuration.file?.deployment?.maven?.settingsId) { - deploySnapshot = true - } - else { - echo "Missing deployment configuration in job configuration file - snapshot deployment will be skipped." - } - } - if (params.ENVIRONMENT_FILTER) { keepOnlyEnvironmentsMatchingFilter(params.ENVIRONMENT_FILTER) } @@ -402,8 +378,7 @@ Some useful filters: 'default', 'jdk', 'jdk-10', 'eclipse', 'postgresql', 'elast enableDefaultBuild = enableDefaultBuildIT || - environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } || - deploySnapshot + environments.content.any { key, envSet -> envSet.enabled.any { buildEnv -> buildEnv.requiresDefaultBuildArtifacts() } } if (helper.scmSource.pullRequest) { incrementalBuild = true @@ -418,7 +393,6 @@ Resulting execution plan: enableDefaultBuild=$enableDefaultBuild enableDefaultBuildIT=$enableDefaultBuildIT environments=${environments.enabledAsString} - deploySnapshot=$deploySnapshot incrementalBuild=$incrementalBuild """ } @@ -430,7 +404,7 @@ stage('Default build') { return } runBuildOnNode( NODE_PATTERN_BASE, [time: 2, unit: 'HOURS'] ) { - withMavenWorkspace(mavenSettingsConfig: deploySnapshot ? helper.configuration.file.deployment.maven.settingsId : null) { + withMavenWorkspace { String commonMavenArgs = """ \ --fail-at-end \ -Pcoverage \ @@ -443,12 +417,7 @@ stage('Default build') { -Pdist \ -Pjqassistant -Pci-build \ -DskipITs \ - clean \ - ${deploySnapshot ? "\ - deploy \ - " : "\ - install \ - "} \ + clean install \ """ // Quick check after the initial build, if we spot the change here, no need to even proceed.. checkNoSourceFilesModifiedOrFail() diff --git a/MAINTAINERS.md b/MAINTAINERS.md index cd75a9e59b9..546482b2014 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -40,6 +40,17 @@ For primary branches, it may also re-execute the same build in different environ See [CONTRIBUTING.md](CONTRIBUTING.md#building-from-source) for information about how to execute similar builds from the commandline. +### Snapshot publishing pipeline + +https://ci.hibernate.org/job/hibernate-search-publish-snapshot/ + +This job takes care of publishing snapshots for primary branches. + +It is triggered automatically on push to each branch, but throttled +to avoid problems when multiple PRs get merged in short span of time. + +See [ci/snapshot-publish/Jenkinsfile](ci/snapshot-publish/Jenkinsfile) for the job definition. + ### Release pipeline https://ci.hibernate.org/job/hibernate-search-release/ diff --git a/ci/snapshot-publish/Jenkinsfile b/ci/snapshot-publish/Jenkinsfile new file mode 100644 index 00000000000..241a94da6d6 --- /dev/null +++ b/ci/snapshot-publish/Jenkinsfile @@ -0,0 +1,53 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * Copyright Red Hat Inc. and Hibernate Authors + */ + +@Library('hibernate-jenkins-pipeline-helpers') _ + +// Avoid running the pipeline on branch indexing +if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) { + print "INFO: Build skipped due to trigger being Branch Indexing" + currentBuild.result = 'NOT_BUILT' + return +} + +pipeline { + agent { + label 'Worker&&Containers' + } + tools { + maven 'Apache Maven 3.9' + jdk 'OpenJDK 21 Latest' + } + options { + // Wait for 1h before publishing snapshots, in case there's more commits. + quietPeriod 3600 + // In any case, never publish snapshots more than once per hour. + rateLimitBuilds(throttle: [count: 1, durationName: 'hour', userBoost: true]) + + buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3')) + disableConcurrentBuilds(abortPrevious: false) + } + stages { + stage('Publish') { + steps { + script { + withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven', + mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') { + sh """mvn \ + -Pci-build \ + -DskipTests \ + clean deploy \ + """ + } + } + } + } + } + post { + always { + notifyBuildResult notifySuccessAfterSuccess: false, maintainers: 'marko@hibernate.org' + } + } +} From 25e02fc35a96d235e36aa236f24cf899f433aef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 16 Dec 2024 11:29:03 +0100 Subject: [PATCH 2/3] Use specific Jenkins nodes for releases --- ci/release/Jenkinsfile | 2 +- ci/snapshot-publish/Jenkinsfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/release/Jenkinsfile b/ci/release/Jenkinsfile index a88f6457499..f7324d54d4a 100644 --- a/ci/release/Jenkinsfile +++ b/ci/release/Jenkinsfile @@ -9,7 +9,7 @@ import org.hibernate.jenkins.pipeline.helpers.version.Version pipeline { agent { - label 'Worker&&Containers' + label 'Release' } tools { maven 'Apache Maven 3.9' diff --git a/ci/snapshot-publish/Jenkinsfile b/ci/snapshot-publish/Jenkinsfile index 241a94da6d6..cc58dda587b 100644 --- a/ci/snapshot-publish/Jenkinsfile +++ b/ci/snapshot-publish/Jenkinsfile @@ -14,7 +14,7 @@ if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) { pipeline { agent { - label 'Worker&&Containers' + label 'Release' } tools { maven 'Apache Maven 3.9' From c2de5753a4c2d3aa784da747094c12a2dae928fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Mon, 16 Dec 2024 13:42:59 +0100 Subject: [PATCH 3/3] Remove/update obsolete documentation about CI --- .github/workflows/ci.yml | 9 ++------ CONTRIBUTING.md | 48 +--------------------------------------- MAINTAINERS.md | 16 +++++++++++--- 3 files changed, 16 insertions(+), 57 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7961af7bf57..53ebb5ed3fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,8 @@ # SPDX-License-Identifier: Apache-2.0 # Copyright Red Hat Inc. and Hibernate Authors -# The main CI of Hibernate Search is https://ci.hibernate.org/job/hibernate-search/. -# However, Hibernate Search builds run on GitHub actions regularly -# to build on Windows -# and check that both the Linux and Windows workflows still work -# and can be used in GitHub forks. -# See https://docs.github.com/en/actions -# for more information about GitHub actions. +# This is not the main CI job, but it is useful on forks. +# See MAINTAINERS.md for details about all available CI jobs. name: GH Actions CI diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 983ec858baf..b40c12faf8c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -481,54 +481,8 @@ The Neo4j web UI will be accessible from http://localhost:7474/. ## Continuous integration -Continuous integration happens on a self-hosted Jenkins instance at https://ci.hibernate.org. +See [MAINTAINERS.md](MAINTAINERS.md#ci) for information about CI. -Several multi-branch pipelines are available. - -### Main pipeline - -https://ci.hibernate.org/job/hibernate-search/ - -See [Jenkinsfile](Jenkinsfile). - -This job takes care of: - -* Primary branch builds -* Pull request builds - -It executes the build in a default environment, at the very least. -For primary branches, it may also re-execute the same build in different environments: - -* Newer JDKs -* Different database vendors (PostgreSQL, Oracle, ...) -* Different versions of Elasticsearch/OpenSearch -* AWS Elasticsearch/OpenSearch Service - -See [this section](#building-from-source) for information on how to execute similar builds from the commandline. - -The job can be triggered manually, which is particularly useful to test more environments on a pull request. -### Release pipeline - -https://ci.hibernate.org/job/hibernate-search/ - -See [Jenkinsfile](Jenkinsfile). - -This job takes care of: - -* Primary branch builds -* Pull request builds - -It executes the build in a default environment, at the very least. -For primary branches, it may also re-execute the same build in different environments: - -* Newer JDKs -* Different database vendors (PostgreSQL, Oracle, ...) -* Different versions of Elasticsearch/OpenSearch -* AWS Elasticsearch/OpenSearch Service - -See [this section](#building-from-source) for information on how to execute similar builds from the commandline. - -The job can be triggered manually, which is particularly useful to test more environments on a pull request. ## More conventions ### Naming and architecture rules diff --git a/MAINTAINERS.md b/MAINTAINERS.md index 546482b2014..d1066ecac12 100644 --- a/MAINTAINERS.md +++ b/MAINTAINERS.md @@ -8,11 +8,12 @@ i.e. anybody with direct push access to the git repository. See [CONTRIBUTING.md](CONTRIBUTING.md). -## Continuous integration +## Continuous integration -Continuous integration happens on a self-hosted Jenkins instance at https://ci.hibernate.org. +Continuous integration happens on a self-hosted Jenkins instance at https://ci.hibernate.org, +and to a smaller extent on GitHub Actions. -Several multi-branch pipelines are available. +Below is a list of all notable workflows/jobs. ### Main pipeline @@ -40,6 +41,15 @@ For primary branches, it may also re-execute the same build in different environ See [CONTRIBUTING.md](CONTRIBUTING.md#building-from-source) for information about how to execute similar builds from the commandline. +### GitHub Actions workflow + +A GitHub Actions workflow is set up, mainly to build/test on Windows, +and to help contributors build Hibernate Search from their own GitHub fork. + +See [.github/workflows](.github/workflows) for the workflow definition. + +See https://docs.github.com/en/actions for more information about GitHub actions. + ### Snapshot publishing pipeline https://ci.hibernate.org/job/hibernate-search-publish-snapshot/