From 07b151cf93fc4963650b2e3cce1349b2aae6d0ce Mon Sep 17 00:00:00 2001 From: Puneet Behl Date: Wed, 17 Jan 2024 16:36:20 +0530 Subject: [PATCH] Add groovy-joint-workflow (#497) * Add groovy-joint-workflow * Update build.gradle * Update build.gradle --- .github/workflows/groovy-joint-workflow.yml | 152 ++++++++++++++++++++ build.gradle | 13 +- 2 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/groovy-joint-workflow.yml diff --git a/.github/workflows/groovy-joint-workflow.yml b/.github/workflows/groovy-joint-workflow.yml new file mode 100644 index 000000000..b09549667 --- /dev/null +++ b/.github/workflows/groovy-joint-workflow.yml @@ -0,0 +1,152 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: "Grails Joint Validation Build" +# GROOVY_2_5_X == Grails 4.0.x +# GROOVY_3_0_X == grails master +# Groovy master branch does not map to any due to changed package names. +on: + push: + branches: + - '[3-9]+.[1-9]+.x' + pull_request: + branches: + - '[3-9]+.[1-9]+.x' + workflow_dispatch: +permissions: + contents: read +env: + CI_GROOVY_VERSION: +jobs: + build_groovy: + strategy: + fail-fast: true + runs-on: ubuntu-latest + outputs: + groovyVersion: ${{ steps.groovy-version.outputs.value }} + steps: + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '11.0.6' + - name: Cache local Maven repository & Groovy + uses: actions/cache@v3 + with: + path: | + ~/groovy + ~/.m2/repository + key: cache-local-groovy-maven-${{ github.sha }} + - name: Checkout Groovy 3_0_X (Grails 5 and later) + if: startsWith(github.ref, 'refs/heads/3.') || startsWith(github.base_ref, '3.') + run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_3_0_X --single-branch + - name: Set CI_GROOVY_VERSION for Grails + id: groovy-version + run: | + cd ../groovy + echo "CI_GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_ENV + echo "value=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')" >> $GITHUB_OUTPUT + - name: Prepare GE Set-up Configuration + id: ge_conf + run: | + echo "VALUE<> $GITHUB_OUTPUT + echo "plugins { " >> $GITHUB_OUTPUT + echo " id 'com.gradle.enterprise' version '3.15.1'" >> $GITHUB_OUTPUT + echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '1.11.3'" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "gradleEnterprise {" >> $GITHUB_OUTPUT + echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT + echo " buildScan {" >> $GITHUB_OUTPUT + echo " publishAlways()" >> $GITHUB_OUTPUT + echo " publishIfAuthenticated()" >> $GITHUB_OUTPUT + echo " uploadInBackground = System.getenv('CI') == null" >> $GITHUB_OUTPUT + echo " capture {" >> $GITHUB_OUTPUT + echo " taskInputFiles = true" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "buildCache {" >> $GITHUB_OUTPUT + echo " local { enabled = System.getenv('CI') != 'true' }" >> $GITHUB_OUTPUT + echo " remote(HttpBuildCache) {" >> $GITHUB_OUTPUT + echo " push = System.getenv('CI') == 'true'" >> $GITHUB_OUTPUT + echo " enabled = true" >> $GITHUB_OUTPUT + echo " url = 'https://ge.grails.org/cache/'" >> $GITHUB_OUTPUT + echo " credentials {" >> $GITHUB_OUTPUT + echo " username = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER')" >> $GITHUB_OUTPUT + echo " password = System.getenv('GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY')" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo " }" >> $GITHUB_OUTPUT + echo "}" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + - name: Gradle Enterprise Set-up + run: | + cd ../groovy + # Delete exiting plugins and build-scan from settings.gradle file + sed -i '21,31d' settings.gradle + # Add Gradle Enterprise set-up related configuration after line no 20 in settings.gradle + echo "${{ steps.ge_conf.outputs.value}}" | sed -i -e "20r /dev/stdin" settings.gradle + - name: Build and install groovy (no docs) + uses: gradle/gradle-build-action@v2 + env: + GRADLE_SCANS_ACCEPT: yes + 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: + build-root-directory: ../groovy + arguments: | + install + -x groovydoc + -x javadoc + -x javadocAll + -x groovydocAll + -x asciidoc + -x docGDK + build_grails_views: + needs: [build_groovy] + strategy: + fail-fast: true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: '11' + - name: Cache local Maven repository & Groovy + uses: actions/cache@v3 + with: + path: | + ~/groovy + ~/.m2/repository + key: cache-local-groovy-maven-${{ github.sha }} + - name: Set CI_GROOVY_VERSION for Grails + run: | + echo "CI_GROOVY_VERSION=${{needs.build_groovy.outputs.groovyVersion}}" >> $GITHUB_ENV + - name: 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: + arguments: | + build + -Dgeb.env=chromeHeadless \ No newline at end of file diff --git a/build.gradle b/build.gradle index 938a063ba..37fe5b06a 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,8 @@ subprojects { subproject-> version subproject.projectVersion + ext['groovyVersion'] = System.getenv('CI_GROOVY_VERSION') ?: project.groovyVersion + subproject.configurations { all { resolutionStrategy { @@ -57,6 +59,12 @@ subprojects { subproject-> } } + repositories { + mavenLocal() + mavenCentral() + maven { url "https://repo.grails.org/grails/core" } + } + if (subproject.name.startsWith('examples') || subproject.name.endsWith('docs')) { return } @@ -77,11 +85,6 @@ subprojects { subproject-> sourceCompatibility = 1.11 targetCompatibility = 1.11 - repositories { - mavenCentral() - maven { url "https://repo.grails.org/grails/core" } - } - apply from: '../publishing/grailsCentralPublishing.gradle'