11package ch .epfl .scala
22
33import java .nio .charset .StandardCharsets
4- import java .nio .file .Path
54import java .nio .file .Paths
65import java .time .Instant
76
@@ -10,7 +9,6 @@ import scala.concurrent.duration.Duration
109import scala .util .Properties
1110import scala .util .Try
1211
13- import ch .epfl .scala .GithubDependencyGraphPlugin .autoImport
1412import ch .epfl .scala .GithubDependencyGraphPlugin .autoImport ._
1513import ch .epfl .scala .JsonProtocol ._
1614import ch .epfl .scala .githubapi .JsonProtocol ._
@@ -59,9 +57,16 @@ object SubmitDependencyGraph {
5957 .flatMap(projectRef => state.setting(projectRef / Keys .crossScalaVersions))
6058 .distinct
6159
60+ val root = Paths .get(loadedBuild.root).toAbsolutePath
61+ val workspace = Paths .get(githubWorkspace()).toAbsolutePath
62+ val buildFile =
63+ if (root.startsWith(workspace)) workspace.relativize(root).resolve(" build.sbt" )
64+ else root.resolve(" build.sbt" )
65+ state.log.info(s " Resolving snapshot of $buildFile" )
66+
6267 val initState = state
6368 .put(githubSubmitInputKey, input)
64- .put(autoImport.githubWorkspace, githubWorkspace( ))
69+ .put(githubBuildFile, githubapi. FileInfo (buildFile.toString ))
6570 .put(githubManifestsKey, Map .empty[String , Manifest ])
6671 .put(githubProjectsKey, projectRefs)
6772
@@ -85,7 +90,7 @@ object SubmitDependencyGraph {
8590 " Authorization" -> s " token ${githubToken()}"
8691 )
8792
88- state.log.info(s " Submiting dependency snapshot to $snapshotUrl" )
93+ state.log.info(s " Submiting dependency snapshot of job ${snapshot.job} to $snapshotUrl" )
8994 val result = for {
9095 httpResp <- Try (Await .result(http.processFull(request), Duration .Inf ))
9196 snapshot <- getSnapshot(httpResp)
@@ -130,11 +135,11 @@ object SubmitDependencyGraph {
130135 }
131136
132137 private def githubJob (): Job = {
133- val correlator = s " ${githubJobName()}_ ${githubWorkflow ()}"
138+ val correlator = s " ${githubWorkflow()} _ ${ githubJobName()}_ ${githubAction ()}"
134139 val id = githubRunId
135140 val html_url =
136141 for {
137- serverUrl <- Properties .envOrNone(" $ GITHUB_SERVER_URL" )
142+ serverUrl <- Properties .envOrNone(" GITHUB_SERVER_URL" )
138143 repository <- Properties .envOrNone(" GITHUB_REPOSITORY" )
139144 } yield s " $serverUrl/ $repository/actions/runs/ $id"
140145 Job (correlator, id, html_url)
@@ -144,6 +149,7 @@ object SubmitDependencyGraph {
144149 githubWorkspace()
145150 githubWorkflow()
146151 githubJobName()
152+ githubAction()
147153 githubRunId()
148154 githubSha()
149155 githubRef()
@@ -152,9 +158,10 @@ object SubmitDependencyGraph {
152158 githubToken()
153159 }
154160
155- private def githubWorkspace (): Path = Paths .get( githubCIEnv(" GITHUB_WORKSPACE" )).toAbsolutePath
161+ private def githubWorkspace (): String = githubCIEnv(" GITHUB_WORKSPACE" )
156162 private def githubWorkflow (): String = githubCIEnv(" GITHUB_WORKFLOW" )
157163 private def githubJobName (): String = githubCIEnv(" GITHUB_JOB" )
164+ private def githubAction (): String = githubCIEnv(" GITHUB_ACTION" )
158165 private def githubRunId (): String = githubCIEnv(" GITHUB_RUN_ID" )
159166 private def githubSha (): String = githubCIEnv(" GITHUB_SHA" )
160167 private def githubRef (): String = githubCIEnv(" GITHUB_REF" )
0 commit comments