Move tests to reusable workflow
MODIFY
.github/workflows/ci.yml
.github/workflows/ci.yml
@@ -47,41 +47,11 @@ jobs:
build-root-directory: gradle-plugins
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- vm:
- - hotspot
- - openj9
- fail-fast: false
- steps:
- - uses: actions/checkout@v3
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt-${{ matrix.vm }}
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: 11
-
- - name: Test
- env:
+ uses: ./.github/workflows/test.yml
+ secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -PtestJavaVM=${{ matrix.vm }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
testLatestDeps:
# release branches are excluded

MODIFY
.github/workflows/nightly-no-cache.yml
.github/workflows/nightly-no-cache.yml
@@ -44,39 +44,11 @@ jobs:
build-root-directory: gradle-plugins
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- vm:
- - hotspot
- - openj9
- fail-fast: false
- steps:
- - uses: actions/checkout@v3
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt-${{ matrix.vm }}
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
+ uses: ./.github/workflows/test.yml
with:
- distribution: adopt
- java-version: 11
-
- - name: Test
- env:
+ no-build-cache: true
+ secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -PtestJavaVM=${{ matrix.vm }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false --no-build-cache
testLatestDeps:
uses: ./.github/workflows/test-latest-deps.yml

MODIFY
.github/workflows/nightly.yml
.github/workflows/nightly.yml
@@ -46,41 +46,11 @@ jobs:
root-build-directory: gradle-plugins
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- vm:
- - hotspot
- - openj9
- fail-fast: false
- steps:
- - uses: actions/checkout@v3
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt-${{ matrix.vm }}
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: 11
-
- - name: Test
- env:
+ uses: ./.github/workflows/test.yml
+ secrets:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -PtestJavaVM=${{ matrix.vm }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
testLatestDeps:
uses: ./.github/workflows/test-latest-deps.yml

MODIFY
.github/workflows/pr.yml
.github/workflows/pr.yml
@@ -68,63 +68,10 @@ jobs:
build-root-directory: gradle-plugins
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- vm:
- - hotspot
- - openj9
- fail-fast: false
- steps:
- - uses: actions/checkout@v3
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt-${{ matrix.vm }}
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
+ uses: ./.github/workflows/test.yml
with:
- distribution: adopt
- java-version: 11
-
- - name: Start deadlock detector
- run: .github/scripts/deadlock-detector.sh
-
- - name: Test
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -PtestJavaVM=${{ matrix.vm }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
cache-read-only: true
- - name: Upload deadlock detector artifacts if any
- if: always()
- uses: actions/upload-artifact@v2
- with:
- name: deadlock-detector-test-${{ matrix.test-java-version }}
- path: /tmp/deadlock-detector-*
- if-no-files-found: ignore
-
- - name: Upload jvm crash dump files if any
- if: always()
- uses: actions/upload-artifact@v2
- with:
- name: javacore-test-${{ matrix.test-java-version }}
- path: |
- "**/hs_err_pid*.log"
- "**/javacore.*.txt"
- "**/Snap.*.trc"
- "**/core.*.dmp"
- "**/jitdump.*.dmp"
- if-no-files-found: ignore
-
testLatestDeps:
# testLatestDeps is not included in the PR workflow by default
# because any time a new library version is released to maven central

MODIFY
.github/workflows/release-gradle-plugins.yml
.github/workflows/release-gradle-plugins.yml
@@ -13,35 +13,7 @@ on:
jobs:
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- steps:
- - uses: actions/checkout@v3
- with:
- ref: ${{ github.event.inputs.release-branch-name }}
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: 11
-
- - name: Test
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
+ uses: ./.github/workflows/test.yml
# testLatestDeps is intentionally not included in the release workflows
# because any time a new library version is released to maven central

MODIFY
.github/workflows/release.yml
.github/workflows/release.yml
@@ -5,35 +5,7 @@ on:
jobs:
test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- test-java-version:
- - 8
- - 11
- - 15
- steps:
- - uses: actions/checkout@v3
- with:
- ref: ${{ github.ref_name }}
-
- - id: setup-test-java
- name: Set up JDK ${{ matrix.test-java-version }} for running tests
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: ${{ matrix.test-java-version }}
-
- - name: Set up JDK 11 for running Gradle
- uses: actions/setup-java@v2
- with:
- distribution: adopt
- java-version: 11
-
- - name: Test
- uses: gradle/gradle-build-action@v2
- with:
- arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false
+ uses: ./.github/workflows/test.yml
# testLatestDeps is intentionally not included in the release workflows
# because any time a new library version is released to maven central

ADD
.github/workflows/test.yml
+name: Test
+
+on:
+ workflow_call:
+ inputs:
+ cache-read-only:
+ type: boolean
+ required: false
+ no-build-cache:
+ type: boolean
+ required: false
+ secrets:
+ GRADLE_ENTERPRISE_ACCESS_KEY:
+ required: false
+ GE_CACHE_USERNAME:
+ required: false
+ GE_CACHE_PASSWORD:
+ required: false
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ test-java-version:
+ - 8
+ - 11
+ - 15
+ vm:
+ - hotspot
+ - openj9
+ fail-fast: false
+ steps:
+ - uses: actions/checkout@v3
+
+ - id: setup-test-java
+ name: Set up JDK ${{ matrix.test-java-version }}-${{ matrix.vm }} for running tests
+ uses: actions/setup-java@v2
+ with:
+ distribution: adopt-${{ matrix.vm }}
+ java-version: ${{ matrix.test-java-version }}
+
+ - name: Set up JDK 11 for running Gradle
+ uses: actions/setup-java@v2
+ with:
+ distribution: adopt
+ java-version: 11
+
+ - name: Start deadlock detector
+ run: .github/scripts/deadlock-detector.sh
+
+ - name: Test
+ env:
+ GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
+ GE_CACHE_USERNAME: ${{ secrets.GE_CACHE_USERNAME }}
+ GE_CACHE_PASSWORD: ${{ secrets.GE_CACHE_PASSWORD }}
+ uses: gradle/gradle-build-action@v2
+ with:
+ arguments: test -PtestJavaVersion=${{ matrix.test-java-version }} -PtestJavaVM=${{ matrix.vm }} -Porg.gradle.java.installations.paths=${{ steps.setup-test-java.outputs.path }} -Porg.gradle.java.installations.auto-download=false ${{ inputs.no-build-cache && ' --no-build-cache' || '' }}
+ cache-read-only: ${{ inputs.cache-read-only }}
+
+ - name: Upload deadlock detector artifacts if any
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: deadlock-detector-test-${{ matrix.test-java-version }}
+ path: /tmp/deadlock-detector-*
+ if-no-files-found: ignore
+
+ - name: Upload jvm crash dump files if any
+ if: always()
+ uses: actions/upload-artifact@v2
+ with:
+ name: javacore-test-${{ matrix.test-java-version }}
+ path: |
+ "**/hs_err_pid*.log"
+ "**/javacore.*.txt"
+ "**/Snap.*.trc"
+ "**/core.*.dmp"
+ "**/jitdump.*.dmp"
+ if-no-files-found: ignore

Move tests to reusable workflow (#5486)