Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Update github workflows #592

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 49 additions & 48 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java CI
name: "Java CI"
on:
push:
branches:
Expand All @@ -9,72 +9,73 @@ on:
env:
GIT_USER_NAME: 'grails-build'
GIT_USER_EMAIL: '[email protected]'

jobs:

test_project:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Run Tests
if: github.event_name == 'pull_request'
id: tests
uses: gradle/actions/setup-gradle@v3
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 }}
distribution: temurin
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
arguments: check -Dgeb.env=chromeHeadless

develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🏃 Run Tests"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
-Dgeb.env=chromeHeadless
check
build_project:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v2
- uses: actions/setup-java@v4
with: { java-version: 17, distribution: temurin }
- name: Run Build
uses: gradle/actions/setup-gradle@v3
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 }}
- name: "📥 Checkout repository"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
arguments: build -Dgeb.env=chromeHeadless

- name: Publish Snapshot artifacts to Artifactory (repo.grails.org)
java-version: 17
distribution: temurin
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🔨 Build project"
env:
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
-Dgeb.env=chromeHeadless
build
- name: "📤 Publish Snapshot Artifacts to Artifactory (repo.grails.org)"
if: success()
uses: gradle/actions/setup-gradle@v3
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 }}
DEVELOVITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
ORG_GRADLE_PROJECT_artifactoryUsername: ${{ secrets.ARTIFACTORY_USERNAME }}
ORG_GRADLE_PROJECT_artifactoryPassword: ${{ secrets.ARTIFACTORY_PASSWORD }}
with:
arguments: |
-Dorg.gradle.internal.publish.checksums.insecure=true
publish

- name: Generate Snapshot Documentation
run: >
./gradlew
-Dorg.gradle.internal.publish.checksums.insecure=true
publish
- name: "📖 Generate Snapshot Documentation"
if: success()
uses: gradle/actions/setup-gradle@v3
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: views-docs:docs

- name: Publish Snapshot Documentation to Github Pages
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
views-docs:docs
- name: "📤 Publish Snapshot Documentation to Github Pages"
if: success()
uses: micronaut-projects/github-pages-deploy-action@grails
env:
Expand Down
206 changes: 94 additions & 112 deletions .github/workflows/groovy-joint-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# 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
#
# https://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.
name: "Groovy Joint Validation Build"
on:
push:
branches:
Expand All @@ -27,138 +9,138 @@ on:
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
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Cache local Maven repository & Groovy
- name: "🗄️ Cache local Maven repository"
uses: actions/cache@v4
with:
path: |
~/groovy
~/.m2/repository
key: cache-local-groovy-maven-${{ github.sha }}
- name: Checkout Groovy 4_0_X (Grails 7 and later)
run: cd .. && git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch
- name: Set CI_GROOVY_VERSION for Grails
path: ~/.m2/repository
key: cache-local-maven-${{ github.sha }}
- name: "📥 Checkout Grails Views to fetch Gradle Plugin versions it uses"
uses: actions/checkout@v4
with:
sparse-checkout-cone-mode: false
sparse-checkout: settings.gradle
- name: "📝 Store the Gradle Plugin versions used in Grails Views"
id: gradle-plugin-versions
run: |
DEVELOCITY_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.develocity\"\|'"'com.gradle.develocity'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:])
COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION=$(grep -m 1 'id\s*\(\"com.gradle.common-custom-user-data-gradle-plugin\"\|'"'com.gradle.common-custom-user-data-gradle-plugin'"'\)\s*version' settings.gradle | sed -E "s/.*version[[:space:]]*['\"]?([0-9]+\.[0-9]+(\.[0-9]+)?)['\"]?.*/\1/" | tr -d [:space:])
echo "Project uses Develocity Plugin version: $DEVELOCITY_PLUGIN_VERSION"
echo "Project uses Common Custom User Data Plugin version: $COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION"
echo "develocity_plugin_version=$DEVELOCITY_PLUGIN_VERSION" >> $GITHUB_OUTPUT
echo "common_custom_user_data_plugin_version=$COMMON_CUSTOM_USER_DATA_PLUGIN_VERSION" >> $GITHUB_OUTPUT
rm settings.gradle
- name: "📥 Checkout Groovy 4_0_X (Grails 7 and later)"
run: git clone --depth 1 https://github.com/apache/groovy.git -b GROOVY_4_0_X --single-branch
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "📝 Store Groovy version to use when building Grails Views"
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 Develocity Setup 1
id: develocity_conf_1
cd groovy
GROOVY_VERSION=$(cat gradle.properties | grep groovyVersion | cut -d\= -f2 | tr -d '[:space:]')
echo "Groovy version $GROOVY_VERSION stored"
echo "value=$GROOVY_VERSION" >> $GITHUB_OUTPUT
- name: "🐘 Configure Gradle Plugins (Step 1/3)"
id: develocity-conf-1
run: |
echo "VALUE<<EOF" >> $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 " id 'com.gradle.develocity' version '${{ steps.gradle-plugin-versions.outputs.develocity_plugin_version }}'" >> $GITHUB_OUTPUT
echo " id 'com.gradle.common-custom-user-data-gradle-plugin' version '${{ steps.gradle-plugin-versions.outputs.common_custom_user_data_plugin_version }}'" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Prepare Develocity Setup 2
id: develocity_conf_2
- name: "🐘 Configure Gradle Plugins (Step 2/3)"
id: develocity-conf-2
run: |
echo "VALUE<<EOF" >> $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 "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY') != null" >> $GITHUB_OUTPUT
echo "def isBuildCacheAuthenticated =" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') != null &&" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') != null" >> $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 "develocity {" >> $GITHUB_OUTPUT
echo " server = 'https://ge.grails.org'" >> $GITHUB_OUTPUT
echo " buildScan {" >> $GITHUB_OUTPUT
echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT
echo " uploadInBackground = false" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "buildCache {" >> $GITHUB_OUTPUT
echo " local { enabled = false }" >> $GITHUB_OUTPUT
echo " remote(develocity.buildCache) {" >> $GITHUB_OUTPUT
echo " push = isBuildCacheAuthenticated" >> $GITHUB_OUTPUT
echo " enabled = true" >> $GITHUB_OUTPUT
echo " usernameAndPassword(" >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_USER') ?: ''," >> $GITHUB_OUTPUT
echo " System.getenv('DEVELOCITY_BUILD_CACHE_NODE_KEY') ?: ''" >> $GITHUB_OUTPUT
echo " )" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Develocity Set-up
- name: "🐘 Configure Gradle Plugins (step 3/3)"
run: |
cd ../groovy
cd groovy
# Delete existing plugins from settings.gradle file
sed -i '32,37d' settings.gradle
# Add Gradle Enterprise set-up related configuration after line no 31 in settings.gradle
echo "${{ steps.develocity_conf_1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle
# Add Develocity setup related configuration after line no 31 in settings.gradle
echo "${{ steps.develocity-conf-1.outputs.value }}" | sed -i -e "31r /dev/stdin" settings.gradle
# Delete existing buildCache configuration from gradle/build-scans.gradle file
sed -i '23,46d' gradle/build-scans.gradle
# Add Gradle Enterprise set-up related configuration after line no 22 in gradle/build-scans.gradle
echo "${{ steps.develocity_conf_2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle
- name: Build and install groovy (no docs)
uses: gradle/gradle-build-action@v3
# Add Develocity setup related configuration after line no 22 in gradle/build-scans.gradle
echo "${{ steps.develocity-conf-2.outputs.value }}" | sed -i -e "22r /dev/stdin" gradle/build-scans.gradle
- name: "🔨 Publish Groovy to local maven repository (no docs)"
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
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: |
cd groovy
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK

build_project:
needs: [build_groovy]
strategy:
fail-fast: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK
- name: "📥 Checkout project"
uses: actions/checkout@v4
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Cache local Maven repository & Groovy
distribution: temurin
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@v4
with:
develocity-access-key: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
- name: "🗄️ Restore local Maven repository from cache"
uses: actions/cache@v4
with:
path: |
~/groovy
~/.m2/repository
key: cache-local-groovy-maven-${{ github.sha }}

- name: Build Project
uses: gradle/actions/setup-gradle@v3
path: ~/.m2/repository
key: cache-local-maven-${{ github.sha }}
- name: "🪶 Add mavenLocal repository to build"
run: sed -i 's|// mavenLocal() // Keep|mavenLocal() // Keep|' build.gradle
- name: "🔨 Build and test Grails using the locally built Groovy snapshot"
env:
GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
CI_GROOVY_VERSION: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
ORG_GRADLE_PROJECT_groovyVersion: ${{ needs.build_groovy.outputs.groovySnapshotVersion }}
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
-x groovydoc
-Dgeb.env=chromeHeadless
DEVELOCITY_BUILD_CACHE_NODE_USER: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_USER }}
DEVELOCITY_BUILD_CACHE_NODE_KEY: ${{ secrets.GRADLE_ENTERPRISE_BUILD_CACHE_NODE_KEY }}
run: >
./gradlew
build
-Dgeb.env=chromeHeadless
-PgroovyVersion=${{needs.build_groovy.outputs.groovyVersion}}
-x groovydoc
Loading
Loading