Skip to content

Commit b522175

Browse files
committed
updates
1 parent 7089433 commit b522175

File tree

4 files changed

+126
-124
lines changed

4 files changed

+126
-124
lines changed

.github/workflows/build-common.yml

Lines changed: 17 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
name: Build
1+
name: Reusable - Common
22

33
on:
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

1513
permissions:
1614
contents: read
1715

18-
concurrency:
19-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
20-
cancel-in-progress: true
21-
2216
jobs:
2317
build:
2418
runs-on: ubuntu-latest
@@ -34,9 +28,10 @@ jobs:
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-
}}

.github/workflows/build-daily.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Daily
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Run daily at 7:30 AM UTC
7+
- cron: '30 7 * * *'
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
common:
14+
uses: ./.github/workflows/build-common.yml
15+
with:
16+
no-build-cache: true
17+
18+
link-check:
19+
uses: ./.github/workflows/reusable-link-check.yml
20+
21+
workflow-notification:
22+
permissions:
23+
contents: read
24+
issues: write
25+
if: always()
26+
needs:
27+
- common
28+
- link-check
29+
uses: ./.github/workflows/reusable-workflow-notification.yml
30+
with:
31+
success: >-
32+
${{
33+
needs.common.result == 'success' &&
34+
needs.link-check.result == 'success'
35+
}}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Build Pull Request
2+
3+
on:
4+
pull_request:
5+
merge_group:
6+
7+
permissions:
8+
contents: read
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
common:
16+
uses: ./.github/workflows/build-common.yml
17+
with:
18+
cache-read-only: true
19+
20+
link-check:
21+
uses: ./.github/workflows/reusable-link-check.yml
22+
23+
required-status-check:
24+
if: always()
25+
needs:
26+
- common
27+
- link-check # wait for link check to complete, but don't require it to pass for merging
28+
runs-on: ubuntu-latest
29+
steps:
30+
# The reusable workflow success depends on all its jobs passing
31+
- if: needs.common.result != 'success'
32+
run: exit 1 # fail

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- release/*
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
common:
14+
uses: ./.github/workflows/build-common.yml
15+
16+
# Link check is disabled for push events to avoid unnecessary CI failures
17+
# (these failures will instead be captured by the daily scheduled run)
18+
# and for release branches to avoid unnecessary maintenance if external links break
19+
20+
publish-snapshots:
21+
needs:
22+
- common
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
26+
27+
- name: Set up JDK for running Gradle
28+
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1
29+
with:
30+
distribution: temurin
31+
java-version: 17
32+
33+
- name: Set up gradle
34+
uses: gradle/actions/setup-gradle@017a9effdb900e5b5b2fddfb590a105619dca3c3 # v4.4.2
35+
36+
- name: Build and publish snapshots
37+
run: ./gradlew assemble publishToSonatype
38+
env:
39+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
40+
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
41+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
42+
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}

0 commit comments

Comments
 (0)