Skip to content

Commit a37da19

Browse files
authored
[CI] Publish build scans to develocity.scala-lang.org (#21386)
For the Context, Gradle is supporting the Scala Center with a free instance of [Develocity](https://gradle.com/gradle-enterprise-solutions/) that we can use to analyze the build scans of our open-source projects. This PR configures publishing of build scans for every GitHub workflow of the `scala/scala3` CI. All build scans will be publicly available on https://develocity.scala-lang.org/. The `sbt-develocity` plugin can also do test retry and flaky test detection, which I will activate in a subsequent PR, on some test classes.
2 parents ec1b115 + df43fa4 commit a37da19

11 files changed

+77
-3
lines changed

Diff for: .github/workflows/build-msi.yml

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ jobs:
2929
cache: 'sbt'
3030
- name: Build MSI package
3131
run: sbt 'dist-win-x86_64/Windows/packageBin'
32+
env:
33+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
3234
- name: Upload MSI Artifact
3335
uses: actions/upload-artifact@v4
3436
with:

Diff for: .github/workflows/build-sdk.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }}
5353
win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }}
5454
win-x86_64-digest: ${{ steps.win-x86_64-digest.outputs.digest }}
55+
env:
56+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
5557
steps:
5658
- uses: actions/checkout@v4
5759
- uses: actions/setup-java@v4
@@ -112,5 +114,3 @@ jobs:
112114
run : |
113115
curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -o artifact.zip -L https://api.github.com/repos/scala/scala3/actions/artifacts/${{ steps.win-x86_64.outputs.artifact-id }}/zip
114116
echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT"
115-
116-

Diff for: .github/workflows/ci.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ on:
2828

2929
env:
3030
DOTTY_CI_RUN: true
31+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
3132

3233
# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
3334
# since it means that every container has the same weight which should be
@@ -1013,7 +1014,7 @@ jobs:
10131014
uses: ./.github/workflows/build-msi.yml
10141015
if : github.event_name == 'pull_request' && contains(github.event.pull_request.body, '[test_msi]')
10151016
# TODO: ADD A JOB THAT DEPENDS ON THIS TO TEST THE MSI
1016-
1017+
10171018
build-sdk-package:
10181019
uses: ./.github/workflows/build-sdk.yml
10191020
with:

Diff for: .github/workflows/dependency-graph.yml

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v4
1212
- uses: scalacenter/sbt-dependency-submission@v3
13+
env:
14+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

Diff for: .github/workflows/language-reference.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
./project/scripts/sbt "scaladoc/generateReferenceDocumentation --no-regenerate-expected-links"
4444
./project/scripts/docsLinksStability ./scaladoc/output/reference ./project/scripts/expected-links/reference-expected-links.txt
4545
cd ..
46+
env:
47+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
4648

4749
- name: Push changes to scala3-reference-docs
4850
if: github.event_name == 'push'

Diff for: .github/workflows/launchers.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
pull_request:
44
workflow_dispatch:
55

6+
env:
7+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
8+
69
jobs:
710
linux-x86_64:
811
name: Deploy and Test on Linux x64 architecture

Diff for: .github/workflows/scaladoc.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
build:
1717
env:
1818
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_STORAGE_SAS_TOKEN }}
19+
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
1920
runs-on: ubuntu-latest
2021
if: "github.event_name == 'merge_group'
2122
|| ( github.event_name == 'pull_request'

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Dotty
22
=====
33
[![Dotty CI](https://github.com/scala/scala3/workflows/Dotty/badge.svg?branch=main)](https://github.com/scala/scala3/actions?query=branch%3Amain)
44
[![Join the chat at https://discord.com/invite/scala](https://img.shields.io/discord/632150470000902164)](https://discord.com/invite/scala)
5+
[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://develocity.scala-lang.org)
56

67
* [Documentation](https://docs.scala-lang.org/scala3/)
78

Diff for: project/Build.scala

+30
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import sbt.*
99
import complete.DefaultParsers._
1010
import pl.project13.scala.sbt.JmhPlugin
1111
import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh
12+
import com.gradle.develocity.agent.sbt.DevelocityPlugin.autoImport._
1213
import com.typesafe.sbt.packager.Keys._
1314
import com.typesafe.sbt.packager.MappingsHelper.directory
1415
import com.typesafe.sbt.packager.universal.UniversalPlugin
@@ -268,6 +269,31 @@ object Build {
268269

269270
// enable verbose exception messages for JUnit
270271
(Test / testOptions) += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-s"),
272+
273+
// Configuration to publish build scans to develocity.scala-lang.org
274+
develocityConfiguration := {
275+
val isInsideCI = insideCI.value
276+
val config = develocityConfiguration.value
277+
val buildScan = config.buildScan
278+
val buildCache = config.buildCache
279+
config
280+
.withProjectId(ProjectId("scala3"))
281+
.withServer(config.server.withUrl(Some(url("https://develocity.scala-lang.org"))))
282+
.withBuildScan(
283+
buildScan
284+
.withPublishing(Publishing.onlyIf(_.authenticated))
285+
.withBackgroundUpload(!isInsideCI)
286+
.tag(if (isInsideCI) "CI" else "Local")
287+
.withLinks(buildScan.links ++ GithubEnv.develocityLinks)
288+
.withValues(buildScan.values ++ GithubEnv.develocityValues)
289+
.withObfuscation(buildScan.obfuscation.withIpAddresses(_.map(_ => "0.0.0.0")))
290+
)
291+
.withBuildCache(
292+
buildCache
293+
.withLocal(buildCache.local.withEnabled(false))
294+
.withRemote(buildCache.remote.withEnabled(false))
295+
)
296+
}
271297
)
272298

273299
// Settings shared globally (scoped in Global). Used in build.sbt
@@ -888,6 +914,10 @@ object Build {
888914
sjsSources
889915
} (Set(scalaJSIRSourcesJar)).toSeq
890916
}.taskValue,
917+
918+
// Develocity's Build Cache does not work with our compilation tests
919+
// at the moment: it does not take compilation files as inputs.
920+
Test / develocityBuildCacheClient := None,
891921
)
892922

893923
def insertClasspathInArgs(args: List[String], cp: String): List[String] = {

Diff for: project/GithubEnv.scala

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import scala.util.Properties
2+
import sbt.url
3+
import java.net.URL
4+
5+
6+
// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/variables#default-environment-variables
7+
object GithubEnv {
8+
lazy val repositoryVar: Option[(String, String)] = envVar("GITHUB_REPOSITORY")
9+
lazy val runIdVar: Option[(String, String)] = envVar("GITHUB_RUN_ID")
10+
lazy val shaVar: Option[(String, String)] = envVar("GITHUB_SHA")
11+
lazy val workflowVar: Option[(String, String)] = envVar("GITHUB_WORKFLOW")
12+
13+
lazy val runUrl: Option[(String, URL)] =
14+
for {
15+
(_, repository) <- repositoryVar
16+
(_, runId) <- runIdVar
17+
} yield "GitHub Run" -> url(s"https://github.com/$repository/actions/runs/$runId")
18+
lazy val treeUrl: Option[(String, URL)] =
19+
for {
20+
(_, repository) <- repositoryVar
21+
(_, sha) <- shaVar
22+
} yield "GitHub Commit" -> url(s"https://github.com/$repository/tree/$sha")
23+
24+
25+
def develocityValues: Seq[(String, String)] = repositoryVar.toSeq ++ shaVar ++ workflowVar
26+
def develocityLinks: Seq[(String, URL)] = runUrl.toSeq ++ treeUrl
27+
28+
private def envVar(key: String): Option[(String, String)] =
29+
Properties.envOrNone(key).map(key -> _)
30+
}

Diff for: project/plugins.sbt

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.2")
2121
addSbtPlugin("ch.epfl.scala" % "sbt-tasty-mima" % "1.0.0")
2222

2323
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")
24+
25+
addSbtPlugin("com.gradle" % "sbt-develocity" % "1.1.1")

0 commit comments

Comments
 (0)