forked from swiftlang/swift-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-validate.sh
More file actions
executable file
·46 lines (39 loc) · 2.25 KB
/
ci-validate.sh
File metadata and controls
executable file
·46 lines (39 loc) · 2.25 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
#!/bin/bash
set -x
set -e
# WORKAROUND: prebuilts broken on Swift 6.2.1 and Linux and tests using macros https://github.com/swiftlang/swift-java/issues/418
if [ "$(uname)" = "Darwin" ]; then
DISABLE_EXPERIMENTAL_PREBUILTS=''
else
DISABLE_EXPERIMENTAL_PREBUILTS='--disable-experimental-prebuilts'
fi
if [[ "$(uname)" == "Darwin" && -n "$GITHUB_ACTION" ]]; then
# WORKAROUND: GitHub Actions on macOS issue with downloading gradle wrapper
# We seem to be hitting a problem when the swiftpm plugin, needs to execute gradle wrapper in a new gradle_user_home.
# Normally, this would just download gradle again and kick off a build, this seems to timeout *specifically* on
# github actions runners.
#
# It is not a sandbox problem, becuase the ./gradlew is run without sandboxing as we already execute
# the entire swift build with '--disable-sandbox' for other reasons.
#
# We cannot use the same gradle user home as the default one since we might make gradle think we're
# building the same project concurrently, which we kind of are, however only a limited subset in order
# to trigger wrap-java with those dependencies.
#
# TODO: this may use some further improvements so normal usage does not incur another wrapper download.
./gradlew -h # prime ~/.gradle/wrapper/dists/...
# Worst part of workaround here; we make sure to pre-load the resolved gradle wrapper downloaded distribution
# to the "known" location the plugin will use for its local builds, which are done in order to compile SwiftKitCore.
# This build is only necessary in order to drive wrap-java on sources generated during the build itself
# which enables the "Implement Swift protocols in Java" feature of jextract/jni mode.
GRADLE_USER_HOME="$(pwd)/.build/plugins/outputs/swiftjavaextractjnisampleapp/MySwiftLibrary/destination/JExtractSwiftPlugin/gradle-user-home"
if [ -d "$HOME/.gradle" ] ; then
echo "COPY $HOME/.gradle to $GRADLE_USER_HOME"
mkdir -p "$GRADLE_USER_HOME"
cp -r "$HOME/.gradle/"* "$GRADLE_USER_HOME/" || true
fi
fi
# FIXME: disable prebuilts until prebuilt swift-syntax isn't broken on 6.2 anymore: https://github.com/swiftlang/swift-java/issues/418
swift build $DISABLE_EXPERIMENTAL_PREBUILTS --disable-sandbox
./gradlew run
./gradlew test