Skip to content

Split building and testing in workflow #512

Split building and testing in workflow

Split building and testing in workflow #512

Workflow file for this run

name: Build
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
# validate gradle wrapper binary https://github.com/gradle/wrapper-validation-action
gradle-wrapper-validation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/[email protected]
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Gradle build without tests
uses: ./.github/workflows/gradle-goal
with:
# We also compile the test-classes, even though we are skipping the tests
command: "./gradlew build testClasses -x test"
- name: Warmup gradle wrapper
uses: ./.github/workflows/gradle-goal
with:
command: "./gradlew check"
- name: Store test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/build/test-results/test/TEST-*.xml'
- name: Cache working directory with build results
uses: actions/upload-artifact@v3
with:
name: working-dir-build-cache
path: ./
- name: Agent artifact
uses: actions/upload-artifact@v3
with:
name: elastic-otel-javaagent
path: |
./agent/build/libs/elastic-otel-javaagent-*.jar
test:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download cached build working directory
uses: actions/download-artifact@v3
with:
name: working-dir-build-cache
path: ./
- name: Run tests
uses: ./.github/workflows/gradle-goal
with:
command: "./gradlew test"
- name: Store test results
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-results
path: '**/build/test-results/test/TEST-*.xml'