Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 34 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Setup sbt
uses: sbt/setup-sbt@v1
Expand All @@ -100,7 +101,7 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
Expand All @@ -114,7 +115,7 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
Expand All @@ -128,7 +129,7 @@ jobs:
with:
distribution: temurin
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
Expand All @@ -142,7 +143,7 @@ jobs:
with:
version: 22.3.2
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graal_22.3.2@11' && steps.setup-graalvm-22_3_2-11.outputs.cache-hit == 'false'
Expand All @@ -156,7 +157,7 @@ jobs:
with:
distribution: graalvm
java-version: 21
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graalvm@21' && steps.setup-java-graalvm-21.outputs.cache-hit == 'false'
Expand All @@ -170,7 +171,7 @@ jobs:
with:
distribution: corretto
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false'
Expand All @@ -184,7 +185,7 @@ jobs:
with:
distribution: semeru
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'semeru@17' && steps.setup-java-semeru-17.outputs.cache-hit == 'false'
Expand Down Expand Up @@ -263,6 +264,7 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Setup sbt
uses: sbt/setup-sbt@v1
Expand All @@ -274,7 +276,7 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
Expand All @@ -287,7 +289,7 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
Expand All @@ -300,7 +302,7 @@ jobs:
with:
distribution: temurin
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
Expand All @@ -313,7 +315,7 @@ jobs:
with:
version: 22.3.2
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graal_22.3.2@11' && steps.setup-graalvm-22_3_2-11.outputs.cache-hit == 'false'
Expand All @@ -326,7 +328,7 @@ jobs:
with:
distribution: graalvm
java-version: 21
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graalvm@21' && steps.setup-java-graalvm-21.outputs.cache-hit == 'false'
Expand All @@ -339,7 +341,7 @@ jobs:
with:
distribution: corretto
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false'
Expand All @@ -352,7 +354,7 @@ jobs:
with:
distribution: semeru
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'semeru@17' && steps.setup-java-semeru-17.outputs.cache-hit == 'false'
Expand Down Expand Up @@ -409,6 +411,7 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Setup sbt
uses: sbt/setup-sbt@v1
Expand All @@ -420,7 +423,7 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
Expand All @@ -433,7 +436,7 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
Expand All @@ -446,7 +449,7 @@ jobs:
with:
distribution: temurin
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
Expand All @@ -459,7 +462,7 @@ jobs:
with:
version: 22.3.2
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graal_22.3.2@11' && steps.setup-graalvm-22_3_2-11.outputs.cache-hit == 'false'
Expand All @@ -472,7 +475,7 @@ jobs:
with:
distribution: graalvm
java-version: 21
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graalvm@21' && steps.setup-java-graalvm-21.outputs.cache-hit == 'false'
Expand All @@ -485,7 +488,7 @@ jobs:
with:
distribution: corretto
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false'
Expand All @@ -498,7 +501,7 @@ jobs:
with:
distribution: semeru
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'semeru@17' && steps.setup-java-semeru-17.outputs.cache-hit == 'false'
Expand All @@ -520,6 +523,8 @@ jobs:
steps:
- name: Checkout current branch (fast)
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Setup Java (temurin@17)
id: setup-java-temurin-17
Expand Down Expand Up @@ -551,6 +556,7 @@ jobs:
uses: actions/checkout@v6
with:
fetch-depth: 0
persist-credentials: false

- name: Setup sbt
uses: sbt/setup-sbt@v1
Expand All @@ -562,7 +568,7 @@ jobs:
with:
distribution: temurin
java-version: 8
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@8' && steps.setup-java-temurin-8.outputs.cache-hit == 'false'
Expand All @@ -575,7 +581,7 @@ jobs:
with:
distribution: temurin
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@11' && steps.setup-java-temurin-11.outputs.cache-hit == 'false'
Expand All @@ -588,7 +594,7 @@ jobs:
with:
distribution: temurin
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'temurin@17' && steps.setup-java-temurin-17.outputs.cache-hit == 'false'
Expand All @@ -601,7 +607,7 @@ jobs:
with:
version: 22.3.2
java-version: 11
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graal_22.3.2@11' && steps.setup-graalvm-22_3_2-11.outputs.cache-hit == 'false'
Expand All @@ -614,7 +620,7 @@ jobs:
with:
distribution: graalvm
java-version: 21
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'graalvm@21' && steps.setup-java-graalvm-21.outputs.cache-hit == 'false'
Expand All @@ -627,7 +633,7 @@ jobs:
with:
distribution: corretto
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'corretto@17' && steps.setup-java-corretto-17.outputs.cache-hit == 'false'
Expand All @@ -640,7 +646,7 @@ jobs:
with:
distribution: semeru
java-version: 17
cache: sbt
cache: ${{ !(startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') && 'sbt' || '' }}

- name: sbt update
if: matrix.java == 'semeru@17' && steps.setup-java-semeru-17.outputs.cache-hit == 'false'
Expand Down
6 changes: 6 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ ThisBuild / githubWorkflowBuildMatrixExclusions ++= {
ThisBuild / githubWorkflowPublishTimeoutMinutes := Some(45)
ThisBuild / githubWorkflowPublishNeeds += "validate-steward"

ThisBuild / githubWorkflowCheckoutPersistCredentials := false
ThisBuild / githubWorkflowCacheOn := {
val publishing = RunPredicate.Ref.anyOf(githubWorkflowPublishTargetBranches.value)
!publishing
}

ThisBuild / githubWorkflowBuild ++= Seq(
WorkflowStep.Run(
List("pwd"),
Expand Down
4 changes: 3 additions & 1 deletion ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ object TypelevelCiPlugin extends AutoPlugin {
WorkflowJob(
"validate-steward",
"Validate Steward Config",
WorkflowStep.Checkout ::
WorkflowStep.checkout(
full = false,
persistCredentials = githubWorkflowCheckoutPersistCredentials.value) ::
WorkflowStep.SetupJava(List(JavaSpec.temurin("17")), false) :::
WorkflowStep.Use(
UseRef.Public("coursier", "setup-action", "v1"),
Expand Down
2 changes: 2 additions & 0 deletions docs/gha.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Any and all settings which affect the behavior of the generative plugin should b
- `githubWorkflowPREventTypes` : `Seq[PREventType]` – A list of event types which will be used to determine which Pull Request events trigger the **ci.yml** workflow. This follows GitHub's defaults: `[opened, synchronize, reopened]`.
- `githubWorkflowArtifactUpload` : `Boolean` – Controls whether or not to upload target directories in the event that multiple jobs are running sequentially. Can be set on a per-project basis. Defaults to `true`.
- `githubWorkflowJobSetup` : `Seq[WorkflowStep]` – The automatically-generated checkout, setup, and cache steps which are common to all jobs which touch the build (default: autogenerated)
- `githubWorkflowCheckoutPersistCredentials` : `Boolean` – Controls whether the generated `actions/checkout` steps keep the `GITHUB_TOKEN` in the git config of the workspace, where any later step can read it and an artifact upload can publish it. Set this to `false` unless a later step pushes with that token. Defaults to `true`.
- `githubWorkflowCacheOn` : `RunPredicate` – The runs in which the generated `actions/setup-java` steps use the sbt dependency cache. A cache restored in a run that publishes can carry a poisoned entry into the published artifacts, so runs that publish should be left out. A predicate is `RunPredicate.Ref(refPredicate)`, `RunPredicate.Event(eventName)` or `RunPredicate.Custom(expression)`, and predicates combine with `&&`, `||` and `!`. For example `!RunPredicate.Ref(RefPredicate.StartsWith(Ref.Tag("v")))` keeps the cache out of tag builds, and `!RunPredicate.Ref.anyOf(githubWorkflowPublishTargetBranches.value)` keeps it out of every run that publishes. Defaults to `RunPredicate.Always`.
- `githubWorkflowEnv` : `Map[String, String]` – An environment which is global to the entire **ci.yml** workflow. Defaults to `Map("GITHUB_TOKEN" -> "${{ secrets.GITHUB_TOKEN }}")` since it's so commonly needed.
- `githubWorkflowAddedJobs` : `Seq[WorkflowJob]` – A convenience mechanism for adding extra custom jobs to the **ci.yml** workflow (though you can also do this by modifying `githubWorkflowGeneratedCI`). Defaults to empty.
- `githubWorkflowConcurrency` : `Option[Concurrency]` - Use concurrency to ensure that only a single workflow within the same concurrency group will run at a time. Defaults to `${{ github.workflow }} @ ${{ github.ref }}`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ trait GenerativeKeys {
"Additional matrix keys for which *all* artifacts should be downloaded and not just for the primary value (default: {})")
lazy val githubWorkflowJobSetup = settingKey[Seq[WorkflowStep]](
"The automatically-generated checkout, setup, and cache steps which are common to all jobs which touch the build (default: autogenerated)")
lazy val githubWorkflowCheckoutPersistCredentials = settingKey[Boolean](
"Whether the checkout step keeps the GITHUB_TOKEN in the git config of the workspace, where any later step can read it. Set to false unless a later step pushes with it (default: true)")
lazy val githubWorkflowCacheOn = settingKey[RunPredicate](
"The runs in which setup-java uses the sbt dependency cache. Runs that publish should not restore a cache, so that a poisoned entry cannot end up in the published artifacts, e.g. !RunPredicate.Ref.anyOf(githubWorkflowPublishTargetBranches.value) (default: RunPredicate.Always)")

lazy val githubWorkflowEnv = settingKey[Map[String, String]](
s"A map of static environment variable assignments global to the workflow (default: { GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }} })")
Expand Down
Loading
Loading