Skip to content

Commit

Permalink
Add Maven project and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Mar 21, 2024
1 parent b32d4e8 commit 2dbe708
Show file tree
Hide file tree
Showing 11 changed files with 773 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: GitHub Actions Build

on:
push:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-github-bot-playground' }}

defaults:
run:
shell: bash

env:
MAVEN_ARGS: "-e -B --fail-at-end"

jobs:
build:
name: ${{matrix.os.name}}
runs-on: ${{ matrix.os.runs-on }}
strategy:
fail-fast: false
matrix:
os:
- {
name: "Linux JDK 17",
runs-on: 'ubuntu-latest',
java: {
version: 17
}
}
# We can't start Linux containers on GitHub Actions' Windows VMs,
# so we can't run Elasticsearch tests.
# See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995
- {
name: "Windows JDK 17",
runs-on: 'windows-latest',
java: {
version: 17
}
}
steps:
- name: Support longpaths on Windows
if: "startsWith(matrix.os.runs-on, 'windows')"
run: git config --global core.longpaths true
- uses: actions/checkout@v4
with:
# Fetch the whole history to make sure that gitflow incremental builder
# can find the base commit.
fetch-depth: 0
- name: Set up Java ${{ matrix.os.java.version }}
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.os.java.version }}
distribution: temurin
- name: Set up Maven
run: ./mvnw -v
- name: Building code and running unit tests and basic checks
run: |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
-Pjqassistant -Pdist -Pci-build -DskipITs
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Running integration tests in the default environment
run: |
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
-Pskip-checks \
${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }}
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ nb-configuration.xml

# Local environment
.env

# Gradle Enterprise/Develocity
/.mvn/.gradle-enterprise
12 changes: 12 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<extensions>
<extension>
<groupId>com.gradle</groupId>
<artifactId>gradle-enterprise-maven-extension</artifactId>
<version>1.20.1</version>
</extension>
<extension>
<groupId>com.gradle</groupId>
<artifactId>common-custom-user-data-maven-extension</artifactId>
<version>1.13</version>
</extension>
</extensions>
41 changes: 41 additions & 0 deletions .mvn/gradle-enterprise.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<gradleEnterprise
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/gradle-enterprise-maven https://www.gradle.com/schema/gradle-enterprise-maven.xsd">
<server>
<url>https://ge.hibernate.org</url>
<allowUntrusted>false</allowUntrusted>
</server>
<buildScan>
<!-- adjust conditions ?
mvn gradle-enterprise:provision-access-key
https://docs.gradle.com/enterprise/maven-extension/#publishing_based_on_criteria
-->
<!-- build scan publication is configured in gradle-enterprise-custom-user-data.groovy
to leverage options to disable build scan publication for test builds
-->
<!--
Expression support is documented here: https://docs.gradle.com/enterprise/maven-extension/#expression_support
-->
<obfuscation>
<!-- Don't share ip addresses-->
<ipAddresses>#{{'0.0.0.0'}}</ipAddresses>
</obfuscation>
<capture>
<goalInputFiles>true</goalInputFiles>
</capture>
<!-- https://docs.gradle.com/enterprise/maven-extension/#manual_access_key_configuration -->
<backgroundBuildScanUpload>#{env['CI'] == null}</backgroundBuildScanUpload>
</buildScan>
<buildCache>
<local>
<enabled>#{properties['no-build-cache'] == null}</enabled>
</local>
<remote>
<enabled>#{properties['no-build-cache'] == null}</enabled>
<storeEnabled>#{env['CI'] != null and (env['CHANGE_ID']?:'').isBlank() and (env['GITHUB_BASE_REF']?:'').isBlank() and !(env['GRADLE_ENTERPRISE_ACCESS_KEY']?:'').isBlank()}</storeEnabled>
<server>
<url>https://ge.hibernate.org/cache/hsearchtest01/</url>
</server>
</remote>
</buildCache>
</gradleEnterprise>
1 change: 1 addition & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED
Binary file added .mvn/wrapper/maven-wrapper.jar
Binary file not shown.
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.6/apache-maven-3.9.6-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
68 changes: 68 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
def withMavenWorkspace(Closure body) {
withMaven(jdk: 'OpenJDK 17 Latest', maven: 'Apache Maven 3.9',
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository',
options: [
artifactsPublisher(disabled: true),
junitPublisher(disabled: true)
]) {
withCredentials([string(credentialsId: 'ge.hibernate.org-access-key',
variable: 'GRADLE_ENTERPRISE_ACCESS_KEY')]) {
withGradle { // withDevelocity, actually: https://plugins.jenkins.io/gradle/#plugin-content-capturing-build-scans-from-jenkins-pipeline
body()
}
}
}
}

pipeline {
agent none
options {
buildDiscarder logRotator(daysToKeepStr: '10', numToKeepStr: '3')
disableConcurrentBuilds(abortPrevious: true)
}
stages {
stage('Default build') {
agent {
label 'Worker&&Containers'
}
steps {
timeout(time: 30, unit: 'MINUTES') {
withMavenWorkspace {
sh "mvn clean install -U -Pdist -DskipTests"
dir(env.WORKSPACE_TMP + '/.m2repository') {
stash name: 'original-build-result', includes: "org/hibernate/infra/"
}
}
}
}
}
stage('Non-default envs') {
matrix {
axes {
axis {
name 'ENV_NAME'
values 'elasticsearch-7', 'postgresql', 'opensearch-2.12'
}
}
stages {
stage('Build') {
agent {
label 'Worker&&Containers'
}
steps {
dir(env.WORKSPACE_TMP + '/.m2repository') {
unstash name: 'original-build-result'
}
withMavenWorkspace {
sh """ \
mvn clean install -U -Pdependency-update -Pdist -Pci-build -Dscan.tag.${env.ENV_NAME} \
--fail-at-end \
"""
}
}
}
}
}
}
}
}
Loading

0 comments on commit 2dbe708

Please sign in to comment.