Skip to content

Commit

Permalink
Update gradle.yml (#13267)
Browse files Browse the repository at this point in the history
Break down into multiple jobs
  • Loading branch information
puneetbehl committed Dec 6, 2023
1 parent 696d33a commit 40b4c63
Showing 1 changed file with 51 additions and 55 deletions.
106 changes: 51 additions & 55 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,82 +2,78 @@ name: Java CI
on:
push:
branches:
- master
- '[4-9]+.[0-9]+.x'
- '[3-9]+.[3-9]+.x'
pull_request:
branches:
- master
- '[4-9]+.[0-9]+.x'
- '[3-9]+.[3-9]+.x'
workflow_dispatch:
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
build:
permissions:
contents: read # to fetch code (actions/checkout)
runs-on: ubuntu-latest
strategy:
matrix:
java: ['8']
env:
WORKSPACE: ${{ github.workspace }}
GRADLE_OPTS: -Xmx1500m -Dfile.encoding=UTF-8
steps:
- uses: actions/checkout@v2
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- uses: actions/checkout@v3
- name: Set up JDK
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Run Build
id: build
uses: gradle/gradle-build-action@v2
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
with:
java-version: ${{ matrix.java }}
- name: Optional setup step
run: |
[ -f ./setup.sh ] && ./setup.sh || true
- name: Run Tests
run: |
(set -x; ./gradlew clean classes --no-daemon)
(set -x; ./gradlew testClasses --no-daemon)
./gradlew --stop
(set -x; ./gradlew grails-test-suite-persistence:test grails-test-suite-uber:test grails-test-suite-web:test --no-daemon)
./gradlew --stop
(set -x; ./gradlew check -x grails-test-suite-persistence:test -x grails-test-suite-uber:test -x grails-test-suite-web:test --no-daemon)
- name: Publish Test Report
uses: scacap/action-surefire-report@v1
arguments: build
publish:
permissions:
contents: read # to fetch code (actions/checkout)
checks: write
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: ['build']
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_paths: '**/build/test-results/test/TEST-*.xml'
- name: Run Assemble
if: success() && github.event_name == 'push' && matrix.java == '8'
run: ./gradlew assemble
- name: Publish to repo.grails.org
if: success() && github.event_name == 'push' && matrix.java == '8'
token: ${{ secrets.GH_TOKEN }}
- name: Set up JDK
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '8'
- name: Publish to Artifactory (repo.grails.org)
id: publish
uses: gradle/gradle-build-action@v2
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: |
./gradlew publish
with:
arguments: -Dorg.gradle.internal.publish.checksums.insecure=true publish
- name: Extract branch name
if: success() && github.event_name == 'push' && matrix.java == '8'
if: success()
id: extract_branch
run: echo ::set-output name=value::${GITHUB_REF:11}
run: echo "value=${GITHUB_REF:11}" >> $GITHUB_OUTPUT
- name: Create Snapshot Message for the Workflow Dispatch
if: success() && github.event_name == 'push' && matrix.java == '8'
if: success()
id: dispatch_message
run: echo ::set-output name=value::{\"message\":\"New Core Snapshot $(date) - $GITHUB_SHA\"}
run: echo "value={\"message\":\"New Core Snapshot $(date) - $GITHUB_SHA\"}" >> $GITHUB_OUTPUT
- name: Invoke the Java CI workflow in Grails Functional Tests
if: success() && github.event_name == 'push' && matrix.java == '8'
uses: benc-uk/workflow-dispatch@v1.1
if: success()
uses: benc-uk/workflow-dispatch@v1.2
with:
workflow: Java CI
repo: grails/grails-functional-tests
ref: ${{ steps.extract_branch.outputs.value }}
token: ${{ secrets.GH_TOKEN }}
inputs: ${{ steps.dispatch_message.outputs.value }}
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
inputs: ${{ steps.dispatch_message.outputs.value }}

0 comments on commit 40b4c63

Please sign in to comment.