Repository navigation
Build - pull_request #2142
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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@v7 | |
| with: | |
| ref: ${{ github.event_name == 'milestone' && github.event.repository.default_branch || github.ref }} | |
| - name: Setup Java ${{ matrix.java }} | |
| uses: actions/setup-java@v6 | |
| 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@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 | |
| 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@v6 | |
| - 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@v5 | |
| 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@v5 |