Repository navigation
69 lines (63 loc) · 2.45 KB
/
Copy pathjava-runtime.yml
File metadata and controls
69 lines (63 loc) · 2.45 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
#
# 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: CI Java runtime
on:
workflow_call:
inputs:
extra-java-versions:
description: Additional JDKs to test alongside the configured project runtime (JSON array).
type: string
default: '[]'
outputs:
versions:
description: Project runtime followed by any additional test JDKs (JSON array).
value: ${{ jobs.read-version.outputs.versions }}
permissions:
contents: read
jobs:
read-version:
runs-on: ubuntu-24.04
outputs:
versions: ${{ steps.java.outputs.versions }}
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Read the project runtime and optional test JDKs
id: java
env:
EXTRA_JAVA_VERSIONS: ${{ inputs.extra-java-versions }}
run: |
python3 - <<'PYTHON'
import json
import os
import re
from pathlib import Path
runtime = Path('.github/workflows/.java-version').read_text().strip()
extra = json.loads(os.environ['EXTRA_JAVA_VERSIONS'])
if not isinstance(extra, list):
raise ValueError('extra-java-versions must be a JSON array')
versions = []
for version in [runtime, *extra]:
if not isinstance(version, str) or not re.fullmatch(r'[1-9][0-9]*(\.[0-9]+)*', version):
raise ValueError('Java versions must be non-empty numeric strings')
if version not in versions:
versions.append(version)
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
print('versions=' + json.dumps(versions), file=output)
PYTHON