From df97ab8935cb9abad767385188c502d26f3209d4 Mon Sep 17 00:00:00 2001 From: Arman Bilge Date: Sat, 12 Oct 2024 22:26:48 +0000 Subject: [PATCH] Expose `SetupSbt` step --- .github/workflows/ci.yml | 24 +++++++++---------- .../typelevel/sbt/gha/GenerativePlugin.scala | 10 ++------ .../org/typelevel/sbt/gha/WorkflowStep.scala | 5 ++++ 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c0f2974..c5555d2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,9 +80,6 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 60 steps: - - name: Install sbt - uses: sbt/setup-sbt@v1 - - name: Ignore line ending differences in git if: contains(runner.os, 'windows') shell: bash @@ -93,6 +90,9 @@ jobs: with: fetch-depth: 0 + - name: Setup sbt + uses: sbt/setup-sbt@v1 + - name: Setup Java (temurin@8) id: setup-java-temurin-8 if: matrix.java == 'temurin@8' @@ -251,9 +251,6 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 45 steps: - - name: Install sbt - uses: sbt/setup-sbt@v1 - - name: Ignore line ending differences in git if: contains(runner.os, 'windows') run: git config --global core.autocrlf false @@ -263,6 +260,9 @@ jobs: with: fetch-depth: 0 + - name: Setup sbt + uses: sbt/setup-sbt@v1 + - name: Setup Java (temurin@8) id: setup-java-temurin-8 if: matrix.java == 'temurin@8' @@ -397,9 +397,6 @@ jobs: java: [temurin@8] runs-on: ${{ matrix.os }} steps: - - name: Install sbt - uses: sbt/setup-sbt@v1 - - name: Ignore line ending differences in git if: contains(runner.os, 'windows') run: git config --global core.autocrlf false @@ -409,6 +406,9 @@ jobs: with: fetch-depth: 0 + - name: Setup sbt + uses: sbt/setup-sbt@v1 + - name: Setup Java (temurin@8) id: setup-java-temurin-8 if: matrix.java == 'temurin@8' @@ -539,9 +539,6 @@ jobs: java: [temurin@11] runs-on: ${{ matrix.os }} steps: - - name: Install sbt - uses: sbt/setup-sbt@v1 - - name: Ignore line ending differences in git if: contains(runner.os, 'windows') run: git config --global core.autocrlf false @@ -551,6 +548,9 @@ jobs: with: fetch-depth: 0 + - name: Setup sbt + uses: sbt/setup-sbt@v1 + - name: Setup Java (temurin@8) id: setup-java-temurin-8 if: matrix.java == 'temurin@8' diff --git a/github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala b/github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala index 594970e8..183be7ce 100644 --- a/github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala +++ b/github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativePlugin.scala @@ -781,12 +781,6 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)} }, githubWorkflowGeneratedCacheSteps := Seq(), githubWorkflowJobSetup := { - val installSbt = List( - WorkflowStep.Use( - UseRef.Public("sbt", "setup-sbt", "v1"), - name = Some("Install sbt") - ) - ) val autoCrlfOpt = if (githubWorkflowOSes.value.exists(_.contains("windows"))) { List( @@ -798,9 +792,9 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)} Nil } - installSbt ::: - autoCrlfOpt ::: + autoCrlfOpt ::: List(WorkflowStep.CheckoutFull) ::: + WorkflowStep.SetupSbt :: WorkflowStep.SetupJava(githubWorkflowJavaVersions.value.toList) ::: githubWorkflowGeneratedCacheSteps.value.toList }, diff --git a/github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowStep.scala b/github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowStep.scala index 76594585..19d549d2 100644 --- a/github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowStep.scala +++ b/github-actions/src/main/scala/org/typelevel/sbt/gha/WorkflowStep.scala @@ -44,6 +44,11 @@ object WorkflowStep { UseRef.Public("actions", "checkout", "v4"), name = Some("Checkout current branch (fast)")) + val SetupSbt: WorkflowStep = WorkflowStep.Use( + UseRef.Public("sbt", "setup-sbt", "v1"), + name = Some("Setup sbt") + ) + def SetupJava(versions: List[JavaSpec], enableCaching: Boolean = true): List[WorkflowStep] = { def sbtUpdateStep(cond: String, setupId: String) = if (enableCaching)