Encode semconv version in build dir to fix build cache (#51) #106
This file contains 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
name: Build | |
on: | |
push: | |
branches: | |
- main | |
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 | |
steps: | |
- uses: actions/checkout@v3 | |
- id: setup-java-test | |
name: Set up Java ${{ matrix.test-java-version }} for tests | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: ${{ matrix.test-java-version }} | |
- id: setup-java | |
name: Set up Java for build | |
uses: actions/setup-java@v3 | |
with: | |
distribution: temurin | |
java-version: 17 | |
- name: build | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: | | |
build | |
-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 }} | |
- name: generate | |
# Skip running on macos-latest which doesn't have docker | |
if: matrix.os == 'ubuntu-latest' | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: | | |
generateSemanticConventions --console=plain | |
# Run spotless after generate to format generated code | |
- name: spotless | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: | | |
spotlessApply | |
- name: Check for diff | |
run: | | |
# need to "git add" in case any generated files did not already exist | |
# select files from both /semconv and /semconv-incubating | |
git add semconv** | |
if git diff --cached --quiet | |
then | |
echo "No diff detected." | |
else | |
echo "Diff detected - did you run './gradlew generateSemanticConventions spotlessApply'?" | |
echo $(git diff --cached --name-only) | |
echo $(git diff --cached) | |
exit 1 | |
fi | |
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 | |
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 | |
runs-on: ubuntu-latest | |
if: always() | |
steps: | |
- if: | | |
needs.build.result != 'success' | |
run: exit 1 |