Skip to content

Commit

Permalink
ci: reorganize jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
ktoso committed Nov 12, 2024
1 parent 7e1f6b1 commit cbaad14
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 91 deletions.
41 changes: 41 additions & 0 deletions .github/prepare_env/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: 'Swift Java CI Env'
description: 'Prepare the CI environment by installing Swift and selected JDK etc.'

runs:
steps:
- name: Install System Dependencies
run: apt-get -qq update && apt-get -qq install -y make curl wget libjemalloc2 libjemalloc-dev
- name: Cache JDK
id: cache-jdk
uses: actions/cache@v4
continue-on-error: true
with:
path: /usr/lib/jvm/default-jdk/
key: ${{ runner.os }}-jdk-${{ matrix.jdk_vendor }}-${{ hashFiles('/usr/lib/jvm/default-jdk/*') }}
restore-keys: |
${{ runner.os }}-jdk-
- name: Install JDK
if: steps.cache-jdk.outputs.cache-hit != 'true'
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
# - name: Install Untested Nightly Swift
# run: "bash -xc './docker/install_untested_nightly_swift.sh'"
- name: Cache local Gradle repository
uses: actions/cache@v4
continue-on-error: true
with:
path: |
/root/.gradle/caches
/root/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('*/*.gradle*', 'settings.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache local SwiftPM repository
uses: actions/cache@v4
continue-on-error: true
with:
path: /__w/swift-java/swift-java/.build/checkouts
key: ${{ runner.os }}-swiftpm-cache-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-swiftpm-cache
${{ runner.os }}-swiftpm-
104 changes: 14 additions & 90 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,50 +29,15 @@ jobs:
JAVA_HOME: "/usr/lib/jvm/default-jdk"
steps:
- uses: actions/checkout@v4
- name: Install System Dependencies
run: apt-get -qq update && apt-get -qq install -y make curl wget libjemalloc2 libjemalloc-dev
- name: Cache JDK
id: cache-jdk
uses: actions/cache@v4
continue-on-error: true
with:
path: /usr/lib/jvm/default-jdk/
key: ${{ runner.os }}-jdk-${{ matrix.jdk_vendor }}-${{ hashFiles('/usr/lib/jvm/default-jdk/*') }}
restore-keys: |
${{ runner.os }}-jdk-
- name: Install JDK
if: steps.cache-jdk.outputs.cache-hit != 'true'
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
# - name: Install Untested Nightly Swift
# run: "bash -xc './docker/install_untested_nightly_swift.sh'"
- name: Cache local Gradle repository
uses: actions/cache@v4
continue-on-error: true
with:
path: |
/root/.gradle/caches
/root/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('*/*.gradle*', 'settings.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache local SwiftPM repository
uses: actions/cache@v4
continue-on-error: true
with:
path: /__w/swift-java/swift-java/.build/checkouts
key: ${{ runner.os }}-swiftpm-cache-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-swiftpm-cache
${{ runner.os }}-swiftpm-
- name: Prepare CI Environment
uses: /.github/actions/prepare_env
# run the actual build
- name: Gradle build
run: |
./gradlew build -x test --no-daemon # just build
./gradlew build --info --no-daemon
- name: Gradle build (benchmarks)
run: |
./gradlew compileJmh --info --no-daemon
run: ./gradlew build -x test # just build
- name: Gradle check
run: ./gradlew check --info
- name: Gradle compile benchmarks
run: ./gradlew compileJmh --info

test-swift:
name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }})
Expand All @@ -90,40 +55,11 @@ jobs:
JAVA_HOME: "/usr/lib/jvm/default-jdk"
steps:
- uses: actions/checkout@v4
- name: Install System Dependencies
run: apt-get -qq update && apt-get -qq install -y make curl wget libjemalloc2 libjemalloc-dev
- name: Cache JDK
id: cache-jdk
uses: actions/cache@v4
continue-on-error: true
with:
path: /usr/lib/jvm/default-jdk/
key: ${{ runner.os }}-jdk-${{ matrix.jdk_vendor }}-${{ hashFiles('/usr/lib/jvm/default-jdk/*') }}
restore-keys: |
${{ runner.os }}-jdk-
- name: Install JDK
if: steps.cache-jdk.outputs.cache-hit != 'true'
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
- name: Cache local Gradle repository
uses: actions/cache@v4
continue-on-error: true
with:
path: |
/root/.gradle/caches
/root/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('*/*.gradle*', 'settings.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Cache local SwiftPM repository
uses: actions/cache@v4
continue-on-error: true
with:
path: /__w/swift-java/swift-java/.build/checkouts
key: ${{ runner.os }}-swiftpm-cache-${{ hashFiles('Package.swift') }}
restore-keys: |
${{ runner.os }}-swiftpm-cache
${{ runner.os }}-swiftpm-
- name: Test Swift
- name: Prepare CI Environment
uses: /.github/actions/prepare_env
- name: Swift Build
run: "swift build --build-tests"
- name: Swift Test
run: "swift test"

verify-samples:
Expand All @@ -141,20 +77,8 @@ jobs:
JAVA_HOME: "/usr/lib/jvm/default-jdk"
steps:
- uses: actions/checkout@v4
- name: Install System Dependencies
run: apt-get -qq update && apt-get -qq install -y make curl wget libjemalloc2 libjemalloc-dev
- name: Cache JDK
id: cache-jdk
uses: actions/cache@v4
continue-on-error: true
with:
path: /usr/lib/jvm/default-jdk/
key: ${{ runner.os }}-jdk-${{ matrix.jdk_vendor }}-${{ hashFiles('/usr/lib/jvm/default-jdk/*') }}
restore-keys: |
${{ runner.os }}-jdk-
- name: Install JDK
if: steps.cache-jdk.outputs.cache-hit != 'true'
run: "bash -xc 'JDK_VENDOR=${{ matrix.jdk_vendor }} ./docker/install_jdk.sh'"
- name: Prepare CI Environment
uses: /.github/actions/prepare_env
- name: Verify Samples (All)
run: .github/scripts/validate_samples.sh
# TODO: Benchmark compile crashes in CI, enable when nightly toolchains in better shape.
Expand Down
2 changes: 1 addition & 1 deletion Sources/JExtractSwift/Swift2Java.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,6 @@ extension Logger.Level: ExpressibleByArgument {

func isDirectory(url: URL) -> Bool {
var isDirectory: ObjCBool = false
FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
_ = FileManager.default.fileExists(atPath: url.path, isDirectory: &isDirectory)
return isDirectory.boolValue
}

0 comments on commit cbaad14

Please sign in to comment.