1
1
package ch .epfl .scala
2
2
3
3
import java .nio .charset .StandardCharsets
4
- import java .nio .file .Path
5
4
import java .nio .file .Paths
6
5
import java .time .Instant
7
6
@@ -10,7 +9,6 @@ import scala.concurrent.duration.Duration
10
9
import scala .util .Properties
11
10
import scala .util .Try
12
11
13
- import ch .epfl .scala .GithubDependencyGraphPlugin .autoImport
14
12
import ch .epfl .scala .GithubDependencyGraphPlugin .autoImport ._
15
13
import ch .epfl .scala .JsonProtocol ._
16
14
import ch .epfl .scala .githubapi .JsonProtocol ._
@@ -59,9 +57,16 @@ object SubmitDependencyGraph {
59
57
.flatMap(projectRef => state.setting(projectRef / Keys .crossScalaVersions))
60
58
.distinct
61
59
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
+
62
67
val initState = state
63
68
.put(githubSubmitInputKey, input)
64
- .put(autoImport.githubWorkspace, githubWorkspace( ))
69
+ .put(githubBuildFile, githubapi. FileInfo (buildFile.toString ))
65
70
.put(githubManifestsKey, Map .empty[String , Manifest ])
66
71
.put(githubProjectsKey, projectRefs)
67
72
@@ -85,7 +90,7 @@ object SubmitDependencyGraph {
85
90
" Authorization" -> s " token ${githubToken()}"
86
91
)
87
92
88
- state.log.info(s " Submiting dependency snapshot to $snapshotUrl" )
93
+ state.log.info(s " Submiting dependency snapshot of job ${snapshot.job} to $snapshotUrl" )
89
94
val result = for {
90
95
httpResp <- Try (Await .result(http.processFull(request), Duration .Inf ))
91
96
snapshot <- getSnapshot(httpResp)
@@ -130,11 +135,11 @@ object SubmitDependencyGraph {
130
135
}
131
136
132
137
private def githubJob (): Job = {
133
- val correlator = s " ${githubJobName()}_ ${githubWorkflow ()}"
138
+ val correlator = s " ${githubWorkflow()} _ ${ githubJobName()}_ ${githubAction ()}"
134
139
val id = githubRunId
135
140
val html_url =
136
141
for {
137
- serverUrl <- Properties .envOrNone(" $ GITHUB_SERVER_URL" )
142
+ serverUrl <- Properties .envOrNone(" GITHUB_SERVER_URL" )
138
143
repository <- Properties .envOrNone(" GITHUB_REPOSITORY" )
139
144
} yield s " $serverUrl/ $repository/actions/runs/ $id"
140
145
Job (correlator, id, html_url)
@@ -144,6 +149,7 @@ object SubmitDependencyGraph {
144
149
githubWorkspace()
145
150
githubWorkflow()
146
151
githubJobName()
152
+ githubAction()
147
153
githubRunId()
148
154
githubSha()
149
155
githubRef()
@@ -152,9 +158,10 @@ object SubmitDependencyGraph {
152
158
githubToken()
153
159
}
154
160
155
- private def githubWorkspace (): Path = Paths .get( githubCIEnv(" GITHUB_WORKSPACE" )).toAbsolutePath
161
+ private def githubWorkspace (): String = githubCIEnv(" GITHUB_WORKSPACE" )
156
162
private def githubWorkflow (): String = githubCIEnv(" GITHUB_WORKFLOW" )
157
163
private def githubJobName (): String = githubCIEnv(" GITHUB_JOB" )
164
+ private def githubAction (): String = githubCIEnv(" GITHUB_ACTION" )
158
165
private def githubRunId (): String = githubCIEnv(" GITHUB_RUN_ID" )
159
166
private def githubSha (): String = githubCIEnv(" GITHUB_SHA" )
160
167
private def githubRef (): String = githubCIEnv(" GITHUB_REF" )
0 commit comments