From 3e3bc8d4b1014fd8b15610ed1bd3549bdee45a90 Mon Sep 17 00:00:00 2001 From: Jonathan Coates Date: Sat, 22 Oct 2022 21:21:33 +0100 Subject: [PATCH] Fix a whole bunch of GH action issues - Switch over to the Gradle GH action. Not expecting massive changes, but might provide some better caching. - Bump some GH action versions. - Fix a Java 8 compatability issue in our build scripts. --- .github/workflows/main-ci.yml | 17 ++++++++--------- .github/workflows/make-doc.yml | 18 +++++++----------- .../kotlin/cc/tweaked/gradle/ProcessHelpers.kt | 3 ++- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml index 1f6477d52..2e144e545 100644 --- a/.github/workflows/main-ci.yml +++ b/.github/workflows/main-ci.yml @@ -8,20 +8,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Clone repository + uses: actions/checkout@v3 - - name: Set up Java 8 - uses: actions/setup-java@v1 + - name: Set up Java + uses: actions/setup-java@v3 with: java-version: 8 + distribution: 'temurin' - - name: Cache Gradle dependencies - uses: actions/cache@v2 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- + cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/mc-') }} - name: Disable Gradle daemon run: | diff --git a/.github/workflows/make-doc.yml b/.github/workflows/make-doc.yml index cff59218f..958ed218d 100644 --- a/.github/workflows/make-doc.yml +++ b/.github/workflows/make-doc.yml @@ -11,23 +11,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - name: Clone repository + uses: actions/checkout@v3 - - name: Set up Java 8 + - name: Set up Java uses: actions/setup-java@v1 with: java-version: 8 + distribution: 'temurin' - - name: Cache gradle dependencies - uses: actions/cache@v2 + - name: Setup Gradle + uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('gradle.properties') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: Setup node - run: npm ci + cache-read-only: ${{ !startsWith(github.ref, 'refs/heads/mc-') }} - name: Build with Gradle run: ./gradlew compileJava --no-daemon || ./gradlew compileJava --no-daemon diff --git a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ProcessHelpers.kt b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ProcessHelpers.kt index 15643de3e..8ed4ee55b 100644 --- a/buildSrc/src/main/kotlin/cc/tweaked/gradle/ProcessHelpers.kt +++ b/buildSrc/src/main/kotlin/cc/tweaked/gradle/ProcessHelpers.kt @@ -4,6 +4,7 @@ import org.codehaus.groovy.runtime.ProcessGroovyMethods import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader +import java.util.stream.Collectors internal object ProcessHelpers { fun startProcess(vararg command: String): Process { @@ -25,7 +26,7 @@ internal object ProcessHelpers { fun captureLines(process: Process): List { val out = BufferedReader(InputStreamReader(process.inputStream)).use { reader -> - reader.lines().filter { it.isNotEmpty() }.toList() + reader.lines().filter { it.isNotEmpty() }.collect(Collectors.toList()) } ProcessGroovyMethods.closeStreams(process) if (process.waitFor() != 0) throw IOException("Command exited with a non-0 status")