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 " Submitting snapshot of build $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
@@ -119,7 +124,7 @@ object SubmitDependencyGraph {
119
124
val manifests = state.get(githubManifestsKey).get
120
125
DependencySnapshot (
121
126
0 ,
122
- githubJob(),
127
+ githubJob(state ),
123
128
githubSha(),
124
129
githubRef(),
125
130
detector,
@@ -129,21 +134,24 @@ object SubmitDependencyGraph {
129
134
)
130
135
}
131
136
132
- private def githubJob (): Job = {
133
- val correlator = s " ${githubJobName()}_ ${githubWorkflow ()}"
137
+ private def githubJob (state : State ): Job = {
138
+ val correlator = s " ${githubWorkflow()} _ ${ githubJobName()}_ ${githubAction ()}"
134
139
val id = githubRunId
135
140
val html_url =
136
141
for {
137
142
serverUrl <- Properties .envOrNone(" $GITHUB_SERVER_URL" )
138
143
repository <- Properties .envOrNone(" GITHUB_REPOSITORY" )
139
144
} 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
141
148
}
142
149
143
150
private def checkGithubEnv (): Unit = {
144
151
githubWorkspace()
145
152
githubWorkflow()
146
153
githubJobName()
154
+ githubAction()
147
155
githubRunId()
148
156
githubSha()
149
157
githubRef()
@@ -152,9 +160,10 @@ object SubmitDependencyGraph {
152
160
githubToken()
153
161
}
154
162
155
- private def githubWorkspace (): Path = Paths .get( githubCIEnv(" GITHUB_WORKSPACE" )).toAbsolutePath
163
+ private def githubWorkspace (): String = githubCIEnv(" GITHUB_WORKSPACE" )
156
164
private def githubWorkflow (): String = githubCIEnv(" GITHUB_WORKFLOW" )
157
165
private def githubJobName (): String = githubCIEnv(" GITHUB_JOB" )
166
+ private def githubAction (): String = githubCIEnv(" GITHUB_ACTION" )
158
167
private def githubRunId (): String = githubCIEnv(" GITHUB_RUN_ID" )
159
168
private def githubSha (): String = githubCIEnv(" GITHUB_SHA" )
160
169
private def githubRef (): String = githubCIEnv(" GITHUB_REF" )
0 commit comments