-
Notifications
You must be signed in to change notification settings - Fork 129
174 lines (153 loc) · 5.53 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Build
on:
push:
branches:
- main
- release/*
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build
uses: gradle/actions/setup-gradle@v3
with:
arguments: build -x test
cache-read-only: ${{ github.event_name == 'pull_request' }}
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
test:
name: test (${{ matrix.test-java-version }})
runs-on: ubuntu-latest
strategy:
matrix:
test-java-version:
- 8
- 11
- 17
- 20
fail-fast: false
steps:
- uses: actions/checkout@v4
- id: setup-test-java
name: Set up JDK ${{ matrix.test-java-version }} for running tests
uses: actions/setup-java@v4
with:
# using zulu because new releases get published quickly
distribution: zulu
java-version: ${{ matrix.test-java-version }}
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build
uses: gradle/actions/setup-gradle@v3
with:
arguments: >
test
-PtestJavaVersion=${{ matrix.test-java-version }}
-Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }}
-Porg.gradle.java.installations.auto-download=false
cache-read-only: ${{ github.event_name == 'pull_request' }}
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
integration-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Integration test
uses: gradle/actions/setup-gradle@v3
with:
arguments: integrationTest
cache-read-only: ${{ github.event_name == 'pull_request' }}
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: Save integration test results
uses: actions/upload-artifact@v4
if: always()
with:
name: integration-test-results
path: jmx-metrics/build/reports/tests/integrationTest
markdown-link-check:
uses: ./.github/workflows/reusable-markdown-link-check.yml
markdown-lint-check:
uses: ./.github/workflows/reusable-markdown-lint.yml
misspell-check:
uses: ./.github/workflows/reusable-misspell-check.yml
shell-script-check:
uses: ./.github/workflows/reusable-shell-script-check.yml
publish-snapshots:
# the condition is on the steps below instead of here on the job, because skipping the job
# causes the job to show up as canceled in the GitHub UI which prevents the PR build section
# from collapsing when everything (else) is green
#
# and the name is updated when the steps below are skipped which makes what's happening clearer
# in the GitHub UI
#
# note: the condition below has to be written so that '' is last since it resolves to false
# and so would not short-circuit if used in the second-last position
name: publish-snapshots${{ (github.ref_name != 'main' || github.repository != 'open-telemetry/opentelemetry-java-contrib') && ' (skipped)' || '' }}
needs:
# intentionally not blocking snapshot publishing on markdown-link-check or misspell-check
- build
- integration-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK for running Gradle
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Build and publish snapshots
uses: gradle/actions/setup-gradle@v3
# skipping release branches because the versions in those branches are not snapshots
# (also this skips pull requests)
if: ${{ github.ref_name == 'main' && github.repository == 'open-telemetry/opentelemetry-java-contrib' }}
with:
arguments: assemble publishToSonatype
env:
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }}
required-status-check:
if: github.event_name == 'pull_request'
needs:
- build
- integration-test
- markdown-lint-check
- misspell-check
- shell-script-check
runs-on: ubuntu-latest
steps:
# only the "build" and "integration-test" checks are required for release branch PRs in order
# to avoid any unnecessary release branch maintenance (especially for patches)
- if: |
needs.build.result != 'success' ||
needs.integration-test.result != 'success' ||
(
!startsWith(github.base_ref, 'release/') &&
(
needs.markdown-lint-check.result != 'success' ||
needs.misspell-check.result != 'success' ||
needs.shell-script-check.result != 'success'
)
)
run: exit 1 # fail