9
9
# See https://docs.github.com/en/actions
10
10
# for more information about GitHub actions.
11
11
12
- name : GitHub Actions Build
12
+ name : GH Actions CI
13
13
14
14
on :
15
15
push :
24
24
- ' !dependabot/**'
25
25
tags :
26
26
- ' **'
27
- # WARNING: Using pull_request_target to access secrets, but we check out the merge commit.
28
- # See checkout action for details.
29
- pull_request_target :
27
+ pull_request :
30
28
types : [opened, synchronize, reopened, ready_for_review]
31
29
branches :
32
30
# Pattern order matters: the last matching inclusion/exclusion wins
43
41
44
42
concurrency :
45
43
group : " workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
46
- cancel-in-progress : ${{ github.event_name == 'pull_request_target ' || github.repository != 'hibernate/hibernate-validator' }}
44
+ cancel-in-progress : ${{ github.event_name == 'pull_request ' || github.repository != 'hibernate/hibernate-validator' }}
47
45
48
46
defaults :
49
47
run :
50
48
shell : bash
51
49
52
50
env :
53
- MAVEN_ARGS : " -e -B --settings .github/mvn-settings.xml --fail-at-end"
51
+ MAVEN_ARGS : " -e -B --settings .github/mvn-settings.xml --fail-at-end --no-transfer-progress "
54
52
TESTCONTAINERS_REUSE_ENABLE : true
55
53
56
54
jobs :
@@ -68,37 +66,33 @@ jobs:
68
66
version : 17
69
67
},
70
68
maven : {
71
- args : ' -Pci-build --no-transfer-progress'
69
+ # Since we only start an Elasticsearch container on Linux we add the profile to enable container reuse here:
70
+ args : ' -Pci-build'
72
71
}
73
72
}
73
+ # We can't start Linux containers on GitHub Actions' Windows VMs,
74
+ # so we can't run Elasticsearch tests.
75
+ # See https://github.com/actions/runner-images/issues/1143#issuecomment-972929995
74
76
- {
75
77
name : " Windows JDK 17" ,
76
78
runs-on : ' windows-latest' ,
77
79
java : {
78
80
version : 17
79
81
},
80
82
maven : {
81
- args : ' -Pci-build --no-transfer-progress '
83
+ args : ' -Dtest.elasticsearch.skip=true '
82
84
}
83
85
}
84
86
steps :
85
87
- name : Support longpaths on Windows
86
88
if : " startsWith(matrix.os.runs-on, 'windows')"
87
89
run : git config --global core.longpaths true
88
- - name : Check out commit already pushed to branch
89
- if : " ! github.event.pull_request.number"
90
- uses : actions/checkout@v4
91
- - name : Check out PR head
92
- uses : actions/checkout@v4
93
- if : github.event.pull_request.number
90
+ - uses : actions/checkout@v4
94
91
with :
95
- # WARNING: This is potentially dangerous since we're checking out unreviewed code,
96
- # and since we're using the pull_request_target event we can use secrets.
97
- # Thus, we must be extra careful to never expose secrets to steps that execute this code,
98
- # and to strictly limit our set of secrets to those that only pose minor security threats.
99
- # This means in particular we won't expose Develocity credentials to the main maven executions,
100
- # but instead will execute maven a third time just to push build scans to Develocity; (once we have scans enabled)
101
- ref : " refs/pull/${{ github.event.pull_request.number }}/head"
92
+ persist-credentials : false
93
+ # Fetch the whole history to make sure that gitflow incremental builder
94
+ # can find the base commit.
95
+ fetch-depth : 0
102
96
- name : Set up Java ${{ matrix.os.java.version }}
103
97
uses : actions/setup-java@v4
104
98
with :
@@ -109,38 +103,44 @@ jobs:
109
103
uses : actions/cache@v4
110
104
with :
111
105
path : ~/.m2/repository
112
- key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
106
+ # use a different key than workflows running in trusted mode
107
+ key : ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
113
108
restore-keys : |
114
- ${{ runner.os }}-maven-
109
+ ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-
115
110
- name : Set up Maven
116
111
run : ./mvnw -v
117
112
118
113
- name : Build code and run tests and basic checks
119
114
run : |
120
115
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
121
116
-Pjqassistant -Pdist -Prelocation
117
+ env :
118
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
119
+ # For jobs running on 'pull_request', upload build scan data.
120
+ # The actual publishing must be done in a separate job (see ci-report.yml).
121
+ # We don't write to the remote cache as that would be unsafe.
122
+ - name : Upload GitHub Actions artifact for the Develocity build scan
123
+ uses : actions/upload-artifact@v4
124
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }}"
125
+ with :
126
+ name : build-scan-data-initial-${{ matrix.os.name }}
127
+ path : ~/.m2/.develocity/build-scan-data
122
128
123
129
- name : Build code and run tests in container mode
124
130
run : |
125
131
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
126
132
-Pjqassistant -Pskip-checks \
127
133
-am -pl :hibernate-validator-tck-runner \
128
134
-Dincontainer -Dincontainer-prepared
129
- # Workaround for https://github.com/actions/upload-artifact/issues/240
130
- - name : List build reports to upload (if build failed)
131
- if : ${{ failure() || cancelled() }}
132
- # The weird syntax is because we're setting a multiline environment variable
133
- # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#example-of-a-multiline-string
134
- run : |
135
- {
136
- echo 'buildReportPaths<<EOF'
137
- find . -path '**/*-reports'
138
- echo EOF
139
- } >> "$GITHUB_ENV"
140
- - name : Upload build reports (if build failed)
135
+ env :
136
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
137
+ # Same as above, but for the build scan of the latest Maven run.
138
+ - name : Upload GitHub Actions artifact for the Develocity build scan
141
139
uses : actions/upload-artifact@v4
142
- if : ${{ failure() || cancelled() }}
140
+ if : " ${{ github.event_name == 'pull_request' && ! cancelled() }}"
143
141
with :
144
- name : ${{ format('build-reports-{0}', matrix.os.name ) }}
145
- path : ${{ env.buildReportPaths }}
146
- retention-days : 7
142
+ name : build-scan-data-tck-container-${{ matrix.os.name }}
143
+ path : ~/.m2/.develocity/build-scan-data
144
+
145
+ - name : Omit produced artifacts from build cache
146
+ run : rm -r ~/.m2/repository/org/hibernate/validator
0 commit comments