Skip to content

Commit 01ee43a

Browse files
authored
Refactor CI build (open-telemetry#328)
* Refactor CI build * apidiffs
1 parent 8c609c1 commit 01ee43a

File tree

4 files changed

+149
-106
lines changed

4 files changed

+149
-106
lines changed

.github/workflows/build-common.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Reusable - Common
2+
3+
on:
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
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build:
18+
name: Build
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os:
24+
- macos-latest
25+
- macos-13
26+
- ubuntu-latest
27+
test-java-version:
28+
- 8
29+
- 11
30+
- 17
31+
- 21
32+
- 25 # renovate: datasource=java-version
33+
# macos-latest drops support for java 8 temurin. Run java 8 on macos-13. Run java 11+ on macos-latest.
34+
exclude:
35+
- os: macos-latest
36+
test-java-version: 8
37+
- os: macos-13
38+
test-java-version: 11
39+
- os: macos-13
40+
test-java-version: 17
41+
- os: macos-13
42+
test-java-version: 21
43+
- os: macos-13
44+
test-java-version: 25 # renovate: datasource=java-version
45+
46+
steps:
47+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
48+
49+
- id: setup-java-test
50+
name: Set up Java ${{ matrix.test-java-version }} for tests
51+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
52+
with:
53+
distribution: temurin
54+
java-version: ${{ matrix.test-java-version }}
55+
56+
- id: setup-java
57+
name: Set up Java for build
58+
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
59+
with:
60+
distribution: temurin
61+
java-version: 17
62+
63+
- uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
64+
65+
- name: build
66+
run: >
67+
./gradlew
68+
build
69+
-PtestJavaVersion=${{ matrix.test-java-version }}
70+
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
71+
- name: generate
72+
# Skip running on macos-latest which doesn't have docker
73+
if: matrix.os == 'ubuntu-latest'
74+
run: ./gradlew generateSemanticConventions --console=plain
75+
76+
# Run spotless after generate to format generated code
77+
- name: spotless
78+
run: ./gradlew spotlessApply
79+
80+
- name: Check that semconv generation is up to date
81+
run: |
82+
# need to "git add" in case any generated files did not already exist
83+
# select files from both /semconv and /semconv-incubating
84+
git add semconv**
85+
if git diff --cached --quiet
86+
then
87+
echo "No diff detected."
88+
else
89+
echo "Diff detected - did you run './gradlew generateSemanticConventions spotlessApply'?"
90+
echo $(git diff --cached --name-only)
91+
echo $(git diff --cached)
92+
exit 1
93+
fi
94+
95+
- name: Check that API diffs are up to date
96+
run: |
97+
# need to "git add" in case any generated files did not already exist
98+
git add docs/apidiffs/
99+
if git diff --cached --quiet
100+
then
101+
echo "No diff detected in apidiffs."
102+
else
103+
echo "Diff detected in apidiffs - did you run './gradlew jApiCmp'?"
104+
echo $(git diff --cached --name-only)
105+
echo $(git diff --cached)
106+
exit 1
107+
fi
108+
109+
misspell-check:
110+
uses: ./.github/workflows/reusable-misspell-check.yml
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Build Pull Request
2+
3+
on:
4+
pull_request:
5+
6+
permissions:
7+
contents: read
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
common:
15+
uses: ./.github/workflows/build-common.yml
16+
with:
17+
cache-read-only: true
18+
19+
link-check:
20+
uses: ./.github/workflows/reusable-link-check.yml
21+
22+
required-status-check:
23+
if: always()
24+
needs:
25+
- common
26+
- link-check # wait for link check to complete, but don't require it to pass for merging
27+
runs-on: ubuntu-latest
28+
steps:
29+
# The reusable workflow success depends on all its jobs passing
30+
- if: needs.common.result != 'success'
31+
run: exit 1 # fail

.github/workflows/build.yml

Lines changed: 3 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -4,115 +4,12 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
7+
- release/*
88
workflow_dispatch:
99

1010
permissions:
1111
contents: read
1212

13-
concurrency:
14-
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
15-
cancel-in-progress: true
16-
1713
jobs:
18-
build:
19-
name: Build
20-
runs-on: ${{ matrix.os }}
21-
strategy:
22-
fail-fast: false
23-
matrix:
24-
os:
25-
- macos-latest
26-
- macos-13
27-
- ubuntu-latest
28-
test-java-version:
29-
- 8
30-
- 11
31-
- 17
32-
- 21
33-
- 25 # renovate: datasource=java-version
34-
# macos-latest drops support for java 8 temurin. Run java 8 on macos-13. Run java 11+ on macos-latest.
35-
exclude:
36-
- os: macos-latest
37-
test-java-version: 8
38-
- os: macos-13
39-
test-java-version: 11
40-
- os: macos-13
41-
test-java-version: 17
42-
- os: macos-13
43-
test-java-version: 21
44-
- os: macos-13
45-
test-java-version: 25 # renovate: datasource=java-version
46-
47-
steps:
48-
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
49-
50-
- id: setup-java-test
51-
name: Set up Java ${{ matrix.test-java-version }} for tests
52-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
53-
with:
54-
distribution: temurin
55-
java-version: ${{ matrix.test-java-version }}
56-
57-
- id: setup-java
58-
name: Set up Java for build
59-
uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0
60-
with:
61-
distribution: temurin
62-
java-version: 17
63-
64-
- uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
65-
66-
- name: build
67-
run: >
68-
./gradlew
69-
build
70-
-PtestJavaVersion=${{ matrix.test-java-version }}
71-
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
72-
73-
- name: generate
74-
# Skip running on macos-latest which doesn't have docker
75-
if: matrix.os == 'ubuntu-latest'
76-
run: ./gradlew generateSemanticConventions --console=plain
77-
78-
# Run spotless after generate to format generated code
79-
- name: spotless
80-
run: ./gradlew spotlessApply
81-
82-
- name: Check for diff
83-
run: |
84-
# need to "git add" in case any generated files did not already exist
85-
# select files from both /semconv and /semconv-incubating
86-
git add semconv**
87-
if git diff --cached --quiet
88-
then
89-
echo "No diff detected."
90-
else
91-
echo "Diff detected - did you run './gradlew generateSemanticConventions spotlessApply'?"
92-
echo $(git diff --cached --name-only)
93-
echo $(git diff --cached)
94-
exit 1
95-
fi
96-
97-
link-check:
98-
# release branches are excluded to avoid unnecessary maintenance
99-
if: ${{ !startsWith(github.ref_name, 'release/') }}
100-
uses: ./.github/workflows/reusable-link-check.yml
101-
102-
misspell-check:
103-
# release branches are excluded to avoid unnecessary maintenance
104-
if: ${{ !startsWith(github.ref_name, 'release/') }}
105-
uses: ./.github/workflows/reusable-misspell-check.yml
106-
107-
required-status-check:
108-
# markdown-link-check is not required so pull requests are not blocked if external links break
109-
# misspell-check is not required so pull requests are not blocked if the misspell dictionary is
110-
# updated
111-
needs:
112-
- build
113-
runs-on: ubuntu-latest
114-
if: always()
115-
steps:
116-
- if: |
117-
needs.build.result != 'success'
118-
run: exit 1
14+
common:
15+
uses: ./.github/workflows/build-common.yml

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@ permissions:
66
contents: read
77

88
jobs:
9+
build:
10+
uses: ./.github/workflows/build-common.yml
11+
912
release:
1013
permissions:
1114
contents: write # for creating the release
1215
runs-on: ubuntu-latest
16+
needs:
17+
- build
1318
outputs:
1419
version: ${{ steps.create-github-release.outputs.version }}
1520
prior-version: ${{ steps.create-github-release.outputs.prior-version }}

0 commit comments

Comments
 (0)