Skip to content

Commit 546d028

Browse files
committed
Create a Workflow type to capture an entire workflow file.
Split out re-usable workflows for regular workflows Add needs Bin friendlier Triggers, added Workflow Call Add permissions and concurrency. Refactor needs Cleanup render of types and steps Cleaned up redundant empty string checks, added prefix, suffix to some compile matrix Add more trigger types
1 parent 41a7c9d commit 546d028

File tree

13 files changed

+1140
-438
lines changed

13 files changed

+1140
-438
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
name: Continuous Integration
99

10-
on:
10+
on:
1111
pull_request:
1212
branches: ['**', '!update/**', '!pr/**']
1313
push:
@@ -31,7 +31,6 @@ permissions:
3131
env:
3232
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3333

34-
3534
concurrency:
3635
group: ${{ github.workflow }} @ ${{ github.ref }}
3736
cancel-in-progress: true

.github/workflows/clean.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77

88
name: Clean
99

10-
on: push
10+
on:
11+
push:
1112

1213
jobs:
1314
delete-artifacts:
1415
name: Delete Artifacts
15-
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
os: [ubuntu-22.04]
19+
runs-on: ${{ matrix.os }}
1620
env:
1721
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1822
steps:

ci/src/main/scala/org/typelevel/sbt/TypelevelCiPlugin.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ object TypelevelCiPlugin extends AutoPlugin {
150150
val dependencySubmission =
151151
if (tlCiDependencyGraphJob.value)
152152
List(
153-
WorkflowJob(
153+
WorkflowJob.Run(
154154
"dependency-submission",
155155
"Submit Dependencies",
156156
scalas = Nil,
@@ -173,7 +173,7 @@ object TypelevelCiPlugin extends AutoPlugin {
173173
Some(file(".scala-steward.conf")).filter(_.exists()),
174174
githubWorkflowAddedJobs ++= {
175175
tlCiStewardValidateConfig.value.toList.map { config =>
176-
WorkflowJob(
176+
WorkflowJob.Run(
177177
"validate-steward",
178178
"Validate Steward Config",
179179
WorkflowStep.Checkout ::

github-actions/src/main/resources/clean.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

github-actions/src/main/scala/org/typelevel/sbt/gha/Concurrency.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,24 @@ package org.typelevel.sbt.gha
1818

1919
sealed abstract class Concurrency {
2020
def group: String
21-
def cancelInProgress: Option[Boolean]
21+
def cancelInProgress: Option[String]
2222
}
2323

2424
object Concurrency {
25+
def apply(group: String): Concurrency =
26+
Impl(group, None)
2527

26-
def apply(group: String, cancelInProgress: Option[Boolean] = None): Concurrency =
28+
def apply(group: String, cancelInProgress: Boolean): Concurrency =
29+
apply(group, Some(cancelInProgress))
30+
31+
def apply(group: String, cancelInProgress: Option[Boolean]): Concurrency =
32+
Impl(group, cancelInProgress.map(_.toString))
33+
34+
def apply(group: String, cancelInProgress: Option[String])(
35+
implicit dummy: DummyImplicit): Concurrency =
2736
Impl(group, cancelInProgress)
2837

29-
private final case class Impl(group: String, cancelInProgress: Option[Boolean])
38+
private final case class Impl(group: String, cancelInProgress: Option[String])
3039
extends Concurrency {
3140
override def productPrefix = "Concurrency"
3241
}

github-actions/src/main/scala/org/typelevel/sbt/gha/GenerativeKeys.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ trait GenerativeKeys {
2525
lazy val githubWorkflowCheck = taskKey[Unit](
2626
"Checks to see if the ci.yml and clean.yml files are equivalent to what would be generated and errors if otherwise")
2727

28+
lazy val githubWorkflows = settingKey[Map[String, Workflow]](
29+
"The map of jobs which will make up the generated workflows, with the keys being the workflow file path.")
30+
lazy val githubWorkflowCI =
31+
settingKey[Workflow]("The Workflow which will make up the generated ci workflow (ci.yml)")
2832
lazy val githubWorkflowGeneratedCI = settingKey[Seq[WorkflowJob]](
2933
"The sequence of jobs which will make up the generated ci workflow (ci.yml)")
3034
lazy val githubWorkflowGeneratedUploadSteps = settingKey[Seq[WorkflowStep]](
@@ -65,13 +69,17 @@ trait GenerativeKeys {
6569
s"Commands automatically prepended to a WorkflowStep.Sbt (default: ['++ $${{ matrix.scala }}'])")
6670
lazy val githubWorkflowBuild = settingKey[Seq[WorkflowStep]](
6771
"A sequence of workflow steps which compile and test the project (default: [Sbt(List(\"test\"))])")
72+
lazy val githubWorkflowBuildJob =
73+
settingKey[WorkflowJob]("A workflow job for compiling and testing the project")
6874

6975
lazy val githubWorkflowPublishPreamble = settingKey[Seq[WorkflowStep]](
7076
"A list of steps to insert after base setup but before publishing (default: [])")
7177
lazy val githubWorkflowPublishPostamble = settingKey[Seq[WorkflowStep]](
7278
"A list of steps to insert after publication but before the end of the publish job (default: [])")
7379
lazy val githubWorkflowPublish = settingKey[Seq[WorkflowStep]](
7480
"A sequence workflow steps which publishes the project (default: [Sbt(List(\"+publish\"))])")
81+
lazy val githubWorkflowPublishJob =
82+
settingKey[WorkflowJob]("A workflow job which publishes the project.")
7583
lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]](
7684
"A set of branch predicates which will be applied to determine whether the current branch gets a publication stage; if empty, publish will be skipped entirely (default: [== main])")
7785
lazy val githubWorkflowPublishCond = settingKey[Option[String]](

0 commit comments

Comments
 (0)