workflow experiment with building just once #162
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| build: | |
| name: Build (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 System Dependencies | |
| run: apt-get -qq update && apt-get -qq install -y make curl wget | |
| - 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: Gradle build | |
| run: | | |
| ./gradlew build -x test --no-daemon # skip tests | |
| test-java: | |
| name: Java tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }}) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| 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: 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- | |
| # run the actual build | |
| - name: Gradle test | |
| run: | | |
| ./gradlew build --info --no-daemon | |
| test-swift: | |
| name: Swift tests (swift:${{ matrix.swift_version }} jdk:${{matrix.jdk_vendor}} os:${{ matrix.os_version }}) | |
| runs-on: ubuntu-latest | |
| needs: build | |
| 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: 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- | |
| # run the actual build | |
| - name: Test Swift | |
| run: "swift test" | |
| - name: Build (Swift) Sample Apps | |
| run: | | |
| find Samples/ -name Package.swift -maxdepth 2 -exec swift build --package-path $(dirname {}) \;; |