|
| 1 | +name: GH Actions CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, reopened, ready_for_review] |
| 7 | + |
| 8 | +permissions: { } # none |
| 9 | + |
| 10 | +# See https://github.com/hibernate/hibernate-orm/pull/4615 for a description of the behavior we're getting. |
| 11 | +concurrency: |
| 12 | + # Consider that two builds are in the same concurrency group (cannot run concurrently) |
| 13 | + # if they use the same workflow and are about the same branch ("ref") or pull request. |
| 14 | + group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" |
| 15 | + # Cancel previous builds in the same concurrency group even if they are in progress |
| 16 | + # for pull requests or pushes to forks (not the upstream repository). |
| 17 | + cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-github-bot-playground' }} |
| 18 | + |
| 19 | +defaults: |
| 20 | + run: |
| 21 | + shell: bash |
| 22 | + |
| 23 | +env: |
| 24 | + MAVEN_ARGS: "-e -B --fail-at-end" |
| 25 | + |
| 26 | +jobs: |
| 27 | + build: |
| 28 | + name: ${{matrix.os.name}} |
| 29 | + runs-on: ${{ matrix.os.runs-on }} |
| 30 | + strategy: |
| 31 | + fail-fast: false |
| 32 | + matrix: |
| 33 | + os: |
| 34 | + - { |
| 35 | + name: "Linux JDK 17", |
| 36 | + runs-on: 'ubuntu-latest', |
| 37 | + java: { |
| 38 | + version: 17 |
| 39 | + } |
| 40 | + } |
| 41 | + # We can't start Linux containers on GitHub Actions' Windows VMs, |
| 42 | + # so we can't run Elasticsearch tests. |
| 43 | + # See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995 |
| 44 | + - { |
| 45 | + name: "Windows JDK 17", |
| 46 | + runs-on: 'windows-latest', |
| 47 | + java: { |
| 48 | + version: 17 |
| 49 | + } |
| 50 | + } |
| 51 | + steps: |
| 52 | + - name: Support longpaths on Windows |
| 53 | + if: "startsWith(matrix.os.runs-on, 'windows')" |
| 54 | + run: git config --global core.longpaths true |
| 55 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2 |
| 56 | + with: |
| 57 | + persist-credentials: false |
| 58 | + # Fetch the whole history to make sure that gitflow incremental builder |
| 59 | + # can find the base commit. |
| 60 | + fetch-depth: 0 |
| 61 | + - name: Set up Java ${{ matrix.os.java.version }} |
| 62 | + uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # 4.7.0 |
| 63 | + with: |
| 64 | + java-version: ${{ matrix.os.java.version }} |
| 65 | + distribution: temurin |
| 66 | + # https://github.com/actions/cache/blob/main/examples.md#java---maven |
| 67 | + - name: Cache local Maven repository |
| 68 | + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2 |
| 69 | + with: |
| 70 | + path: ~/.m2/repository |
| 71 | + # use a different key than workflows running in trusted mode |
| 72 | + key: ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 73 | + restore-keys: | |
| 74 | + ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven- |
| 75 | + - name: Set up Maven |
| 76 | + run: ./mvnw -v |
| 77 | + |
| 78 | + - name: Build code and run unit tests and basic checks |
| 79 | + run: | |
| 80 | + ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \ |
| 81 | + -Pjqassistant -Pdist -Pci-build -DskipITs |
| 82 | + env: |
| 83 | + DEVELOCITY_ACCESS_KEY: "${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}" |
| 84 | + DEVELOCITY_BASE_URL: "${{ env.DEVELOCITY_BASE_URL || 'https://develocity.commonhaus.dev' }}" |
| 85 | + # For jobs running on 'pull_request', upload build scan data. |
| 86 | + # The actual publishing must be done in a separate job (see ci-report.yml). |
| 87 | + # We don't write to the remote cache as that would be unsafe. |
| 88 | + - name: Upload GitHub Actions artifact for the Develocity build scan |
| 89 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # 4.6.1 |
| 90 | + if: "${{ github.event_name == 'pull_request' && !cancelled() }}" |
| 91 | + with: |
| 92 | + name: build-scan-data-initial-${{ matrix.os.name }} |
| 93 | + path: ~/.m2/.develocity/build-scan-data |
| 94 | + |
| 95 | + - name: Run integration tests in the default environment |
| 96 | + run: | |
| 97 | + ./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \ |
| 98 | + -Pskip-checks \ |
| 99 | + ${{ github.event.pull_request.base.ref && format('-Dincremental -Dgib.referenceBranch=refs/remotes/origin/{0}', github.event.pull_request.base.ref) || '' }} |
| 100 | + env: |
| 101 | + DEVELOCITY_ACCESS_KEY: "${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}" |
| 102 | + DEVELOCITY_BASE_URL: "${{ env.DEVELOCITY_BASE_URL || 'https://develocity.commonhaus.dev' }}" |
| 103 | + # Same as above, but for the build scan of the latest Maven run. |
| 104 | + - name: Upload GitHub Actions artifact for the Develocity build scan |
| 105 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # 4.6.1 |
| 106 | + if: "${{ github.event_name == 'pull_request' && !cancelled() }}" |
| 107 | + with: |
| 108 | + name: build-scan-data-integrationtest-${{ matrix.os.name }} |
| 109 | + path: ~/.m2/.develocity/build-scan-data |
0 commit comments