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 -Pci-build --no-transfer-progress "
54
52
TESTCONTAINERS_REUSE_ENABLE : true
55
53
56
54
jobs :
68
66
version : 17
69
67
},
70
68
maven : {
71
- args : ' -Pci-build --no-transfer-progress '
69
+ args : ' '
72
70
}
73
71
}
74
72
- {
@@ -78,27 +76,16 @@ jobs:
78
76
version : 17
79
77
},
80
78
maven : {
81
- args : ' -Pci-build --no-transfer-progress '
79
+ args : ' '
82
80
}
83
81
}
84
82
steps :
85
83
- name : Support longpaths on Windows
86
84
if : " startsWith(matrix.os.runs-on, 'windows')"
87
85
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
86
+ - uses : actions/checkout@v4
94
87
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"
88
+ persist-credentials : false
102
89
- name : Set up Java ${{ matrix.os.java.version }}
103
90
uses : actions/setup-java@v4
104
91
with :
@@ -109,38 +96,44 @@ jobs:
109
96
uses : actions/cache@v4
110
97
with :
111
98
path : ~/.m2/repository
112
- key : ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
99
+ # use a different key than workflows running in trusted mode
100
+ key : ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
113
101
restore-keys : |
114
- ${{ runner.os }}-maven-
102
+ ${{ github.event_name == 'push' && 'trusted' || 'untrusted' }}-${{ runner.os }}-maven-
115
103
- name : Set up Maven
116
104
run : ./mvnw -v
117
105
118
106
- name : Build code and run tests and basic checks
119
107
run : |
120
108
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean install \
121
109
-Pjqassistant -Pdist -Prelocation
110
+ env :
111
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
112
+ # For jobs running on 'pull_request', upload build scan data.
113
+ # The actual publishing must be done in a separate job (see ci-report.yml).
114
+ # We don't write to the remote cache as that would be unsafe.
115
+ - name : Upload GitHub Actions artifact for the Develocity build scan
116
+ uses : actions/upload-artifact@v4
117
+ if : " ${{ github.event_name == 'pull_request' && !cancelled() }}"
118
+ with :
119
+ name : build-scan-data-initial-${{ matrix.os.name }}
120
+ path : ~/.m2/.develocity/build-scan-data
122
121
123
122
- name : Build code and run tests in container mode
124
123
run : |
125
124
./mvnw $MAVEN_ARGS ${{ matrix.os.maven.args }} clean verify \
126
125
-Pjqassistant -Pskip-checks \
127
126
-am -pl :hibernate-validator-tck-runner \
128
127
-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)
128
+ env :
129
+ DEVELOCITY_ACCESS_KEY : " ${{ secrets.DEVELOCITY_ACCESS_KEY || '' }}"
130
+ # Same as above, but for the build scan of the latest Maven run.
131
+ - name : Upload GitHub Actions artifact for the Develocity build scan
141
132
uses : actions/upload-artifact@v4
142
- if : ${{ failure() || cancelled() }}
133
+ if : " ${{ github.event_name == 'pull_request' && ! cancelled() }}"
143
134
with :
144
- name : ${{ format('build-reports-{0}', matrix.os.name ) }}
145
- path : ${{ env.buildReportPaths }}
146
- retention-days : 7
135
+ name : build-scan-data-tck-container-${{ matrix.os.name }}
136
+ path : ~/.m2/.develocity/build-scan-data
137
+
138
+ - name : Omit produced artifacts from build cache
139
+ run : rm -r ~/.m2/repository/org/hibernate/validator
0 commit comments