Skip to content

Commit cd3b748

Browse files
authored
Merge branch 'scalacenter:main' into main
2 parents 2d0d114 + 705b122 commit cd3b748

File tree

20 files changed

+62
-38
lines changed

20 files changed

+62
-38
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ A list of space-separated names of configurations to ignore. The action will not
5151

5252
Example of configurations are `compile`, `test`, `scala-tool`, `scala-doc-tool`.
5353

54+
### - `correlator` (optional)
55+
56+
An optional identifier to distinguish between multiple dependency snapshots of the same type.
57+
Defaults to the concatenation of the workflow name, the job id and the action id.
58+
59+
Typically you would specify the correlator in a matrix-based job like this:
60+
61+
```yaml
62+
correlator: ${{ github.job }}-${{ matrix.directory }}
63+
```
64+
5465
#### - `token` (optional)
5566

5667
GitHub Personal Access Token (PAT). Defaults to PAT provided by Action runner.
@@ -115,7 +126,7 @@ To do so you need to install the `sbt-dependency-submission` plugin in your sbt
115126

116127
```scala
117128
// In project/plugins.sbt
118-
addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-submission" % "3.0.0")
129+
addSbtPlugin("ch.epfl.scala" % "sbt-github-dependency-submission" % "3.1.0")
119130
```
120131

121132
After reloading your build, you can run:

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ inputs:
2222
Example: `test scala-doc-tool`
2323
required: false
2424
default: ''
25+
correlator:
26+
description: |
27+
An optional identifier to distinguish between multiple dependency snapshots of the same type.
28+
Defaults to the concatenation of the workflow name, the job id and the action id.
29+
required: false
30+
default: ''
2531
on-resolve-failure:
2632
description: |
2733
Either 'error' or 'warning'.
@@ -36,7 +42,7 @@ inputs:
3642
sbt-plugin-version:
3743
description: Version of the sbt plugin to use.
3844
required: false
39-
default: '3.0.1'
45+
default: '3.1.0'
4046
outputs:
4147
submission-id:
4248
description: The ID of the submission created by the action

dist/index.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sbt-dependency-submission",
3-
"version": "3.0.1",
3+
"version": "3.1.0",
44
"private": true,
55
"description": "Submit the dependency graph of an sbt build to Github",
66
"main": "lib/main.js",

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.10.0
1+
sbt.version=1.10.3

sbt-plugin/.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "3.8.1"
1+
version = "3.8.3"
22
runner.dialect = scala212source3
33
maxColumn = 120
44
align.preset = some

sbt-plugin/build.sbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ val `sbt-github-dependency-submission` = project
2727
.settings(
2828
name := "sbt-github-dependency-submission",
2929
sbtVersion := "1.5.8",
30-
scalaVersion := "2.12.19",
30+
scalaVersion := "2.12.20",
3131
scalacOptions ++= Seq(
3232
"-deprecation",
3333
"-encoding",
@@ -39,7 +39,7 @@ val `sbt-github-dependency-submission` = project
3939
),
4040
libraryDependencies ++= Seq(
4141
"com.eed3si9n" %% "gigahorse-asynchttpclient" % "0.7.0",
42-
"org.scalameta" %% "munit" % "1.0.0" % Test
42+
"org.scalameta" %% "munit" % "1.0.2" % Test
4343
),
4444
buildInfoKeys := Seq[BuildInfoKey](name, version, homepage),
4545
buildInfoPackage := "ch.epfl.scala",

sbt-plugin/project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.10.0
1+
sbt.version=1.10.3

sbt-plugin/project/plugins.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
2-
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.5.3")
3-
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.12.1")
1+
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.9.0")
2+
addSbtPlugin("org.scala-sbt" % "sbt-contraband" % "0.6.0")
3+
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.13.0")
44
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")

sbt-plugin/src/main/contraband/input.contra

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ type DependencySnapshotInput {
2323
## - "scala-doc-tool" to ignore the scaladoc dependencies
2424
## - "scala-tool" to ignore the compiler dependencies
2525
ignoredConfigs: [String]
26+
27+
## The job correlator of the snapshot
28+
correlator: String
2629
}

sbt-plugin/src/main/scala/ch/epfl/scala/SubmitDependencyGraph.scala

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ object SubmitDependencyGraph {
4242
private def inputParser(state: State): Parser[DependencySnapshotInput] =
4343
Parsers.any.*.map { raw =>
4444
val rawString = raw.mkString
45-
if (rawString.isEmpty) DependencySnapshotInput(None, Vector.empty, Vector.empty)
45+
if (rawString.isEmpty) DependencySnapshotInput(None, Vector.empty, Vector.empty, Some(""))
4646
else
4747
JsonParser
4848
.parseFromString(rawString)
@@ -82,7 +82,8 @@ object SubmitDependencyGraph {
8282
}
8383

8484
private def generateInternal(state: State): State = {
85-
val snapshot = githubDependencySnapshot(state)
85+
val input = state.attributes(githubSnapshotInputKey)
86+
val snapshot = githubDependencySnapshot(state, input.correlator.getOrElse(""))
8687
val snapshotJson = CompactPrinter(Converter.toJsonUnsafe(snapshot))
8788
val snapshotJsonFile = IO.withTemporaryFile("dependency-snapshot-", ".json", keepFile = true) { file =>
8889
IO.write(file, snapshotJson)
@@ -103,7 +104,8 @@ object SubmitDependencyGraph {
103104
)
104105
)
105106
val snapshotUrl = s"${githubApiUrl()}/repos/${githubRepository()}/dependency-graph/snapshots"
106-
val job = githubJob()
107+
val input = state.attributes(githubSnapshotInputKey)
108+
val job = githubJob(input.correlator.getOrElse(""))
107109
val request = Gigahorse
108110
.url(snapshotUrl)
109111
.post(snapshotJsonFile)
@@ -145,7 +147,7 @@ object SubmitDependencyGraph {
145147
throw new MessageOnlyException(message)
146148
}
147149

148-
private def githubDependencySnapshot(state: State): DependencySnapshot = {
150+
private def githubDependencySnapshot(state: State, correlator: String): DependencySnapshot = {
149151
val detector = DetectorMetadata(
150152
SbtGithubDependencySubmission.name,
151153
SbtGithubDependencySubmission.homepage.map(_.toString).getOrElse(""),
@@ -155,7 +157,7 @@ object SubmitDependencyGraph {
155157
val manifests = state.get(githubManifestsKey).get
156158
DependencySnapshot(
157159
0,
158-
githubJob(),
160+
githubJob(correlator),
159161
githubSha(),
160162
githubRef(),
161163
detector,
@@ -165,8 +167,7 @@ object SubmitDependencyGraph {
165167
)
166168
}
167169

168-
private def githubJob(): Job = {
169-
val correlator = s"${githubWorkflow()}_${githubJobName()}_${githubAction()}"
170+
private def githubJob(correlator: String): Job = {
170171
val id = githubRunId
171172
val html_url =
172173
for {
@@ -181,9 +182,6 @@ object SubmitDependencyGraph {
181182
throw new MessageOnlyException(s"Missing environment variable $name. This task must run in a Github Action.")
182183
}
183184
check("GITHUB_WORKSPACE")
184-
check("GITHUB_WORKFLOW")
185-
check("GITHUB_JOB")
186-
check("GITHUB_ACTION")
187185
check("GITHUB_RUN_ID")
188186
check("GITHUB_SHA")
189187
check("GITHUB_REF")
@@ -194,9 +192,6 @@ object SubmitDependencyGraph {
194192
}
195193

196194
private def githubWorkspace(): String = Properties.envOrElse("GITHUB_WORKSPACE", "")
197-
private def githubWorkflow(): String = Properties.envOrElse("GITHUB_WORKFLOW", "")
198-
private def githubJobName(): String = Properties.envOrElse("GITHUB_JOB", "")
199-
private def githubAction(): String = Properties.envOrElse("GITHUB_ACTION", "")
200195
private def githubRunId(): String = Properties.envOrElse("GITHUB_RUN_ID", "")
201196
private def githubSha(): String = Properties.envOrElse("GITHUB_SHA", "")
202197
private def githubRef(): String = Properties.envOrElse("GITHUB_REF", "")

sbt-plugin/src/sbt-test/dependency-manifest/coursier-manifest/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inThisBuild(
1010
organization := "ch.epfl.scala",
1111
version := "1.2.0-SNAPSHOT",
1212
useCoursier := true,
13-
scalaVersion := "2.12.19"
13+
scalaVersion := "2.12.20"
1414
)
1515
)
1616

sbt-plugin/src/sbt-test/dependency-manifest/ignore-scaladoc/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ inThisBuild(
1717
)
1818

1919
Global / ignoreScaladoc := {
20-
val input = DependencySnapshotInput(None, Vector.empty, ignoredConfigs = Vector("scala-doc-tool"))
20+
val input = DependencySnapshotInput(None, Vector.empty, ignoredConfigs = Vector("scala-doc-tool"), correlator = None)
2121
StateTransform(state => state.put(githubSnapshotInputKey, input))
2222
}
2323

sbt-plugin/src/sbt-test/dependency-manifest/ignore-test/build.sbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ inThisBuild(
1717
)
1818

1919
Global / ignoreTestConfig := {
20-
val input = DependencySnapshotInput(None, Vector.empty, ignoredConfigs = Vector("test"))
20+
val input = DependencySnapshotInput(None, Vector.empty, ignoredConfigs = Vector("test"), correlator = None)
2121
StateTransform(state => state.put(githubSnapshotInputKey, input))
2222
}
2323

2424
lazy val p1 = project
2525
.in(file("p1"))
2626
.settings(
27-
libraryDependencies += "org.scalameta" %% "munit" % "1.0.0" % Test,
27+
libraryDependencies += "org.scalameta" %% "munit" % "1.0.2" % Test,
2828
checkTest := {
2929
val manifest = githubDependencyManifest.value.get
30-
checkDependency(manifest, "org.scalameta:munit_3:1.0.0")(
30+
checkDependency(manifest, "org.scalameta:munit_3:1.0.2")(
3131
expectedRelationship = DependencyRelationship.direct,
3232
expectedScope = DependencyScope.development,
3333
expectedConfig = "test"

sbt-plugin/src/sbt-test/dependency-manifest/ivy-manifest/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ inThisBuild(
1010
organization := "ch.epfl.scala",
1111
version := "1.2.0-SNAPSHOT",
1212
useCoursier := false, // use Ivy
13-
scalaVersion := "2.12.19"
13+
scalaVersion := "2.12.20"
1414
)
1515
)
1616

sbt-plugin/src/sbt-test/dependency-manifest/package-urls/build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ inThisBuild(
1111
version := "1.2.0-SNAPSHOT",
1212
// use Ivy because Coursier does not allow several classifier on the same dep
1313
useCoursier := false,
14-
scalaVersion := "2.12.19"
14+
scalaVersion := "2.12.20"
1515
)
1616
)
1717

sbt-plugin/src/test/scala/ch/epfl/scala/JsonProtocolTests.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ class JsonProtocolTests extends FunSuite {
3030
import ch.epfl.scala.JsonProtocol._
3131
val raw = Parser.parseUnsafe("{}")
3232
val obtained = Converter.fromJson[DependencySnapshotInput](raw).get
33-
val expected = DependencySnapshotInput(None, Vector.empty, Vector.empty)
33+
val expected = DependencySnapshotInput(None, Vector.empty, Vector.empty, None)
3434
assertEquals(obtained, expected)
3535
}
3636

3737
test("decode input with onResolveFailure: warning") {
3838
import ch.epfl.scala.JsonProtocol._
3939
val raw = Parser.parseUnsafe("""{"onResolveFailure": "warning"}""")
4040
val obtained = Converter.fromJson[DependencySnapshotInput](raw).get
41-
val expected = DependencySnapshotInput(Some(OnFailure.warning), Vector.empty, Vector.empty)
41+
val expected = DependencySnapshotInput(Some(OnFailure.warning), Vector.empty, Vector.empty, None)
4242
assertEquals(obtained, expected)
4343
}
4444
}

src/main.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,12 @@ async function run(): Promise<void> {
4848
return
4949
}
5050

51-
const input = { ignoredModules, ignoredConfigs, onResolveFailure }
51+
const correlatorInput = core.getInput('correlator')
52+
const correlator = correlatorInput
53+
? correlatorInput
54+
: `${github.context.workflow}_${github.context.job}_${github.context.action}`
55+
56+
const input = { ignoredModules, ignoredConfigs, onResolveFailure, correlator }
5257

5358
if (github.context.eventName === 'pull_request') {
5459
core.info('pull request, resetting sha')

0 commit comments

Comments
 (0)