Repository navigation
176 lines (158 loc) · 6.48 KB
/
Copy pathbuild.yml
File metadata and controls
176 lines (158 loc) · 6.48 KB
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
175
176
# Build and Test
#
# Description:
# Builds the project and runs unit tests for every supported Java version.
#
# Triggers:
# - pull_request: when a PR targets main
# - push: when code is pushed to main
# - milestone: when milestone metadata changes
#
# Notes:
# Builds against Java 17, 21, and 25.
name: Build
run-name: Build - ${{ github.event_name }}
on:
workflow_dispatch:
milestone:
types: [created, edited, closed, deleted]
pull_request:
branches:
- main
paths:
- '.github/workflows/build.yml'
- '.github/workflows/ai-pr-review.yml'
- '.github/prompts/ai-pr-review.md'
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'telemetry-exporter/**'
- 'otel-plugin/**'
- '.github/scripts/verify_otel_api_compatibility.py'
- 'examples/**'
- 'pom.xml'
push:
branches:
- main
paths:
- '.github/workflows/build.yml'
- '.github/workflows/ai-pr-review.yml'
- '.github/prompts/ai-pr-review.md'
- 'sdk/**'
- 'sdk-testing/**'
- 'sdk-integration-tests/**'
- 'telemetry-exporter/**'
- 'otel-plugin/**'
- '.github/scripts/verify_otel_api_compatibility.py'
- 'examples/**'
- 'pom.xml'
permissions:
contents: read
issues: read
pages: write
id-token: write
jobs:
build:
# CodeBuild-hosted runner in the Java testing account (Lambda compute,
# corretto21 image). Fork PRs stay on GitHub-hosted runners so untrusted
# fork code never executes inside the testing account; same-repo PRs, push
# and workflow_dispatch use the ephemeral CodeBuild runner.
runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository && 'ubuntu-latest' || format('codebuild-github-actions-runner-{0}-{1}', github.run_id, github.run_attempt) }}
strategy:
fail-fast: false
matrix:
java:
- 17
- 21
- 25
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'milestone' && github.event.repository.default_branch || github.ref }}
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: corretto
java-version: ${{ matrix.java }}
cache: maven
- name: Build and test
run: mvn -B install --file pom.xml
- name: Verify installed OpenTelemetry API compatibility
if: ${{ matrix.java == 17 }}
run: python3 .github/scripts/verify_otel_api_compatibility.py
- name: Setup uv for coverage badge
if: ${{ matrix.java == 17 }}
# cicirello/jacoco-badge-generator is a Docker-based action; the
# CodeBuild Lambda-compute runner has no docker, so run the same tool
# from PyPI via uv instead. uv provides Python on the Amazon Linux image
# (actions/setup-python ships only Ubuntu builds).
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
version: "0.12.22"
- name: Generate JaCoCo Badge
if: ${{ matrix.java == 17 }}
# Equivalent to cicirello/jacoco-badge-generator@v2 with the two inputs
# this workflow set (jacoco-csv-file, badges-directory); writes
# jacoco.svg into the badges directory, matching the action's default.
# The package version is pinned so this step stays reproducible, as the
# SHA-pinned action was.
run: |
uv run --with jacoco-badge-generator==2.12.1 python -m jacoco_badge_generator \
-j coverage-report/target/site/jacoco-aggregate/jacoco.csv \
-d coverage-report/target/site/jacoco-aggregate
- name: Generate javadoc site
if: ${{ matrix.java == 17 }}
run: mvn -B -pl sdk -am javadoc:javadoc
- name: Generate milestone badge
if: ${{ matrix.java == 17 }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
# Use curl + jq rather than the GitHub CLI: gh is not preinstalled on
# the CodeBuild runner image. GITHUB_API_URL/GH_TOKEN are provided by
# Actions; the jq filter matches the previous `gh api --jq` behavior.
TITLE=$(curl -sfL \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"${GITHUB_API_URL}/repos/${{ github.repository }}/milestones?state=open&per_page=100" \
| jq -r '[.[] | select(.state == "open" and .due_on != null)] | sort_by(.due_on) | .[0].title // empty')
if [ -z "$TITLE" ]; then
URL="https://img.shields.io/badge/Next%20Milestone-No%20milestone-lightgrey"
else
ENCODED=$(echo -n "$TITLE" | jq -sRr @uri | sed 's/-/--/g')
URL="https://img.shields.io/badge/Next%20Milestone-${ENCODED}-blue"
fi
mkdir -p milestone
curl -sfL "$URL" -o milestone/badge.svg
echo "Badge generated for: ${TITLE:-No milestone}"
- name: Configure GitHub Pages
if: ${{ matrix.java == 17 }}
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
- name: Prepare GitHub Pages artifact
if: ${{ matrix.java == 17 }}
run: |
mkdir -p github-pages/coverage github-pages/javadoc github-pages/milestone
cp -R coverage-report/target/site/jacoco-aggregate/. github-pages/coverage
cp -R sdk/target/reports/apidocs/. github-pages/javadoc
cp -R milestone/. github-pages/milestone
touch github-pages/.nojekyll
- name: Upload GitHub Pages artifact
if: ${{ matrix.java == 17 }}
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: github-pages
deploy-pages:
if: ${{ github.event_name == 'milestone' || github.ref == 'refs/heads/main' }}
needs: build
# Never fork-reachable (main/milestone only); runs only actions/deploy-pages.
runs-on: ${{ format('codebuild-github-actions-runner-{0}-{1}', github.run_id, github.run_attempt) }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1