1- name : Build
1+ name : Reusable - Common
22
33on :
4- push :
5- branches :
6- - main
7- - release/*
8- pull_request :
9- merge_group :
10- workflow_dispatch :
11- schedule :
12- # Run daily at 7:30 AM UTC
13- - cron : ' 30 7 * * *'
4+ workflow_call :
5+ inputs :
6+ cache-read-only :
7+ type : boolean
8+ required : false
9+ no-build-cache :
10+ type : boolean
11+ required : false
1412
1513permissions :
1614 contents : read
1715
18- concurrency :
19- group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
20- cancel-in-progress : true
21-
2216jobs :
2317 build :
2418 runs-on : ubuntu-latest
3428 - name : Set up gradle
3529 uses : gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
3630 with :
37- cache-read-only : ${{ github.event_name == 'pull_request' }}
31+ cache-read-only : ${{ inputs.cache-read-only }}
32+
3833 - name : Gradle build and test
39- run : ./gradlew build -x test
34+ run : ./gradlew build -x test ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
4035
4136 test :
4237 name : Test
@@ -87,13 +82,15 @@ jobs:
8782 - name : Set up gradle
8883 uses : gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
8984 with :
90- cache-read-only : ${{ github.event_name == 'pull_request' }}
85+ cache-read-only : ${{ inputs.cache-read-only }}
86+
9187 - name : Gradle test
9288 run : >
9389 ./gradlew test
9490 "-PtestJavaVersion=${{ matrix.test-java-version }}"
9591 "-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }}"
9692 "-Porg.gradle.java.installations.auto-download=false"
93+ ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
9794
9895 integration-test :
9996 runs-on : ubuntu-latest
@@ -109,10 +106,10 @@ jobs:
109106 - name : Set up gradle
110107 uses : gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
111108 with :
112- cache-read-only : ${{ github.event_name == 'pull_request' }}
109+ cache-read-only : ${{ inputs.cache-read-only }}
113110
114111 - name : Integration test
115- run : ./gradlew integrationTest
112+ run : ./gradlew integrationTest ${{ inputs.no-build-cache && '--no-build-cache' || '' }}
116113
117114 - name : Save integration test results
118115 uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
@@ -121,16 +118,6 @@ jobs:
121118 name : integration-test-results
122119 path : jmx-metrics/build/reports/tests/integrationTest
123120
124- link-check :
125- # merge group and push events are excluded to avoid unnecessary CI failures
126- # (these failures will instead be captured by the daily scheduled run)
127- #
128- # release branches are excluded to avoid unnecessary maintenance if external links break
129- # (and also because the README.md might need update on release branches before the release
130- # download has been published)
131- if : github.event_name != 'merge_group' && github.event_name != 'push' && !startsWith(github.ref_name, 'release/')
132- uses : ./.github/workflows/reusable-link-check.yml
133-
134121 markdown-lint-check :
135122 uses : ./.github/workflows/reusable-markdown-lint.yml
136123
@@ -139,97 +126,3 @@ jobs:
139126
140127 shell-script-check :
141128 uses : ./.github/workflows/reusable-shell-script-check.yml
142-
143- publish-snapshots :
144- # the condition is on the steps below instead of here on the job, because skipping the job
145- # causes the job to show up as canceled in the GitHub UI which prevents the PR build section
146- # from collapsing when everything (else) is green
147- #
148- # and the name is updated when the steps below are skipped which makes what's happening clearer
149- # in the GitHub UI
150- #
151- # note: the condition below has to be written so that '' is last since it resolves to false
152- # and so would not short-circuit if used in the second-last position
153- name : publish-snapshots${{ (github.ref_name != 'main' || github.repository != 'open-telemetry/opentelemetry-java-contrib') && ' (skipped)' || '' }}
154- needs :
155- # intentionally not blocking snapshot publishing on link-check or misspell-check
156- - build
157- - integration-test
158- runs-on : ubuntu-latest
159- steps :
160- - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
161-
162- - name : Set up JDK for running Gradle
163- uses : actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
164- with :
165- distribution : temurin
166- java-version : 17
167-
168- - name : Set up gradle
169- uses : gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
170- # skipping release branches because the versions in those branches are not snapshots
171- # (also this skips pull requests)
172- if : ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }}
173- - name : Build and publish snapshots
174- if : ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }}
175- run : ./gradlew assemble publishToSonatype
176- env :
177- SONATYPE_USER : ${{ secrets.SONATYPE_USER }}
178- SONATYPE_KEY : ${{ secrets.SONATYPE_KEY }}
179- GPG_PRIVATE_KEY : ${{ secrets.GPG_PRIVATE_KEY }}
180- GPG_PASSWORD : ${{ secrets.GPG_PASSWORD }}
181-
182- required-status-check :
183- if : (github.event_name == 'pull_request' || github.event_name == 'merge_group') && always()
184- needs :
185- - build
186- - test
187- - integration-test
188- - markdown-lint-check
189- - misspell-check
190- - shell-script-check
191- runs-on : ubuntu-latest
192- steps :
193- # only the build and test checks are required for release branch PRs in order
194- # to avoid any unnecessary release branch maintenance (especially for patches)
195- - if : |
196- needs.build.result != 'success' ||
197- needs.test.result != 'success' ||
198- needs.integration-test.result != 'success' ||
199- (
200- !startsWith(github.base_ref, 'release/') &&
201- (
202- needs.markdown-lint-check.result != 'success' ||
203- needs.misspell-check.result != 'success' ||
204- needs.shell-script-check.result != 'success'
205- )
206- )
207- run: exit 1 # fail
208-
209- workflow-notification :
210- permissions :
211- contents : read
212- issues : write
213- if : (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && always()
214- needs :
215- - build
216- - test
217- - integration-test
218- - link-check
219- - markdown-lint-check
220- - misspell-check
221- - shell-script-check
222- - publish-snapshots
223- uses : ./.github/workflows/reusable-workflow-notification.yml
224- with :
225- success : >-
226- ${{
227- needs.build.result == 'success' &&
228- needs.test.result == 'success' &&
229- needs.integration-test.result == 'success' &&
230- needs.link-check.result == 'success' &&
231- needs.markdown-lint-check.result == 'success' &&
232- needs.misspell-check.result == 'success' &&
233- needs.shell-script-check.result == 'success' &&
234- needs.publish-snapshots.result == 'success'
235- }}
0 commit comments