-
-
Notifications
You must be signed in to change notification settings - Fork 970
172 lines (170 loc) · 8.1 KB
/
groovy-joint-workflow.yml
File metadata and controls
172 lines (170 loc) · 8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# 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: "CI - Groovy Joint Validation Build"
on:
push:
branches:
- '[4-9]+.[0-9]+.x'
pull_request:
branches:
- '[4-9]+.[0-9]+.x'
workflow_dispatch:
# queue jobs and only allow 1 run per branch due to the likelihood of hitting GitHub resource limits
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
jobs:
build_groovy:
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
runs-on: ubuntu-latest
outputs:
groovyVersion: ${{ steps.groovy-version.outputs.value }}
steps:
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
java-version: 17
distribution: liberica
- name: "🗄️ Cache local Maven repository"
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: cache-local-maven-${{ github.sha }}
- name: "📥 Checkout Grails Core to fetch Gradle Plugin versions it uses"
uses: actions/checkout@v6
with:
sparse-checkout-cone-mode: false
sparse-checkout: settings.gradle
- name: "📝 Store the Gradle Plugin versions used in this project"
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@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@v1
- name: "📝 Store Groovy version to use when building Grails"
id: groovy-version
run: |
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.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: "🐘 Configure Gradle Plugins (Step 2/3)"
id: develocity-conf-2
run: |
echo "VALUE<<EOF" >> $GITHUB_OUTPUT
echo "def isAuthenticated = System.getenv('DEVELOCITY_ACCESS_KEY ') != null" >> $GITHUB_OUTPUT
echo "develocity {" >> $GITHUB_OUTPUT
echo " server = 'https://develocity.apache.org'" >> $GITHUB_OUTPUT
echo " buildScan {" >> $GITHUB_OUTPUT
echo " tag('groovy')" >> $GITHUB_OUTPUT
echo " tag('grails-core')" >> $GITHUB_OUTPUT
echo " publishing.onlyIf { isAuthenticated }" >> $GITHUB_OUTPUT
echo " uploadInBackground = false" >> $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 = isAuthenticated" >> $GITHUB_OUTPUT
echo " enabled = true" >> $GITHUB_OUTPUT
echo " }" >> $GITHUB_OUTPUT
echo "}" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: "🐘 Configure Gradle Plugins (step 3/3)"
run: |
cd groovy
# Delete existing plugins from settings.gradle file
sed -i '32,37d' 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 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)"
run: |
cd groovy
./gradlew pTML -x groovydoc -x javadoc -x javadocAll -x groovydocAll -x asciidoc -x docGDK
build_grails:
needs: [build_groovy]
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:8
ports:
- 27017:27017
options: >-
--health-cmd "mongosh --eval 'db.adminCommand(\"ping\")'"
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: "📥 Checkout project"
uses: actions/checkout@v6
- name: "☕️ Setup JDK"
uses: actions/setup-java@v4
with:
java-version: 17
distribution: liberica
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@v1
- name: "🗄️ Restore local Maven repository from cache"
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: cache-local-maven-${{ github.sha }}
- name: 'Swap Groovy Version'
run: |
sed -i "/['\"]groovy\.version['\"][[:space:]]*:/c\'groovy.version':'${{ needs.build_groovy.outputs.groovyVersion }}'," dependencies.gradle
- name: "🔨 Build and test Grails using the locally built Groovy snapshot"
run: >
./gradlew build
--continue
--stacktrace
-x groovydoc
-PgebAtCheckWaiting
-PskipCodeStyle
-PmaxTestParallel=3
env:
GRAILS_INCLUDE_MAVEN_LOCAL: true