Skip to content

add new ResourceDetector #3902

add new ResourceDetector

add new ResourceDetector #3902

Workflow file for this run

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:
name: Build
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
test-java-version:
- 8
- 11
- 17
- 20
# Collect coverage on latest LTS
include:
- os: ubuntu-20.04
test-java-version: 17
coverage: true
jmh-based-tests: true
steps:
- uses: actions/checkout@v4
- id: setup-java-test
name: Set up Java ${{ matrix.test-java-version }} for tests
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ matrix.test-java-version }}
- id: setup-java
name: Set up Java for build
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@v3
with:
arguments: |
build
${{ matrix.coverage && 'jacocoTestReport' || '' }}
-PtestJavaVersion=${{ matrix.test-java-version }}
-Porg.gradle.java.installations.paths=${{ steps.setup-java-test.outputs.path }},${{ steps.setup-java.outputs.path }}
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
# JMH-based tests run only if this environment variable is set to true
RUN_JMH_BASED_TESTS: ${{ matrix.jmh-based-tests }}
- name: Check for diff
# The jApiCmp diff compares current to latest, which isn't appropriate for release branches
if: ${{ !startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/') }}
run: |
# need to "git add" in case any generated files did not already exist
git add docs/apidiffs
if git diff --cached --quiet
then
echo "No diff detected."
else
echo "Diff detected - did you run './gradlew jApiCmp'?"
echo $(git diff --cached --name-only)
echo $(git diff --cached)
exit 1
fi
- uses: codecov/codecov-action@v4
if: ${{ matrix.coverage }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: actions/upload-artifact@v4
if: ${{ matrix.coverage }}
with:
name: coverage-report
path: all/build/reports/jacoco/test/html
markdown-link-check:
# release branches are excluded to avoid unnecessary maintenance
if: ${{ !startsWith(github.ref_name, 'release/') }}
uses: ./.github/workflows/reusable-markdown-link-check.yml
misspell-check:
# release branches are excluded to avoid unnecessary maintenance
if: ${{ !startsWith(github.ref_name, 'release/') }}
uses: ./.github/workflows/reusable-misspell-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 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') && ' (skipped)' || '' }}
# intentionally not blocking snapshot publishing on markdown-link-check or misspell-check
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- id: setup-java
name: Set up Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- uses: gradle/gradle-build-action@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' }}
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 }}
build-graal:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: graalvm/setup-graalvm@v1
with:
# TODO(jack-berg): Which versions do we need to test? Should we use a matrix scheme?
java-version: '21'
distribution: 'graalvm'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Running test
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
./gradlew nativeTest
required-status-check:
# markdown-link-check is not required so pull requests are not blocked if external links break
# misspell-check is not required so pull requests are not blocked if the misspell dictionary is
# updated
needs:
- build
- build-graal
runs-on: ubuntu-latest
if: always()
steps:
- if: |
needs.build.result != 'success' ||
needs.build-graal.result != 'success'
run: exit 1