-
-
Notifications
You must be signed in to change notification settings - Fork 974
172 lines (170 loc) · 8.01 KB
/
Copy pathgroovy-joint-workflow.yml
File metadata and controls
172 lines (170 loc) · 8.01 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:
- '[0-9]+.[0-9]+.x'
pull_request:
branches:
- '[0-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@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 21
distribution: liberica
- name: "📥 Checkout Grails Core to fetch Gradle Plugin versions it uses"
# Sparse-checkout fetches only the two paths this job actually needs:
# - dependencies.gradle: parsed below to derive the matching Apache
# Groovy branch (GROOVY_<major>_0_X) for this Grails branch.
# - .github/scripts/groovy-joint-build.init.gradle: passed to
# ./gradlew --init-script when publishing Groovy to local Maven so
# the joint build reuses our Develocity / build-cache settings.
# Both paths must be listed here; otherwise the init-script step fails
# with "The specified initialization script ... does not exist."
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
dependencies.gradle
.github/scripts/groovy-joint-build.init.gradle
- name: "📝 Derive matching Apache Groovy branch from dependencies.gradle"
id: groovy-branch
run: |
# Extract the major version of `groovy.version` declared in this branch's
# dependencies.gradle (e.g. '5.0.5' -> '5', '4.0.31' -> '4') and use it to
# pick the matching Apache Groovy development branch (GROOVY_<major>_0_X),
# or master for the current Groovy development line before a maintenance
# branch exists.
# This keeps `7.0.x` PRs validating against Groovy 4 and `8.0.x` PRs
# validating against Groovy 5 without hard-coding the branch here.
GROOVY_MAJOR=$(grep -m 1 "'groovy\.version'" dependencies.gradle | sed -E "s/.*'([0-9]+)\.[0-9]+\.[0-9]+.*/\1/" | tr -d '[:space:]')
if [ -z "$GROOVY_MAJOR" ]; then
echo "::error::Could not determine Apache Groovy major version from dependencies.gradle"
exit 1
fi
if [ "$GROOVY_MAJOR" = "6" ]; then
GROOVY_BRANCH="master"
else
GROOVY_BRANCH="GROOVY_${GROOVY_MAJOR}_0_X"
fi
echo "Validating against Apache Groovy branch: $GROOVY_BRANCH"
echo "value=$GROOVY_BRANCH" >> $GITHUB_OUTPUT
rm dependencies.gradle
- name: "📥 Checkout Apache Groovy (${{ steps.groovy-branch.outputs.value }})"
run: git clone --depth 1 https://github.com/apache/groovy.git -b ${{ steps.groovy-branch.outputs.value }} --single-branch
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
cache-disabled: true # this workflow rebuilds Groovy each run; a Gradle home cache is not useful here
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@3f82d2dc6cd5c03f02ce5f7885a21195d85f8d14 # v1.9.3
- 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: "🔨 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 \
--init-script $GITHUB_WORKSPACE/.github/scripts/groovy-joint-build.init.gradle
- name: "📤 Share locally built Groovy artifacts with the build_grails job"
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: local-groovy-maven-repo
path: ~/.m2/repository/org/apache/groovy/
if-no-files-found: 'error'
retention-days: 1
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: "⚙️ Maximize build space"
run: |
echo "-- Dotnet"
sudo rm -rf /usr/share/dotnet
echo "-- Android"
sudo rm -rf /usr/local/lib/android
echo "-- Haskell"
sudo rm -rf /opt/ghc
echo "-- CodeQL"
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h
- name: "📥 Checkout project"
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: "☕️ Setup JDK"
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 21
distribution: liberica
- name: "🐘 Setup Gradle"
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
with:
cache-disabled: true # this workflow rebuilds Groovy each run; a Gradle home cache is not useful here
develocity-access-key: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: "🔍 Setup TestLens"
uses: testlens-app/setup-testlens@3f82d2dc6cd5c03f02ce5f7885a21195d85f8d14 # v1.9.3
- name: "📥 Fetch the locally built Groovy artifacts"
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: local-groovy-maven-repo
path: ~/.m2/repository/org/apache/groovy
- 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"
# -PskipMicronautProjects excludes the Grails-Micronaut "island" (grails-micronaut,
# grails-micronaut-bom, and the micronaut-tied test-examples) from the build graph.
# That island intentionally pins Groovy 5 / Spock 2.4-groovy-5.0 via grails-micronaut-bom,
# which is incompatible with the Groovy 4.x snapshot this job swaps in above.
# See https://github.com/apache/grails-core/issues/15613.
run: >
./gradlew build
--continue
--stacktrace
-x groovydoc
-PskipCodeStyle
-PskipMicronautProjects
-PmaxTestParallel=3
env:
GRAILS_INCLUDE_MAVEN_LOCAL: true