Skip to content

Commit

Permalink
Shifted all of the scoping to be less confusing
Browse files Browse the repository at this point in the history
  • Loading branch information
djspiewak committed Mar 27, 2020
1 parent 9b7f224 commit 366d7b9
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ This plugin is quite prescriptive in that it forcibly manages the contents of th

### Generative

Any and all settings which affect the behavior of the generative plugin should be set in the `ThisBuild` scope (for example, `ThisBuild / crossScalaVersions :=` rather than just `crossScalaVersions := `). This is important because GitHub Actions workflows are global across the entire build, regardless of how individual projects are configured. A corollary of this is that it is not possible (yet) to have specific subprojects which build with different Scala versions, Java versions, or OSes. This is theoretically possible but it's very complicated. For now, I'm going to be lazy and wait for someone to say "pretty please" before implementing it.

#### General

- `githubWorkflowGeneratedCI` : `Seq[WorkflowJob]` — Contains a description of the **ci.yml** jobs that will drive the generation if used. This setting can be overridden to customize the jobs (e.g. by adding additional jobs to the workflow).
Expand Down
10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@

name := "sbt-github-actions"

ThisBuild / baseVersion := "0.2"
ThisBuild / baseVersion := "0.3"

ThisBuild / organization := "com.codecommit"
ThisBuild / publishGithubUser := "djspiewak"
ThisBuild / publishFullName := "Daniel Spiewak"

Global / scalaVersion := "2.12.10"
ThisBuild / scalaVersion := "2.12.10"

Global / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest")
Global / githubWorkflowBuild := WorkflowStep.Sbt(List("test", "scripted"))
ThisBuild / githubWorkflowOSes := Seq("ubuntu-latest", "macos-latest", "windows-latest")
ThisBuild / githubWorkflowBuild := WorkflowStep.Sbt(List("test", "scripted"))

Global / githubWorkflowPublishTargetBranches := Seq()
ThisBuild / githubWorkflowPublishTargetBranches := Seq()

sbtPlugin := true
sbtVersion := "1.3.8"
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/sbtghactions/GenerativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,6 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}"""

private lazy val internalTargetAggregation = settingKey[Seq[File]]("Aggregates target directories from all subprojects")

override def projectSettings = Seq(Global / internalTargetAggregation += target.value)

private val windowsGuard = Some("contains(runner.os, 'windows')")

private val PlatformSep = FileSystems.getDefault.getSeparator
Expand All @@ -270,9 +268,9 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}"""
private def sanitizeTarget(str: String): String =
List('\\', '/', '"', ':', '<', '>', '|', '*', '?').foldLeft(str)(_.replace(_, '_'))

override def globalSettings = settingDefaults ++ Seq(
internalTargetAggregation := Seq(),
override def globalSettings = Seq(internalTargetAggregation := Seq())

override def buildSettings = settingDefaults ++ Seq(
githubWorkflowGeneratedUploadSteps := {
val mainSteps = pathStrs.value map { target =>
WorkflowStep.Use(
Expand Down Expand Up @@ -539,7 +537,9 @@ git config --global alias.rm-symlink '!git rm-symlinks' # for back-compat."""
workflowsDirTask.value / "clean.yml"
}

override def buildSettings = Seq(
override def projectSettings = Seq(
Global / internalTargetAggregation += target.value,

githubWorkflowGenerate / aggregate := false,
githubWorkflowCheck / aggregate := false,

Expand Down
7 changes: 4 additions & 3 deletions src/sbt-test/sbtghactions/check-and-regenerate/build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
organization := "com.codecommit"
version := "0.0.1"

Global / crossScalaVersions := Seq("2.13.1", "2.12.10")
Global / scalaVersion := crossScalaVersions.value.head
ThisBuild / crossScalaVersions := Seq("2.13.1", "2.12.10")
ThisBuild / scalaVersion := crossScalaVersions.value.head

Global / githubWorkflowPublishTargetBranches += RefPredicate.Equals(Ref.Tag("test"))
ThisBuild / githubWorkflowJavaVersions += "graalvm@20.0.0"
ThisBuild / githubWorkflowPublishTargetBranches += RefPredicate.Equals(Ref.Tag("test"))
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
matrix:
os: [ubuntu-latest]
scala: [2.13.1, 2.12.10]
java: [adopt@1.8]
java: [adopt@1.8, graalvm@20.0.0]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (fast)
Expand Down

0 comments on commit 366d7b9

Please sign in to comment.