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 " Submitting snapshot of build $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
@@ -119,7 +124,7 @@ object SubmitDependencyGraph {
119124 val manifests = state.get(githubManifestsKey).get
120125 DependencySnapshot (
121126 0 ,
122- githubJob(),
127+ githubJob(state ),
123128 githubSha(),
124129 githubRef(),
125130 detector,
@@ -129,15 +134,17 @@ object SubmitDependencyGraph {
129134 )
130135 }
131136
132- private def githubJob (): Job = {
137+ private def githubJob (state : State ): Job = {
133138 val correlator = s " ${githubJobName()}_ ${githubWorkflow()}"
134139 val id = githubRunId
135140 val html_url =
136141 for {
137142 serverUrl <- Properties .envOrNone(" $GITHUB_SERVER_URL" )
138143 repository <- Properties .envOrNone(" GITHUB_REPOSITORY" )
139144 } yield s " $serverUrl/ $repository/actions/runs/ $id"
140- Job (correlator, id, html_url)
145+ val job = Job (correlator, id, html_url)
146+ state.log.info(s " Job is $job" )
147+ job
141148 }
142149
143150 private def checkGithubEnv (): Unit = {
@@ -152,7 +159,7 @@ object SubmitDependencyGraph {
152159 githubToken()
153160 }
154161
155- private def githubWorkspace (): Path = Paths .get( githubCIEnv(" GITHUB_WORKSPACE" )).toAbsolutePath
162+ private def githubWorkspace (): String = githubCIEnv(" GITHUB_WORKSPACE" )
156163 private def githubWorkflow (): String = githubCIEnv(" GITHUB_WORKFLOW" )
157164 private def githubJobName (): String = githubCIEnv(" GITHUB_JOB" )
158165 private def githubRunId (): String = githubCIEnv(" GITHUB_RUN_ID" )
0 commit comments