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

Use specific Jenkins nodes for releases #4433

Merged
merged 3 commits into from
Dec 16, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
49 changes: 1 addition & 48 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -481,55 +481,8 @@ The Neo4j web UI will be accessible from http://localhost:7474/.

## <a id="ci"></a> 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
Expand Down
37 changes: 3 additions & 34 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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'
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -418,7 +393,6 @@ Resulting execution plan:
enableDefaultBuild=$enableDefaultBuild
enableDefaultBuildIT=$enableDefaultBuildIT
environments=${environments.enabledAsString}
deploySnapshot=$deploySnapshot
incrementalBuild=$incrementalBuild
"""
}
Expand All @@ -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 \
Expand All @@ -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()
Expand Down
27 changes: 24 additions & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ i.e. anybody with direct push access to the git repository.

See [CONTRIBUTING.md](CONTRIBUTING.md).

## Continuous integration
## <a id="ci"></a> 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

Expand Down Expand Up @@ -40,6 +41,26 @@ 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/

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/
Expand Down
2 changes: 1 addition & 1 deletion ci/release/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
53 changes: 53 additions & 0 deletions ci/snapshot-publish/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -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 'Release'
}
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: '[email protected]'
}
}
}
Loading