Skip to content

Prepare for Linux build and CI #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4cf2ae5
fix the imported _Subprocess build on Linux
ktoso Sep 30, 2024
96d58da
adjust gradle build to work with JDK23 that we now pull
ktoso Sep 30, 2024
2c9b36c
minor source/test adjustments for Linux
ktoso Sep 30, 2024
290e43d
fix include paths in Package.swift on Linux
ktoso Sep 30, 2024
db9835d
Explain dependencies in README
ktoso Sep 30, 2024
862d4b3
Initial docker setup so that we can locally run linux tests
ktoso Sep 30, 2024
e972628
explain how to run tests in docker in README
ktoso Sep 30, 2024
032078d
make docker commands for: test-swift and test-java
ktoso Sep 30, 2024
17196ab
[CI] Add support for GitHub Actions
shahmishal Sep 28, 2024
dbb0203
Use 'make' build command
shahmishal Sep 28, 2024
97cd94c
install make in the Dockerfile
shahmishal Sep 28, 2024
8ec9a2b
gh-action: exclude Swift older than 6.0
ktoso Sep 30, 2024
ff2341e
Prepare testing java tests in github actions
ktoso Sep 30, 2024
b0ecb85
include soundness check in CI
ktoso Sep 30, 2024
5cba2f5
back to requiring jdk 22
ktoso Sep 30, 2024
f267b34
Prepared gradle and swift tests with installed jdk
ktoso Sep 30, 2024
00b5e71
ignore bin directory
ktoso Sep 30, 2024
09680c4
include license_header_check_project_name
ktoso Sep 30, 2024
a3106d3
allow SILKILL to not cause unaccaptable language failure
ktoso Sep 30, 2024
c825f61
Add .licenseignore
ktoso Sep 30, 2024
bfa7bcd
fix license headers
ktoso Sep 30, 2024
a4b1975
fix license headers
ktoso Oct 1, 2024
245da1f
style fixes
ktoso Oct 1, 2024
f5fcd37
support Corretto in install jdk script
ktoso Oct 1, 2024
2ac5e47
Allow installing Corretto JDK
ktoso Oct 2, 2024
18042c8
allow customizing jdk we use from the workflow
ktoso Oct 2, 2024
d2dbd7b
debugging on real github actions runner, since these seem to work in act
ktoso Oct 2, 2024
801fcbb
Correct makefile for linux
ktoso Oct 2, 2024
1ceeac4
Cache gradle artifacts and wrapper
ktoso Oct 2, 2024
87ae73b
minor cleanup, silent apt-get
ktoso Oct 2, 2024
24d3e7b
update _Subprocess lib with complete linux support
ktoso Oct 2, 2024
9ddec55
subprocess: adjust shim imports
ktoso Oct 2, 2024
8f6d2f5
fix hardcoded build dir to work on linux
ktoso Oct 2, 2024
d073607
remove gradle cache for now
ktoso Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: pull_request

on:
pull_request:
types: [ opened, reopened, synchronize ]

jobs:
soundness:
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
with:
api_breakage_check_enabled: false
# FIXME: Something is off with the format task and it gets "stuck", need to investigate
format_check_enabled: false
license_header_check_project_name: Swift.org
# FIXME: we're about to remove _Subprocess immediately anyway, so rather than fixing it one by one remove this adjusted list and use the default again ASAP
# swift-subprocess includes the word "kill" because SIGKILL signal handling so we allow it
unacceptable_language_check_word_list: "blacklist whitelist slave master sane sanity insane insanity killed killing hang hung hanged hanging" #ignore-unacceptable-language

test-java:
name: Java tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
swift_version: [ 'nightly-main' ]
os_version: [ 'jammy' ]
jdk_vendor: [ 'Corretto' ]
container:
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
env:
JAVA_HOME: "/usr/lib/jvm/default-jdk"
steps:
- uses: actions/checkout@v4
- name: Install Make
run: apt-get -qq update && apt-get -qq install -y make
- name: Install JDK
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
# TODO: not using setup-java since incompatible with the swiftlang/swift base image
# - uses: actions/setup-java@v4
# with:
# distribution: 'zulu'
# java-version: '22'
# cache: 'gradle'
- name: Generate sources (make) (Temporary)
# TODO: this should be triggered by the respective builds
run: make jextract-run
- name: Gradle build
run: ./gradlew build --no-daemon

test-swift:
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift_version: [ 'nightly-main' ]
os_version: [ 'jammy' ]
jdk_vendor: [ 'Corretto' ]
container:
image: ${{ (contains(matrix.swift_version, 'nightly') && 'swiftlang/swift') || 'swift' }}:${{ matrix.swift_version }}-${{ matrix.os_version }}
env:
JAVA_HOME: "/usr/lib/jvm/default-jdk"
steps:
- uses: actions/checkout@v4
- name: Install Make
run: apt-get -qq update && apt-get -qq install -y make
- name: Install JDK
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
- name: Generate sources (make) (Temporary)
# TODO: this should be triggered by the respective builds
run: "make jextract-run"
- name: Test Swift
run: "swift test"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
*.class
bin/

# Ignore gradle build artifacts
.gradle
Expand Down
46 changes: 46 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.gitignore
.licenseignore
.swiftformatignore
.spi.yml
.swift-format
.github/*
*.md
CONTRIBUTORS.txt
LICENSE.txt
NOTICE.txt
Package.swift
Package.resolved
README.md
SECURITY.md
scripts/unacceptable-language.txt
docker/*
**/*.docc/*
**/.gitignore
**/Package.swift
**/Package.resolved
**/*.md
**/openapi.yml
**/petstore.yaml
**/openapi-generator-config.yaml
**/openapi-generator-config.yml
**/docker-compose.yaml
**/docker/*
**/.dockerignore
JavaSwiftKitDemo/src/main/java/com/example/swift/generated/*
Makefile
**/Makefile
**/*.html
**/CMakeLists.txt
**/*.jar
gradle/wrapper/gradle-wrapper.properties
gradlew
gradlew.bat
**/*.swift2java
Sources/JavaKit/generated/*
Sources/JavaKitJar/generated/*
Sources/JavaKitNetwork/generated/*
Sources/JavaKitReflection/generated/*
Sources/_Subprocess/*
Sources/_Subprocess/**/*
Sources/_SubprocessCShims/*
Sources/_SubprocessCShims/**/*
1 change: 1 addition & 0 deletions BuildLogic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
1 change: 1 addition & 0 deletions BuildLogic/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
1 change: 1 addition & 0 deletions JavaSwiftKitDemo/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

package com.example.swift;

import com.example.swift.HelloSwift;

public class HelloSubclass extends HelloSwift {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

package com.example.swift;

import com.example.swift.HelloSubclass;

public class HelloSwift {
Expand Down
1 change: 1 addition & 0 deletions JavaSwiftKitDemo/src/main/java/org/example/CallMe.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down Expand Up @@ -199,14 +200,13 @@ public static void globalCallJavaCallback(Runnable callMe) {
var mh$ = globalCallJavaCallback.HANDLE;

try {
// signature of 'void run()'
FunctionDescriptor callMe_run_desc = FunctionDescriptor.ofVoid(
// replicate signature of run()
);
MethodHandle callMe_run_handle = MethodHandles.lookup()
.findVirtual(Runnable.class,
"run",
callMe_run_desc.toMethodType()
);
callMe_run_desc.toMethodType());
callMe_run_handle = callMe_run_handle.bindTo(callMe); // set the first parameter to the Runnable as the "this" of the callback pretty much

try (Arena arena = Arena.ofConfined()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Swift.org project authors
//
// SPDX-License-Identifier: Apache-2.0
//
Expand Down
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,38 @@
.PHONY: run clean all

ARCH := $(shell arch)
UNAME := $(shell uname)

ifeq ($(UNAME), Linux)
ifeq ($(ARCH), 'i386')
ARCH_SUBDIR := x86_64
else
ARCH_SUBDIR := aarch64
endif
BUILD_DIR := .build/$(ARCH_SUBDIR)-unknown-linux-gnu
LIB_SUFFIX := so
endif

ifeq ($(UNAME), Darwin)
ifeq ($(ARCH), 'i386')
ARCH_SUBDIR := x86_64
else
ARCH_SUBDIR := arm64
endif
BUILD_DIR := .build/$(ARCH_SUBDIR)-apple-macosx
LIB_SUFFIX := dylib
endif

BUILD_DIR=".build/$(ARCH_SUBDIR)-apple-macosx"

all: generate-all

$(BUILD_DIR)/debug/libJavaKit.dylib $(BUILD_DIR)/debug/libJavaKitExample.dylib $(BUILD_DIR)/debug/Java2Swift:
$(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libJavaKitExample.$(LIB_SUFFIX) $(BUILD_DIR)/debug/Java2Swift:
swift build

./JavaSwiftKitDemo/build/classes/java/main/com/example/swift/HelloSubclass.class: JavaSwiftKitDemo/src/main/java/com/example/swift
./gradlew build

run: $(BUILD_DIR)/debug/libJavaKit.dylib $(BUILD_DIR)/debug/libJavaKitExample.dylib JavaSwiftKitDemo/src/main/java/com/example/swift
run: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX) $(BUILD_DIR)/debug/libJavaKitExample.$(LIB_SUFFIX) JavaSwiftKitDemo/src/main/java/com/example/swift
java -cp JavaSwiftKitDemo/build/classes/java/main -Djava.library.path=$(BUILD_DIR)/debug/ com.example.swift.HelloSwift

Java2Swift: $(BUILD_DIR)/debug/Java2Swift
Expand Down Expand Up @@ -82,7 +97,7 @@ endef
jextract-swift: generate-JExtract-interface-files
swift build

generate-JExtract-interface-files: $(BUILD_DIR)/debug/libJavaKit.dylib
generate-JExtract-interface-files: $(BUILD_DIR)/debug/libJavaKit.$(LIB_SUFFIX)
echo "Generate .swiftinterface files..."
@$(call make_swiftinterface, "JavaKitExample", "MySwiftLibrary")
@$(call make_swiftinterface, "JavaKitExample", "SwiftKit")
Expand All @@ -92,8 +107,8 @@ jextract-run: jextract-swift generate-JExtract-interface-files
--package-name com.example.swift.generated \
--swift-module JavaKitExample \
--output-directory JavaSwiftKitDemo/src/main/java \
.build/arm64-apple-macosx/jextract/JavaKitExample/MySwiftLibrary.swiftinterface \
.build/arm64-apple-macosx/jextract/JavaKitExample/SwiftKit.swiftinterface
$(BUILD_DIR)/jextract/JavaKitExample/MySwiftLibrary.swiftinterface \
$(BUILD_DIR)/jextract/JavaKitExample/SwiftKit.swiftinterface


jextract-run-java: jextract-swift generate-JExtract-interface-files
Expand Down
Loading
Loading