Skip to content

Commit d07266e

Browse files
committed
Prepared gradle and swift tests with installed jdk
1 parent 38dca51 commit d07266e

File tree

2 files changed

+86
-18
lines changed

2 files changed

+86
-18
lines changed

.github/workflows/pull_request.yml

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,58 @@ on:
66

77
jobs:
88
soundness:
9-
name: Soundness
10-
uses: https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/soundness.yml
9+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
1110
with:
1211
api_breakage_check_enabled: false
12+
1313
test-java:
1414
name: Java tests (${{ matrix.swift_version }} - ${{ matrix.os_version }})
1515
runs-on: ubuntu-latest
1616
strategy:
17-
fail-fast: false
17+
fail-fast: true
1818
matrix:
19-
swift_version: ['6.0', 'nightly-main']
20-
os_version: ['jammy']
19+
swift_version: [ nightly-main' ]
20+
os_version: [ 'jammy' ]
21+
container:
22+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
23+
env:
24+
JAVA_HOME: "/usr/lib/jvm/openjdk-23"
2125
steps:
2226
- uses: actions/checkout@v4
23-
- uses: actions/setup-java@v4
24-
with:
25-
distribution: 'zulu'
26-
java-version: '22'
27-
cache: 'gradle'
28-
- run: ./gradlew build --no-daemon
27+
- name: Install Make
28+
run: apt update && apt install -y make
29+
- name: Install JDK
30+
run: "./scripts/install_jdk.sh"
31+
# TODO: not using setup-java since incompatible with the swiftlang/swift base image
32+
# - uses: actions/setup-java@v4
33+
# with:
34+
# distribution: 'zulu'
35+
# java-version: '22'
36+
# cache: 'gradle'
37+
- name: Generate sources (make) (Temporary)
38+
# TODO: this should be triggered by the respective builds
39+
run: make jextract-run
40+
- name: Gradle build
41+
run: ./gradlew build --no-daemon
42+
2943
test-swift:
3044
name: Swift tests (${{ matrix.swift_version }} - ${{ matrix.os_version }})
31-
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
32-
with:
33-
exclude_swift_versions: "[{\"swift_version\": \"5.8\"}, {\"swift_version\": \"5.9\"}, {\"swift_version\": \"5.10\"}]"
34-
pre_build_command: "apt-get update -y -q && apt-get install -y -q openjdk-21-jdk make"
35-
build_command: "make jextract-run"
36-
env_vars: |
37-
JAVA_HOME="/usr/lib/jvm/java-21-openjdk-amd64"
45+
runs-on: ubuntu-latest
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
swift_version: [ '6.0' ]
50+
os_version: [ 'jammy' ]
51+
container:
52+
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Install Make
56+
run: apt update && apt install -y make
57+
- name: Install JDK
58+
run: "./scripts/install_jdk.sh"
59+
- name: Generate sources (make) (Temporary)
60+
# TODO: this should be triggered by the respective builds
61+
run: "make jextract-run"
62+
- name: Test Swift
63+
run: "swift test"

scripts/install_jdk.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
##===----------------------------------------------------------------------===##
3+
##
4+
## This source file is part of the Swift.org open source project
5+
##
6+
## Copyright (c) 2024 Apple Inc. and the Swift.org project authors
7+
## Licensed under Apache License v2.0
8+
##
9+
## See LICENSE.txt for license information
10+
##
11+
## SPDX-License-Identifier: Apache-2.0
12+
##
13+
##===----------------------------------------------------------------------===##
14+
set -euo pipefail
15+
16+
declare -r JDK_VERSION=23
17+
echo "Installing OpenJDK $JDK_VERSION..."
18+
19+
apt-get update && apt-get install -y make curl libc6-dev
20+
21+
echo "Download JDK for: $(uname -m)"
22+
23+
if [ "$(uname -m)" = 'aarch64' ]; then
24+
curl https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_linux-aarch64_bin.tar.gz --output jdk.tar.gz &&
25+
declare -r EXPECT_JDK_SHA=076dcf7078cdf941951587bf92733abacf489a6570f1df97ee35945ffebec5b7;
26+
else
27+
curl https://download.java.net/java/GA/jdk23/3c5b90190c68498b986a97f276efd28a/37/GPL/openjdk-23_linux-x64_bin.tar.gz --output jdk.tar.gz &&
28+
declare -r EXPECT_JDK_SHA=08fea92724127c6fa0f2e5ea0b07ff4951ccb1e2f22db3c21eebbd7347152a67;
29+
fi
30+
31+
declare -r JDK_SHA="$(sha256sum jdk.tar.gz | cut -d ' ' -f 1)"
32+
if [ "$JDK_SHA" != "$EXPECT_JDK_SHA" ]; then
33+
echo "Downloaded JDK SHA does not match expected!" &&
34+
exit 1;
35+
else
36+
echo "JDK SHA is correct.";
37+
fi
38+
39+
# Extract and verify the JDK installation
40+
tar xzvf jdk.tar.gz && rm jdk.tar.gz && mkdir -p /usr/lib/jvm; mv jdk-23 /usr/lib/jvm/openjdk-23
41+
echo "JAVA_HOME = /usr/lib/jvm/openjdk-23"
42+
/usr/lib/jvm/openjdk-23/bin/java -version

0 commit comments

Comments
 (0)