Skip to content

Commit

Permalink
s/master/main/
Browse files Browse the repository at this point in the history
  • Loading branch information
djspiewak committed Jan 17, 2021
1 parent f096643 commit 6dba544
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The `GitHubActionsPlugin` provides general functionality, giving builds the abil

As mentioned above, the `GenerativePlugin` is designed to make it easier to maintain GitHub Actions builds for sbt projects by generating **ci.yml** and **clean.yml** workflow definition files, and then forcibly failing the build if these files ever fall out of step with the build itself. The **ci.yml** workflow, by default, contains both `build` and `publish` jobs, though you will likely need to add extra steps to the `githubWorkflowPublishPreamble` and/or `githubWorkflowEnv` (e.g. decrypting and importing a GPG signing key) in order for publication to *actually* work.

If a `publish` job is not desired, simply set `githubWorkflowPublishTargetBranches` to `Seq()`. By default, `publish` is restricted to run on `master`, and additional restrictions may be configured within the build.
If a `publish` job is not desired, simply set `githubWorkflowPublishTargetBranches` to `Seq()`. By default, `publish` is restricted to run on `main`, and additional restrictions may be configured within the build.

Ivy, sbt, and Coursier caching are all handled by the generated **ci.yml** by default, as well as standard things like Git checkout, Scala setup (using Olafur's [excellent `setup-scala` action](https://github.com/olafurpg/setup-scala)), and more. The matrix for the `build` job will be generated from `crossScalaVersions` and has additional support for multiple JVMs and OSes. Additionally, compiled artifacts are properly uploaded so that jobs which are dependent on `build` can avoid redundant work (most notably, `publish`). Thus, publication is guaranteed to be based on binary files that were generated *and* tested by the `build` job, rather than re-generated by `publish`. (**NB**: due to what appear to be issues in Zinc, this isn't *quite* working yet; expect it to be fixed in a coming release of sbt-github-actions)

Expand All @@ -46,7 +46,7 @@ ThisBuild / githubWorkflowPublishTargetBranches :=
ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release")))
```

This is assuming that you *only* wish to publish tags. If you also wish to publish snapshots upon successful master builds, use the following `githubWorkflowPublishTargetBranches` declaration:
This is assuming that you *only* wish to publish tags. If you also wish to publish snapshots upon successful main builds, use the following `githubWorkflowPublishTargetBranches` declaration:

```scala
ThisBuild / githubWorkflowPublishTargetBranches +=
Expand Down Expand Up @@ -123,5 +123,5 @@ Any and all settings which affect the behavior of the generative plugin should b
- `githubWorkflowPublishPreamble` : `Seq[WorkflowStep]` – Similar to `githubWorkflowBuildPreamble`, this contains a series of steps which will be inserted into the `publish` job *after* setup but *before* the publication step. Defaults to empty.
- `githubWorkflowPublishPostamble` : `Seq[WorkflowStep]` – Similar to the `Preamble` variant, this contains a series of steps which will be inserted into the `publish` job after publication has completed, but before cleanup. Defaults to empty.
- `githubWorkflowPublish` : `Seq[WorkflowStep]` – The steps which will be invoked to publish your project. This defaults to `[sbt +publish]`.
- `githubWorkflowPublishTargetBranches` : `Seq[RefPredicate]` – A list of branch predicates which will be applied to determine whether the `publish` job will run. Defaults to just `== master`. The supports all of the predicate types currently [allowed by GitHub Actions](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#functions). This exists because, while you usually want to run the `build` job on *every* branch, `publish` is obviously much more limited in applicability. If this list is empty, then the `publish` job will be omitted entirely from the workflow.
- `githubWorkflowPublishTargetBranches` : `Seq[RefPredicate]` – A list of branch predicates which will be applied to determine whether the `publish` job will run. Defaults to just `== main`. The supports all of the predicate types currently [allowed by GitHub Actions](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#functions). This exists because, while you usually want to run the `build` job on *every* branch, `publish` is obviously much more limited in applicability. If this list is empty, then the `publish` job will be omitted entirely from the workflow.
- `githubWorkflowPublishCond` : `Option[String]` – This is an optional added conditional check on the publish branch, which must be defined using [GitHub Actions expression syntax](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#about-contexts-and-expressions), which will be conjoined to determine the `if:` predicate on the `publish` job. Defaults to `None`.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted")

// dummy publication just to test that setup works
ThisBuild / githubWorkflowPublishTargetBranches :=
Seq(RefPredicate.Equals(Ref.Branch("master")))
Seq(RefPredicate.Equals(Ref.Branch("main")))

ThisBuild / githubWorkflowPublish := Seq()

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sbtghactions/GenerativeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait GenerativeKeys {
lazy val githubWorkflowPublishPreamble = settingKey[Seq[WorkflowStep]]("A list of steps to insert after base setup but before publishing (default: [])")
lazy val githubWorkflowPublishPostamble = settingKey[Seq[WorkflowStep]]("A list of steps to insert after publication but before the end of the publish job (default: [])")
lazy val githubWorkflowPublish = settingKey[Seq[WorkflowStep]]("A sequence workflow steps which publishe the project (default: [Sbt(List(\"+publish\"))])")
lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]]("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: [== master])")
lazy val githubWorkflowPublishTargetBranches = settingKey[Seq[RefPredicate]]("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])")
lazy val githubWorkflowPublishCond = settingKey[Option[String]]("A set of conditionals to apply to the publish job to further restrict its run (default: [])")

lazy val githubWorkflowJavaVersions = settingKey[Seq[String]]("A list of Java versions to be used for the build job. The publish job will use the *first* of these versions. (default: [[email protected]])")
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/sbtghactions/GenerativePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ ${indent(jobs.map(compileJob(_, sbt)).mkString("\n\n"), 1)}"""
githubWorkflowPublishPreamble := Seq(),
githubWorkflowPublishPostamble := Seq(),
githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("+publish"), name = Some("Publish project"))),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.Equals(Ref.Branch("master"))),
githubWorkflowPublishTargetBranches := Seq(RefPredicate.Equals(Ref.Branch("main"))),
githubWorkflowPublishCond := None,

githubWorkflowJavaVersions := Seq("[email protected]"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master' || github.ref == 'refs/tags/test')
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref == 'refs/tags/test')
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/master')
if: github.event_name != 'pull_request' && (github.ref == 'refs/heads/main')
strategy:
matrix:
os: [ubuntu-latest]
Expand Down
44 changes: 22 additions & 22 deletions src/test/scala/sbtghactions/GenerativePluginSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| push:
| branches: [master]
| branches: [main]
|
|jobs:
| """.stripMargin

compileWorkflow("test", List("master"), Nil, PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected
compileWorkflow("test", List("main"), Nil, PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected
}

"produce the appropriate skeleton around a zero-job workflow with non-empty tags" in {
Expand All @@ -52,15 +52,15 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| push:
| branches: [master]
| branches: [main]
| tags: [howdy]
|
|jobs:
| """.stripMargin

compileWorkflow("test", List("master"), List("howdy"), PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected
compileWorkflow("test", List("main"), List("howdy"), PREventType.Defaults, Map(), Nil, "sbt") mustEqual expected
}

"respect non-default pr types" in {
Expand All @@ -69,15 +69,15 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| types: [ready_for_review, review_requested, opened]
| push:
| branches: [master]
| branches: [main]
|
|jobs:
| """.stripMargin

compileWorkflow("test", List("master"), Nil, List(PREventType.ReadyForReview, PREventType.ReviewRequested, PREventType.Opened), Map(), Nil, "sbt") mustEqual expected
compileWorkflow("test", List("main"), Nil, List(PREventType.ReadyForReview, PREventType.ReviewRequested, PREventType.Opened), Map(), Nil, "sbt") mustEqual expected
}

"compile a one-job workflow targeting multiple branch patterns with an environment" in {
Expand All @@ -86,9 +86,9 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master, backport/v*]
| branches: [main, backport/v*]
| push:
| branches: [master, backport/v*]
| branches: [main, backport/v*]
|
|env:
| GITHUB_TOKEN: $${{ secrets.GITHUB_TOKEN }}
Expand All @@ -107,7 +107,7 @@ class GenerativePluginSpec extends Specification {

compileWorkflow(
"test2",
List("master", "backport/v*"),
List("main", "backport/v*"),
Nil,
PREventType.Defaults,
Map(
Expand All @@ -126,9 +126,9 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| push:
| branches: [master]
| branches: [main]
|
|jobs:
| build:
Expand All @@ -155,7 +155,7 @@ class GenerativePluginSpec extends Specification {

compileWorkflow(
"test3",
List("master"),
List("main"),
Nil,
PREventType.Defaults,
Map(),
Expand All @@ -178,9 +178,9 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| push:
| branches: [master]
| branches: [main]
|
|jobs:
| build:
Expand All @@ -197,7 +197,7 @@ class GenerativePluginSpec extends Specification {

compileWorkflow(
"test4",
List("master"),
List("main"),
Nil,
PREventType.Defaults,
Map(),
Expand All @@ -217,9 +217,9 @@ class GenerativePluginSpec extends Specification {
|
|on:
| pull_request:
| branches: [master]
| branches: [main]
| push:
| branches: [master]
| branches: [main]
|
|jobs:
| build:
Expand All @@ -246,7 +246,7 @@ class GenerativePluginSpec extends Specification {

compileWorkflow(
"test4",
List("master"),
List("main"),
Nil,
PREventType.Defaults,
Map(),
Expand Down Expand Up @@ -311,7 +311,7 @@ class GenerativePluginSpec extends Specification {
}

"drop Use version prefix on anything that doesn't start with a number" in {
compileStep(Use(UseRef.Public("hello", "world", "master")), "", true) mustEqual "- uses: hello/world@master"
compileStep(Use(UseRef.Public("hello", "world", "main")), "", true) mustEqual "- uses: hello/world@main"
}

"compile sbt using the command provided" in {
Expand Down

0 comments on commit 6dba544

Please sign in to comment.