Skip to content

Commit 095af21

Browse files
Merge branch 'main' into feature/grouping
2 parents f0158c6 + a80b77c commit 095af21

File tree

18 files changed

+334
-57
lines changed

18 files changed

+334
-57
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
strategy:
2424
matrix:
2525
os: [ubuntu-latest]
26-
scala: [2.12.16, 2.13.8]
26+
scala: [2.12.17, 2.13.10]
2727
java: [adopt-hotspot@8, adopt-hotspot@11]
2828
runs-on: ${{ matrix.os }}
2929
steps:
@@ -118,22 +118,22 @@ jobs:
118118
~/Library/Caches/Coursier/v1
119119
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}
120120

121-
- name: Download target directories (2.12.16)
121+
- name: Download target directories (2.12.17)
122122
uses: actions/download-artifact@v2
123123
with:
124-
name: target-${{ matrix.os }}-2.12.16-${{ matrix.java }}
124+
name: target-${{ matrix.os }}-2.12.17-${{ matrix.java }}
125125

126-
- name: Inflate target directories (2.12.16)
126+
- name: Inflate target directories (2.12.17)
127127
run: |
128128
tar xf targets.tar
129129
rm targets.tar
130130
131-
- name: Download target directories (2.13.8)
131+
- name: Download target directories (2.13.10)
132132
uses: actions/download-artifact@v2
133133
with:
134-
name: target-${{ matrix.os }}-2.13.8-${{ matrix.java }}
134+
name: target-${{ matrix.os }}-2.13.10-${{ matrix.java }}
135135

136-
- name: Inflate target directories (2.13.8)
136+
- name: Inflate target directories (2.13.10)
137137
run: |
138138
tar xf targets.tar
139139
rm targets.tar

.mergify.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ pull_request_rules:
1010
- name: merge scala-steward's PRs
1111
conditions:
1212
- author=scala-steward
13-
- status-success=Build and Test (ubuntu-latest, 2.12.16, adopt-hotspot@8)
14-
- status-success=Build and Test (ubuntu-latest, 2.12.16, adopt-hotspot@11)
15-
- status-success=Build and Test (ubuntu-latest, 2.13.8, adopt-hotspot@8)
16-
- status-success=Build and Test (ubuntu-latest, 2.13.8, adopt-hotspot@11)
13+
- status-success=Build and Test (ubuntu-latest, 2.12.17, adopt-hotspot@8)
14+
- status-success=Build and Test (ubuntu-latest, 2.12.17, adopt-hotspot@11)
15+
- status-success=Build and Test (ubuntu-latest, 2.13.10, adopt-hotspot@8)
16+
- status-success=Build and Test (ubuntu-latest, 2.13.10, adopt-hotspot@11)
1717
actions:
1818
merge:
1919
method: squash

.scala-steward.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
updatePullRequests = "always"
22

3+
updates.pin = [
4+
# We may drop this when we drop JDK 8 since minimum JDK is 11 from logback-classic 1.4.0
5+
{ groupId = "ch.qos.logback", artifactId="logback-classic", version="1.3." }
6+
]

build.sbt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ val moduleCrossPlatformMatrix: Map[String, List[Platform]] = Map(
2222
"mill-plugin" -> List(JVMPlatform)
2323
)
2424

25-
val Scala212 = "2.12.16"
26-
val Scala213 = "2.13.8"
25+
val Scala212 = "2.12.17"
26+
val Scala213 = "2.13.10"
2727

2828
/// sbt-github-actions configuration
2929

@@ -140,6 +140,11 @@ lazy val core = myCrossProject("core")
140140
// https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.12.6/jackson-core-2.12.6.jar:module-info.class
141141
// https/repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.12.6.1/jackson-databind-2.12.6.1.jar:module-info.class
142142
MergeStrategy.discard
143+
case PathList("META-INF", "sisu", "javax.inject.Named") =>
144+
// (core / assembly) deduplicate: different file contents found in the following:
145+
// https/repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/4.5.0/plexus-archiver-4.5.0.jar:META-INF/sisu/javax.inject.Named
146+
// https/repo1.maven.org/maven2/org/codehaus/plexus/plexus-io/3.4.0/plexus-io-3.4.0.jar:META-INF/sisu/javax.inject.Named
147+
MergeStrategy.first
143148
case otherwise =>
144149
val defaultStrategy = (assembly / assemblyMergeStrategy).value
145150
defaultStrategy(otherwise)

docs/help.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
All command line arguments for the `scala-steward` application.
44

55
```
6-
Usage: scala-steward --workspace <file> --repos-file <file> [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--vcs-type <vcs-type>] [--vcs-api-host <uri>] --vcs-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>] [--default-maven-repo <string>] [--refresh-backoff-period <duration>]
6+
Usage:
7+
scala-steward validate-repo-config
8+
scala-steward --workspace <file> --repos-file <file> [--git-author-name <string>] --git-author-email <string> [--git-author-signing-key <string>] --git-ask-pass <file> [--sign-commits] [--vcs-type <vcs-type>] [--vcs-api-host <uri>] --vcs-login <string> [--do-not-fork] [--add-labels] [--ignore-opts-files] [--env-var <name=value>]... [--process-timeout <duration>] [--whitelist <string>]... [--read-only <string>]... [--enable-sandbox | --disable-sandbox] [--max-buffer-size <integer>] [--repo-config <uri>]... [--disable-default-repo-config] [--scalafix-migrations <uri>]... [--disable-default-scalafix-migrations] [--artifact-migrations <uri>]... [--disable-default-artifact-migrations] [--cache-ttl <duration>] [--bitbucket-server-use-default-reviewers] [--gitlab-merge-when-pipeline-succeeds] [--github-app-id <integer> --github-app-key-file <file>] [--url-checker-test-url <uri>] [--default-maven-repo <string>] [--refresh-backoff-period <duration>]
79
810
911
@@ -78,4 +80,8 @@ Options and flags:
7880
default: https://repo1.maven.org/maven2/
7981
--refresh-backoff-period <duration>
8082
Period of time a failed build won't be triggered again; default: 0days
83+
84+
Subcommands:
85+
validate-repo-config
86+
Validate the repo config file and exit; report errors if any
8187
```

modules/core/src/main/resources/default.scala-steward.conf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ updates.ignore = [
2828
{ groupId = "org.scala-lang", artifactId = "scala3-library_sjs1", version = { exact = "3.2.1" } },
2929

3030
// Ignore the next Scala 2.13 version until it is announced.
31-
{ groupId = "org.scala-lang", artifactId = "scala-compiler", version = { exact = "2.13.10" } },
32-
{ groupId = "org.scala-lang", artifactId = "scala-library", version = { exact = "2.13.10" } },
33-
{ groupId = "org.scala-lang", artifactId = "scala-reflect", version = { exact = "2.13.10" } },
34-
{ groupId = "org.scala-lang", artifactId = "scalap", version = { exact = "2.13.10" } },
31+
{ groupId = "org.scala-lang", artifactId = "scala-compiler", version = { exact = "2.13.11" } },
32+
{ groupId = "org.scala-lang", artifactId = "scala-library", version = { exact = "2.13.11" } },
33+
{ groupId = "org.scala-lang", artifactId = "scala-reflect", version = { exact = "2.13.11" } },
34+
{ groupId = "org.scala-lang", artifactId = "scalap", version = { exact = "2.13.11" } },
3535

3636
// Ignore the next Scala 2.12 version until it is announced.
3737
{ groupId = "org.scala-lang", artifactId = "scala-compiler", version = { exact = "2.12.18" } },

modules/core/src/main/scala/org/scalasteward/core/Main.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import org.scalasteward.core.application.{Cli, Context}
2323
object Main extends IOApp {
2424
override def run(args: List[String]): IO[ExitCode] =
2525
Cli.parseArgs(args) match {
26-
case Cli.ParseResult.Success(config) => Context.step0[IO](config).use(_.stewardAlg.runF)
26+
case Cli.ParseResult.Success(config) => Context.step0[IO](config).use(_.runF)
2727
case Cli.ParseResult.Help(help) => Console[IO].println(help).as(ExitCode.Success)
2828
case Cli.ParseResult.Error(error) => Console[IO].errorln(error).as(ExitCode.Error)
2929
}

modules/core/src/main/scala/org/scalasteward/core/application/Cli.scala

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ object Cli {
257257
.withDefault(default)
258258
}
259259

260+
private val configFile: Opts[File] =
261+
Opts.argument[File]()
262+
263+
private val validateConfigFile: Opts[File] =
264+
Opts.subcommand(
265+
name = "validate-repo-config",
266+
help = "Validate the repo config file and exit; report errors if any"
267+
)(configFile)
268+
260269
private val configOpts: Opts[Config] = (
261270
workspace,
262271
reposFile,
@@ -276,12 +285,19 @@ object Cli {
276285
refreshBackoffPeriod
277286
).mapN(Config.apply)
278287

279-
val command: Command[Config] =
280-
Command("scala-steward", "")(configOpts)
288+
val command: Command[StewardUsage] =
289+
Command("scala-steward", "")(
290+
validateConfigFile
291+
.map(StewardUsage.ValidateRepoConfig(_))
292+
.orElse(
293+
configOpts
294+
.map(StewardUsage.Regular(_))
295+
)
296+
)
281297

282298
sealed trait ParseResult extends Product with Serializable
283299
object ParseResult {
284-
final case class Success(config: Config) extends ParseResult
300+
final case class Success(config: StewardUsage) extends ParseResult
285301
final case class Help(help: String) extends ParseResult
286302
final case class Error(error: String) extends ParseResult
287303
}

modules/core/src/main/scala/org/scalasteward/core/application/Config.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,10 @@ object Config {
135135
final case class GitLabCfg(
136136
mergeWhenPipelineSucceeds: Boolean
137137
)
138+
139+
sealed trait StewardUsage
140+
object StewardUsage {
141+
final case class Regular(config: Config) extends StewardUsage
142+
final case class ValidateRepoConfig(file: File) extends StewardUsage
143+
}
138144
}

modules/core/src/main/scala/org/scalasteward/core/application/Context.scala

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
package org.scalasteward.core.application
1818

19+
import better.files.File
1920
import cats.effect._
2021
import cats.effect.implicits._
22+
import cats.MonadThrow
2123
import cats.syntax.all._
2224
import eu.timepit.refined.auto._
2325
import org.http4s.Uri
@@ -48,6 +50,8 @@ import org.scalasteward.core.vcs.github.{GitHubAppApiAlg, GitHubAuthAlg}
4850
import org.scalasteward.core.vcs.{VCSApiAlg, VCSExtraAlg, VCSRepoAlg, VCSSelection}
4951
import org.typelevel.log4cats.Logger
5052
import org.typelevel.log4cats.slf4j.Slf4jLogger
53+
import org.scalasteward.core.application.Config.StewardUsage
54+
import org.scalasteward.core.repoconfig.ValidateRepoConfigAlg
5155

5256
final class Context[F[_]](implicit
5357
val buildToolDispatcher: BuildToolDispatcher[F],
@@ -77,10 +81,29 @@ final class Context[F[_]](implicit
7781
)
7882

7983
object Context {
80-
def step0[F[_]](config: Config)(implicit F: Async[F]): Resource[F, Context[F]] =
84+
85+
sealed trait StewardContext[F[_]] {
86+
def runF: F[ExitCode]
87+
}
88+
object StewardContext {
89+
final case class Regular[F[_]](context: Context[F]) extends StewardContext[F] {
90+
override def runF: F[ExitCode] = context.stewardAlg.runF
91+
}
92+
93+
final case class ValidateRepoConfig[F[_]](file: File)(implicit
94+
val validateRepoConfigAlg: ValidateRepoConfigAlg[F],
95+
val logger: Logger[F]
96+
) extends StewardContext[F] {
97+
override def runF: F[ExitCode] = validateRepoConfigAlg.validateAndReport(file)
98+
}
99+
}
100+
101+
def step0[F[_]](
102+
usage: Config.StewardUsage
103+
)(implicit F: Async[F]): Resource[F, StewardContext[F]] =
81104
for {
82-
logger <- Resource.eval(Slf4jLogger.fromName[F]("org.scalasteward.core"))
83-
_ <- Resource.eval(printBanner(logger))
105+
logger0 <- Resource.eval(Slf4jLogger.fromName[F]("org.scalasteward.core"))
106+
_ <- Resource.eval(printBanner(logger0))
84107
_ <- Resource.eval(F.delay(System.setProperty("http.agent", userAgentString)))
85108
userAgent <- Resource.eval(F.fromEither(`User-Agent`.parse(userAgentString)))
86109
middleware = ClientConfiguration
@@ -94,22 +117,46 @@ object Context {
94117
ClientConfiguration.disableFollowRedirect[F],
95118
middleware
96119
)
97-
fileAlg = FileAlg.create(logger, F)
98-
processAlg = ProcessAlg.create(config.processCfg)(logger, F)
99-
workspaceAlg = WorkspaceAlg.create(config)(fileAlg, logger, F)
100-
context <- Resource.eval(
101-
step1(config)(
102-
defaultClient,
103-
UrlCheckerClient(urlCheckerClient),
104-
fileAlg,
105-
logger,
106-
processAlg,
107-
workspaceAlg,
108-
F
109-
)
110-
)
120+
fileAlg0 = FileAlg.create(logger0, F)
121+
context <- usage match {
122+
case StewardUsage.Regular(config) =>
123+
initRegular(config)(
124+
defaultClient,
125+
UrlCheckerClient(urlCheckerClient),
126+
fileAlg0,
127+
logger0,
128+
F
129+
).map(StewardContext.Regular(_))
130+
131+
case StewardUsage.ValidateRepoConfig(file) =>
132+
implicit val fileAlg: FileAlg[F] = fileAlg0
133+
implicit val logger: Logger[F] = logger0
134+
Resource.pure[F, StewardContext[F]](initValidateRepoConfig(file))
135+
}
136+
111137
} yield context
112138

139+
def initRegular[F[_]](config: Config)(implicit
140+
client: Client[F],
141+
urlCheckerClient: UrlCheckerClient[F],
142+
fileAlg: FileAlg[F],
143+
logger: Logger[F],
144+
F: Async[F]
145+
): Resource[F, Context[F]] = {
146+
implicit val processAlg = ProcessAlg.create(config.processCfg)
147+
implicit val workspaceAlg = WorkspaceAlg.create(config)
148+
Resource.eval(step1(config))
149+
}
150+
151+
def initValidateRepoConfig[F[_]](file: File)(implicit
152+
fileAlg: FileAlg[F],
153+
logger: Logger[F],
154+
F: MonadThrow[F]
155+
): StewardContext.ValidateRepoConfig[F] = {
156+
implicit val validateRepoConfigAlg = new ValidateRepoConfigAlg[F]()
157+
StewardContext.ValidateRepoConfig[F](file)
158+
}
159+
113160
def step1[F[_]](config: Config)(implicit
114161
client: Client[F],
115162
urlCheckerClient: UrlCheckerClient[F],

0 commit comments

Comments
 (0)