|
| 1 | +# To keep this file consistent on all branches, make sure to specify the library version in the gradle.properties file |
| 2 | +name: Hibernate Reactive CI for Snapshots |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - 'wip/*' |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - 'wip/*' |
| 11 | + # We run the build every hour to check for changes in the snapshots |
| 12 | + schedule: |
| 13 | + # * is a special character in YAML, so you have to quote this string |
| 14 | + # Run every hour at minute 25 |
| 15 | + - cron: '25 * * * *' |
| 16 | + # Allow running this workflow against a specific branch/tag |
| 17 | + workflow_dispatch: |
| 18 | + |
| 19 | +# See https://github.com/hibernate/hibernate-orm/pull/4615 for a description of the behavior we're getting. |
| 20 | +concurrency: |
| 21 | + # Consider that two builds are in the same concurrency group (cannot run concurrently) |
| 22 | + # if they use the same workflow and are about the same branch ("ref") or pull request. |
| 23 | + group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" |
| 24 | + # Cancel previous builds in the same concurrency group even if they are in process |
| 25 | + # for pull requests or pushes to forks (not the upstream repository). |
| 26 | + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-reactive' }} |
| 27 | + |
| 28 | +jobs: |
| 29 | + run_examples: |
| 30 | + name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }} |
| 31 | + runs-on: ubuntu-latest |
| 32 | + strategy: |
| 33 | + matrix: |
| 34 | + example: [ 'session-example', 'native-sql-example' ] |
| 35 | + db: [ 'MySQL', 'PostgreSQL' ] |
| 36 | + exclude: |
| 37 | + # 'native-sql-example' doesn't run on MySQL because it has native queries |
| 38 | + - example: 'native-sql-example' |
| 39 | + db: 'MySQL' |
| 40 | + services: |
| 41 | + # Label used to access the service container |
| 42 | + mysql: |
| 43 | + # Docker Hub image |
| 44 | + image: mysql:8.4.0 |
| 45 | + env: |
| 46 | + MYSQL_ROOT_PASSWORD: hreact |
| 47 | + MYSQL_DATABASE: hreact |
| 48 | + MYSQL_USER: hreact |
| 49 | + MYSQL_PASSWORD: hreact |
| 50 | + # Set health checks to wait until postgres has started |
| 51 | + options: >- |
| 52 | + --health-cmd="mysqladmin ping" |
| 53 | + --health-interval 10s |
| 54 | + --health-timeout 5s |
| 55 | + --health-retries 5 |
| 56 | + ports: |
| 57 | + - 3306:3306 |
| 58 | + postgres: |
| 59 | + # Docker Hub image |
| 60 | + image: postgres:16.3 |
| 61 | + env: |
| 62 | + POSTGRES_DB: hreact |
| 63 | + POSTGRES_USER: hreact |
| 64 | + POSTGRES_PASSWORD: hreact |
| 65 | + # Set health checks to wait until postgres has started |
| 66 | + options: >- |
| 67 | + --health-cmd pg_isready |
| 68 | + --health-interval 10s |
| 69 | + --health-timeout 5s |
| 70 | + --health-retries 5 |
| 71 | + ports: |
| 72 | + - 5432:5432 |
| 73 | + steps: |
| 74 | + - uses: actions/checkout@v2 |
| 75 | + - name: Get year/month for cache key |
| 76 | + id: get-date |
| 77 | + run: | |
| 78 | + echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")" |
| 79 | + shell: bash |
| 80 | + - name: Cache Gradle downloads |
| 81 | + uses: actions/cache@v2 |
| 82 | + id: cache-gradle |
| 83 | + with: |
| 84 | + path: | |
| 85 | + .gradle/caches |
| 86 | + .gradle/jdks |
| 87 | + .gradle/wrapper |
| 88 | + # refresh cache every month to avoid unlimited growth |
| 89 | + key: gradle-examples-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }} |
| 90 | + - name: Set up JDK 11 |
| 91 | + |
| 92 | + with: |
| 93 | + distribution: 'temurin' |
| 94 | + java-version: 11 |
| 95 | + - name: Print the effective ORM version used |
| 96 | + run: ./gradlew :${{ matrix.example }}:dependencyInsight --dependency org.hibernate.orm:hibernate-core |
| 97 | + - name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }} |
| 98 | + run: ./gradlew :${{ matrix.example }}:runAllExamplesOn${{ matrix.db }} |
| 99 | + - name: Upload reports (if build failed) |
| 100 | + uses: actions/upload-artifact@v2 |
| 101 | + if: failure() |
| 102 | + with: |
| 103 | + name: reports-examples-${{ matrix.db }} |
| 104 | + path: './**/build/reports/' |
| 105 | + |
| 106 | + test_dbs: |
| 107 | + name: Test with ${{ matrix.db }} |
| 108 | + runs-on: ubuntu-latest |
| 109 | + strategy: |
| 110 | + matrix: |
| 111 | + db: [ 'MariaDB', 'MySQL', 'PostgreSQL', 'MSSQLServer', 'CockroachDB', 'Db2', 'Oracle' ] |
| 112 | + steps: |
| 113 | + - uses: actions/checkout@v2 |
| 114 | + - name: Get year/month for cache key |
| 115 | + id: get-date |
| 116 | + run: | |
| 117 | + echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")" |
| 118 | + shell: bash |
| 119 | + - name: Cache Gradle downloads |
| 120 | + uses: actions/cache@v2 |
| 121 | + id: cache-gradle |
| 122 | + with: |
| 123 | + path: | |
| 124 | + .gradle/caches |
| 125 | + .gradle/jdks |
| 126 | + .gradle/wrapper |
| 127 | + # refresh cache every month to avoid unlimited growth |
| 128 | + key: gradle-db-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }} |
| 129 | + - name: Set up JDK 11 |
| 130 | + |
| 131 | + with: |
| 132 | + distribution: 'temurin' |
| 133 | + java-version: 11 |
| 134 | + - name: Print the effective ORM version used |
| 135 | + run: ./gradlew :hibernate-reactive-core:dependencyInsight --dependency org.hibernate.orm:hibernate-core |
| 136 | + - name: Build and Test with ${{ matrix.db }} |
| 137 | + run: ./gradlew build -PshowStandardOutput -Pdocker -Pdb=${{ matrix.db }} |
| 138 | + - name: Upload reports (if build failed) |
| 139 | + uses: actions/upload-artifact@v2 |
| 140 | + if: failure() |
| 141 | + with: |
| 142 | + name: reports-db-${{ matrix.db }} |
| 143 | + path: './**/build/reports/' |
| 144 | + |
| 145 | + test_jdks: |
| 146 | + name: Test with Java ${{ matrix.java.name }} |
| 147 | + runs-on: ubuntu-latest |
| 148 | + strategy: |
| 149 | + fail-fast: false |
| 150 | + matrix: |
| 151 | + # To list the available "feature versions" on adoptium.net (ignore "tip_version", it's not relevant): |
| 152 | + # https://api.adoptium.net/v3/info/available_releases |
| 153 | + # To list the available releases for a given "feature version" on adoptium.net (example for 16): |
| 154 | + # https://api.adoptium.net/v3/assets/latest/16/hotspot |
| 155 | + # To see the available versions and download links on jdk.java.net: |
| 156 | + # https://github.com/oracle-actions/setup-java/blob/main/jdk.java.net-uri.properties |
| 157 | + java: |
| 158 | + - { name: "11", java_version_numeric: 11 } |
| 159 | + - { name: "17", java_version_numeric: 17 } |
| 160 | + # We want to enable preview features when testing newer builds of OpenJDK: |
| 161 | + # even if we don't use these features, just enabling them can cause side effects |
| 162 | + # and it's useful to test that. |
| 163 | + - { name: "20", java_version_numeric: 20, jvm_args: '--enable-preview' } |
| 164 | + - { name: "21", java_version_numeric: 21, jvm_args: '--enable-preview' } |
| 165 | + - { name: "22", java_version_numeric: 22, from: 'jdk.java.net', jvm_args: '--enable-preview' } |
| 166 | + - { name: "23-ea", java_version_numeric: 23, from: 'jdk.java.net', jvm_args: '--enable-preview' } |
| 167 | + - { name: "24-ea", java_version_numeric: 24, from: 'jdk.java.net', jvm_args: '--enable-preview' } |
| 168 | + steps: |
| 169 | + - uses: actions/checkout@v2 |
| 170 | + - name: Get year/month for cache key |
| 171 | + id: get-date |
| 172 | + run: | |
| 173 | + echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")" |
| 174 | + shell: bash |
| 175 | + - name: Cache Gradle downloads |
| 176 | + uses: actions/cache@v2 |
| 177 | + id: cache-gradle |
| 178 | + with: |
| 179 | + path: | |
| 180 | + .gradle/caches |
| 181 | + .gradle/jdks |
| 182 | + .gradle/wrapper |
| 183 | + # refresh cache every month to avoid unlimited growth |
| 184 | + key: gradle-java${{ matrix.java }}-${{ steps.get-date.outputs.yearmonth }} |
| 185 | + - name: Set up latest JDK ${{ matrix.java.name }} from jdk.java.net |
| 186 | + if: matrix.java.from == 'jdk.java.net' |
| 187 | + uses: oracle-actions/setup-java@v1 |
| 188 | + with: |
| 189 | + website: jdk.java.net |
| 190 | + release: ${{ matrix.java.java_version_numeric }} |
| 191 | + - name: Set up latest JDK ${{ matrix.java.name }} from Adoptium |
| 192 | + if: matrix.java.from == '' || matrix.java.from == 'adoptium.net' |
| 193 | + |
| 194 | + with: |
| 195 | + distribution: 'temurin' |
| 196 | + java-version: ${{ matrix.java.java_version_numeric }} |
| 197 | + check-latest: true |
| 198 | + - name: Export path to JDK ${{ matrix.java.name }} |
| 199 | + id: testjdk-exportpath |
| 200 | + run: echo "::set-output name=path::${JAVA_HOME}" |
| 201 | + # Always use JDK 11 to build the main code: that's what we use for releases. |
| 202 | + - name: Set up JDK 11 |
| 203 | + |
| 204 | + with: |
| 205 | + distribution: 'temurin' |
| 206 | + java-version: 11 |
| 207 | + check-latest: true |
| 208 | + - name: Export path to JDK 11 |
| 209 | + id: mainjdk-exportpath |
| 210 | + run: echo "::set-output name=path::${JAVA_HOME}" |
| 211 | + - name: Display exact version of JDK ${{ matrix.java.name }} |
| 212 | + run: | |
| 213 | + ${{ steps.testjdk-exportpath.outputs.path }}/bin/java -version |
| 214 | + - name: Print the effective ORM version used |
| 215 | + run: ./gradlew :hibernate-reactive-core:dependencyInsight --dependency org.hibernate.orm:hibernate-core |
| 216 | + - name: Build and Test with Java ${{ matrix.java.name }} |
| 217 | + run: | |
| 218 | + ./gradlew build -PshowStandardOutput -Pdocker -Ptest.jdk.version=${{ matrix.java.java_version_numeric }} \ |
| 219 | + -Porg.gradle.java.installations.paths=${{ steps.mainjdk-exportpath.outputs.path }},${{ steps.testjdk-exportpath.outputs.path }} \ |
| 220 | + ${{ matrix.java.jvm_args && '-Ptest.jdk.launcher.args=' }}${{ matrix.java.jvm_args }} |
| 221 | + - name: Upload reports (if build failed) |
| 222 | + uses: actions/upload-artifact@v2 |
| 223 | + if: failure() |
| 224 | + with: |
| 225 | + name: reports-java${{ matrix.java.name }} |
| 226 | + path: './**/build/reports/' |
| 227 | + |
| 228 | + snapshot: |
| 229 | + name: Release snapshot only when the branch name starts with `wip/` |
| 230 | + if: github.event_name == 'push' && startsWith( github.ref, 'refs/heads/wip/' ) |
| 231 | + runs-on: ubuntu-latest |
| 232 | + steps: |
| 233 | + - uses: actions/checkout@v2 |
| 234 | + - name: Set up JDK 11 |
| 235 | + |
| 236 | + with: |
| 237 | + distribution: 'temurin' |
| 238 | + java-version: 11 |
| 239 | + - name: Create artifacts |
| 240 | + run: ./gradlew assemble |
| 241 | + - name: Detect the version of Hibernate Reactive |
| 242 | + id: detect-version |
| 243 | + run: | |
| 244 | + sed -E 's/^projectVersion( *= *| +)([^ ]+)/::set-output name=version::\2/g' gradle/version.properties |
| 245 | + - name: Publish snapshots to OSSRH, close repository and release |
| 246 | + env: |
| 247 | + ORG_GRADLE_PROJECT_sonatypeOssrhUser: ${{ secrets.SONATYPE_OSSRH_USER }} |
| 248 | + ORG_GRADLE_PROJECT_sonatypeOssrhPassword: ${{ secrets.SONATYPE_OSSRH_PASSWORD }} |
| 249 | + run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository |
0 commit comments