Skip to content

Commit b7f3642

Browse files
authored
Merge pull request #17 from yrodiere/develocity-on-prs
Publish Develocity build reports even on external PRs
2 parents 2964784 + 950e99b commit b7f3642

File tree

3 files changed

+178
-74
lines changed

3 files changed

+178
-74
lines changed

.github/workflows/build.yml

-74
This file was deleted.

.github/workflows/ci-report.yml

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: GH Actions CI reporting
2+
3+
on:
4+
workflow_run:
5+
workflows: [ "GH Actions CI" ]
6+
types: [ completed ]
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
env:
13+
MAVEN_ARGS: "-e -B --settings .github/mvn-settings.xml --fail-at-end"
14+
15+
jobs:
16+
publish-build-scans:
17+
name: Publish Develocity build scans
18+
if: github.repository == 'hibernate/hibernate-search' && github.event.workflow_run.conclusion != 'cancelled'
19+
runs-on: ubuntu-latest
20+
steps:
21+
# Checkout target branch which has trusted code
22+
- name: Check out target branch
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
24+
with:
25+
persist-credentials: false
26+
ref: ${{ github.ref }}
27+
- name: Set up Java 21
28+
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 # 4.7.0
29+
with:
30+
java-version: 21
31+
distribution: temurin
32+
# https://github.com/actions/cache/blob/main/examples.md#java---maven
33+
- name: Cache local Maven repository
34+
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
35+
with:
36+
path: ~/.m2/repository
37+
# use a different key than workflows running untrusted code
38+
key: trusted-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
39+
restore-keys: |
40+
trusted-${{ runner.os }}-maven-
41+
- name: Set up Maven
42+
run: ./mvnw -v
43+
- name: Download GitHub Actions artifacts for the Develocity build scans
44+
id: downloadBuildScan
45+
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # 4.1.9
46+
with:
47+
pattern: build-scan-data-*
48+
github-token: ${{ github.token }}
49+
repository: ${{ github.repository }}
50+
run-id: ${{ github.event.workflow_run.id }}
51+
path: /tmp/downloaded-build-scan-data/
52+
# Don't fail the build if there are no matching artifacts
53+
continue-on-error: true
54+
- name: Publish Develocity build scans for previous builds
55+
if: ${{ steps.downloadBuildScan.outcome != 'failure'}}
56+
run: |
57+
shopt -s nullglob # Don't run the loop below if there are no artifacts
58+
status=0
59+
mkdir -p ~/.m2/.develocity/
60+
for build_scan_data_directory in /tmp/downloaded-build-scan-data/*
61+
do
62+
rm -rf ~/.m2/.develocity/build-scan-data
63+
mv "$build_scan_data_directory" ~/.m2/.develocity/build-scan-data \
64+
&& ./mvnw $MAVEN_ARGS develocity:build-scan-publish-previous || status=1
65+
done
66+
exit $status
67+
env:
68+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY_PR }}
69+
DEVELOCITY_BASE_URL: "${{ env.DEVELOCITY_BASE_URL || 'https://develocity.commonhaus.dev' }}"

.github/workflows/ci.yml

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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

Comments
 (0)