Repository navigation
314 lines (291 loc) · 15.8 KB
/
Copy pathjava-compile.yml
File metadata and controls
314 lines (291 loc) · 15.8 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
name: Generated Java Compiles
# The COBOL -> Java generator (#3121): the Spring Boot projects `cobol-to-java`
# writes must COMPILE, under every supported target config (#3613). Each job
# refactors one pinned mainframe corpus (tests/cobol_mainframe/corpora.json),
# generates the Java under a set of configs, and runs the real build (Maven, or
# Gradle for the gradle rows) with JDK 17 and 21: tests/tools/java_target_matrix.py.
# CardDemo runs every config; the other corpora run default / plain-records /
# gradle, so the generator meets each corpus's shapes. Each set runs twice: from
# the refactoring stage alone, and against an engine scan (--scan), where the
# generator builds from the verified skeleton (#3614) -- CICS transaction
# endpoints and COMMAREA / channel DTOs (#3615).
#
# Runs when the generator or what feeds it changes, on push to main, weekly
# (dependency drift on Maven Central), and on demand.
#
# On a pull request, each job first asks whether the PR changes the generated Java
# at all (java_target_matrix.py --same-as): it generates both paths with the PR's
# code and with the base branch's code and compares every file. Identical output
# needs no compile -- the base already compiles (push to main builds it) -- so the
# JDK / Gradle setup and both builds are skipped and the summary says why. Only what
# the build reads is compared (src/, pom.xml, the Gradle files): a change confined to
# porting tickets, worklists or audits needs no compile. Any build-input difference,
# or a side that fails to generate, builds -- from the projects the check already
# generated, so the corpus is not refactored (or scanned) a third time. The four
# generations run side by side, and the base's are cached per content hash of the generation inputs, so a
# second push to the same PR generates only the head. Pushes, the weekly run and
# manual runs always build from scratch.
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review] # #5104: a draft starts only the cheap audits
branches: [main]
paths:
- "gitgalaxy/cobol_to_java_controller.py"
- "gitgalaxy/cobol_refractor_controller.py"
- "gitgalaxy/tools/cobol_to_java/**"
- "gitgalaxy/tools/cobol_to_cobol/**"
- "gitgalaxy/standards/yaml_reader.py"
- "gitgalaxy/standards/fact_channel_confidence.json"
- "tests/tools/java_target_matrix.py"
- "tests/cobol_mainframe/corpora.json"
- ".github/workflows/java-compile.yml"
- "tests/tools/mainframe_corpus.py" # #4825: read by this workflow (workflow_inputs.py)
push:
branches: [main]
paths:
- "gitgalaxy/cobol_to_java_controller.py"
- "gitgalaxy/cobol_refractor_controller.py"
- "gitgalaxy/tools/cobol_to_java/**"
- "gitgalaxy/tools/cobol_to_cobol/**"
- "gitgalaxy/standards/yaml_reader.py"
- "gitgalaxy/standards/fact_channel_confidence.json"
- "tests/tools/java_target_matrix.py"
- "tests/cobol_mainframe/corpora.json"
- ".github/workflows/java-compile.yml"
schedule:
- cron: "17 6 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true # #4825: read-only, so a superseded main run is cancelled too (frees runners for PRs)
jobs:
# #4964 (sibling of #4935): a push to main whose tree already passed THIS workflow on its PR head (a squash of an
# up-to-date PR) is not run again; any doubt runs it (tests/tools/skip_tested_tree.py has the rule, and tests).
# No PR run on the head (the PR's paths filter skipped it) is "not proven", so the push runs. Always concludes success.
# #5129: only a main push run can be skipped, so the gate runs on push only: a PR run (and a schedule / dispatch run,
# which never skips) starts its heavy jobs without waiting on it. A skipped gate leaves `skip` empty: they run.
tested-tree:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
actions: read
pull-requests: read
outputs:
skip: ${{ steps.decide.outputs.skip }}
steps:
- name: Checkout the gate script
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
sparse-checkout: tests/tools/skip_tested_tree.py
sparse-checkout-cone-mode: false
persist-credentials: false
- name: Decide
id: decide
env:
GH_TOKEN: ${{ github.token }}
run: python tests/tools/skip_tested_tree.py java-compile.yml
compile:
needs: tested-tree
if: ${{ (github.event_name != 'pull_request' || github.event.pull_request.draft == false) && (!cancelled() && needs.tested-tree.outputs.skip != 'true') }}
name: compile (${{ matrix.corpus }})
runs-on: ubuntu-latest
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
include:
- corpus: aws-mainframe-modernization-carddemo
configs: "" # every config in java_target_matrix.MATRIX
- corpus: cics-banking-sample-application-cbsa
configs: "default plain-records gradle"
- corpus: cics-genapp
configs: "default plain-records gradle"
- corpus: zopeneditor-sample
configs: "default plain-records gradle"
- corpus: zecs
configs: "default plain-records gradle"
- corpus: dsf
configs: "default plain-records gradle"
env:
GITGALAXY_LICENSE_KEY: COMMUNITY_FREE_TIER
GITGALAXY_MAINFRAME_CORPORA: ${{ github.workspace }}/.mainframe_corpora
PYTHONUTF8: "1"
steps:
- name: Checkout GitGalaxy
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
path: gitgalaxy
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: |
gitgalaxy/pyproject.toml
gitgalaxy/ci/requirements/*.txt
- name: Install GitGalaxy
run: |
cd gitgalaxy
python -m pip install --require-hashes -r ci/requirements/bootstrap.txt
pip install -e .
- name: Cache the pinned corpora
id: corpora
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .mainframe_corpora
key: mainframe-corpora-${{ hashFiles('gitgalaxy/tests/cobol_mainframe/corpora.json') }}
- name: Fetch the pinned corpora
run: |
cd gitgalaxy
rm -rf "$GITGALAXY_MAINFRAME_CORPORA/_scans"
PYTHONPATH="$PWD" python tests/tools/mainframe_corpus.py fetch
# #5024: restore-only on pull requests. A PR's cache scope is its own ref, so a PR that saved here left
# a copy per PR (a PR that edits corpora.json) that nothing else could read. Main saves it, once per key.
- name: Save the pinned corpora (main)
if: github.event_name != 'pull_request' && steps.corpora.outputs.cache-hit != 'true'
continue-on-error: true # best effort: a miss only costs the next run a clone
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .mainframe_corpora
key: mainframe-corpora-${{ hashFiles('gitgalaxy/tests/cobol_mainframe/corpora.json') }}
- name: Checkout the base branch (pull requests)
if: github.event_name == 'pull_request'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
persist-credentials: false
# #4968: restore-only on every ref. A PR's cache scope is its own ref, so a PR that saved here left one copy per PR
# (13-14 per corpus) that nothing else could read. Main saves it below, keyed on the commit a PR's base is.
- name: Restore the base branch's generation
id: base-gen
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/java_base_cache
# #5142: keyed on the CONTENT of the files that decide the generation (the paths: list above), of the base checkout on a PR
# and of main's own checkout on a push. The old key was the base COMMIT, which has an entry only for the ~43 pct of
# main commits that touch those paths (the push run is path-filtered), so most PRs missed and regenerated both sides.
key: java-same-base-${{ matrix.corpus }}-${{ github.event_name == 'pull_request' && hashFiles('base/gitgalaxy/cobol_to_java_controller.py', 'base/gitgalaxy/cobol_refractor_controller.py', 'base/gitgalaxy/tools/cobol_to_java/**', 'base/gitgalaxy/tools/cobol_to_cobol/**', 'base/gitgalaxy/standards/yaml_reader.py', 'base/gitgalaxy/standards/fact_channel_confidence.json', 'base/tests/tools/java_target_matrix.py', 'base/tests/cobol_mainframe/corpora.json', 'base/tests/tools/mainframe_corpus.py') || hashFiles('gitgalaxy/gitgalaxy/cobol_to_java_controller.py', 'gitgalaxy/gitgalaxy/cobol_refractor_controller.py', 'gitgalaxy/gitgalaxy/tools/cobol_to_java/**', 'gitgalaxy/gitgalaxy/tools/cobol_to_cobol/**', 'gitgalaxy/gitgalaxy/standards/yaml_reader.py', 'gitgalaxy/gitgalaxy/standards/fact_channel_confidence.json', 'gitgalaxy/tests/tools/java_target_matrix.py', 'gitgalaxy/tests/cobol_mainframe/corpora.json', 'gitgalaxy/tests/tools/mainframe_corpus.py') }}
- name: Keep this commit's generation for the pull requests based on it (main)
id: keep-gen
if: github.event_name != 'pull_request' && steps.base-gen.outputs.cache-hit != 'true'
continue-on-error: true # best effort: a miss only costs the next PR a base generation
env:
CORPUS: ${{ matrix.corpus }}
CONFIGS: ${{ matrix.configs }}
run: |
cd gitgalaxy
ONLY=()
if [ -n "$CONFIGS" ]; then ONLY=(--only $CONFIGS); fi
# this checkout is its own base: the run keeps the base side's projects in the cache directory
PYTHONPATH="$PWD" python tests/tools/java_target_matrix.py \
"$GITGALAXY_MAINFRAME_CORPORA/$CORPUS" \
--same-as "$GITHUB_WORKSPACE/gitgalaxy" \
--base-cache "$RUNNER_TEMP/java_base_cache" \
--work "$RUNNER_TEMP/java_keep" \
"${ONLY[@]}"
- name: Save the generation under this commit (main)
if: github.event_name != 'pull_request' && steps.base-gen.outputs.cache-hit != 'true' && steps.keep-gen.outcome == 'success'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/java_base_cache
key: java-same-base-${{ matrix.corpus }}-${{ hashFiles('gitgalaxy/gitgalaxy/cobol_to_java_controller.py', 'gitgalaxy/gitgalaxy/cobol_refractor_controller.py', 'gitgalaxy/gitgalaxy/tools/cobol_to_java/**', 'gitgalaxy/gitgalaxy/tools/cobol_to_cobol/**', 'gitgalaxy/gitgalaxy/standards/yaml_reader.py', 'gitgalaxy/gitgalaxy/standards/fact_channel_confidence.json', 'gitgalaxy/tests/tools/java_target_matrix.py', 'gitgalaxy/tests/cobol_mainframe/corpora.json', 'gitgalaxy/tests/tools/mainframe_corpus.py') }}
- name: Is the generated Java unchanged? (pull requests)
id: same
if: github.event_name == 'pull_request'
continue-on-error: true # "changed" (exit 1) just means: build
env:
CORPUS: ${{ matrix.corpus }}
CONFIGS: ${{ matrix.configs }}
run: |
cd gitgalaxy
ONLY=()
if [ -n "$CONFIGS" ]; then ONLY=(--only $CONFIGS); fi
python tests/tools/java_target_matrix.py \
"$GITGALAXY_MAINFRAME_CORPORA/$CORPUS" \
--same-as "$GITHUB_WORKSPACE/base" \
--base-cache "$RUNNER_TEMP/java_base_cache" \
--work "$RUNNER_TEMP/java_same" \
--summary "$GITHUB_STEP_SUMMARY" \
"${ONLY[@]}"
- name: Setup JDK 17 and 21
if: steps.same.outputs.identical != 'true'
uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: temurin
java-version: |
21
17
- name: Setup Gradle
if: steps.same.outputs.identical != 'true'
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
gradle-version: "8.10.2"
cache-disabled: true # #4968: its own key ends in the run's sha (64 gradle-home-v2 entries); keyed on hashes below
# #4968: the dependency caches are keyed on the files that decide what the builds download, and restore-only on a
# PR ref (one copy per PR otherwise); main saves them.
- name: Restore the Gradle and Maven dependency caches
id: deps
if: steps.same.outputs.identical != 'true'
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: java-compile-deps-${{ hashFiles('gitgalaxy/gitgalaxy/tools/cobol_to_java/cobol_to_java_build_forge.py', 'gitgalaxy/tests/tools/java_target_matrix.py') }}
restore-keys: java-compile-deps-
- name: Generate and compile
if: steps.same.outputs.identical != 'true'
env:
CORPUS: ${{ matrix.corpus }}
CONFIGS: ${{ matrix.configs }}
run: |
cd gitgalaxy
export JDK_17="$JAVA_HOME_17_X64" JDK_21="$JAVA_HOME_21_X64" JAVA_HOME="$JAVA_HOME_17_X64"
ONLY=()
if [ -n "$CONFIGS" ]; then ONLY=(--only $CONFIGS); fi
REUSE=() # a pull request's check already generated the head's projects
if [ -f "$RUNNER_TEMP/java_same/head/.complete" ]; then REUSE=(--generated "$RUNNER_TEMP/java_same/head"); fi
PYTHONPATH="$PWD" python tests/tools/java_target_matrix.py \
"$GITGALAXY_MAINFRAME_CORPORA/$CORPUS" \
"${REUSE[@]}" \
--work "$RUNNER_TEMP/java_matrix" \
--m2 "$HOME/.m2/repository" \
--summary "$GITHUB_STEP_SUMMARY" \
"${ONLY[@]}"
- name: Generate and compile (engine scan, verified skeleton)
# report both paths even when the first fails; skipped when the Java is unchanged
if: ${{ !cancelled() && steps.same.outputs.identical != 'true' }}
env:
CORPUS: ${{ matrix.corpus }}
CONFIGS: ${{ matrix.configs }}
run: |
cd gitgalaxy
export JDK_17="$JAVA_HOME_17_X64" JDK_21="$JAVA_HOME_21_X64" JAVA_HOME="$JAVA_HOME_17_X64"
ONLY=()
if [ -n "$CONFIGS" ]; then ONLY=(--only $CONFIGS); fi
REUSE=()
if [ -f "$RUNNER_TEMP/java_same/head_scan/.complete" ]; then REUSE=(--generated "$RUNNER_TEMP/java_same/head_scan"); fi
PYTHONPATH="$PWD" python tests/tools/java_target_matrix.py \
"$GITGALAXY_MAINFRAME_CORPORA/$CORPUS" \
"${REUSE[@]}" \
--scan \
--work "$RUNNER_TEMP/java_matrix_scan" \
--m2 "$HOME/.m2/repository" \
--summary "$GITHUB_STEP_SUMMARY" \
"${ONLY[@]}"
- name: Save the Gradle and Maven dependency caches (not on a pull request)
if: ${{ !cancelled() && github.event_name != 'pull_request' && steps.same.outputs.identical != 'true' && steps.deps.outputs.cache-hit != 'true' }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
~/.m2/repository
key: java-compile-deps-${{ hashFiles('gitgalaxy/gitgalaxy/tools/cobol_to_java/cobol_to_java_build_forge.py', 'gitgalaxy/tests/tools/java_target_matrix.py') }}