Skip to content

[CI] Publish build scans to develocity.scala-lang.org #21386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build-msi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
cache: 'sbt'
- name: Build MSI package
run: sbt 'dist-win-x86_64/Windows/packageBin'
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
- name: Upload MSI Artifact
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ jobs:
mac-aarch64-id : ${{ steps.mac-aarch64.outputs.artifact-id }}
win-x86_64-id : ${{ steps.win-x86_64.outputs.artifact-id }}
win-x86_64-digest: ${{ steps.win-x86_64-digest.outputs.digest }}
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down Expand Up @@ -112,5 +114,3 @@ jobs:
run : |
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
echo "digest=$(sha256sum artifact.zip | cut -d " " -f 1)" >> "$GITHUB_OUTPUT"


3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ on:

env:
DOTTY_CI_RUN: true
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

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

build-sdk-package:
uses: ./.github/workflows/build-sdk.yml
with:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dependency-graph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: scalacenter/sbt-dependency-submission@v3
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
2 changes: 2 additions & 0 deletions .github/workflows/language-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
./project/scripts/sbt "scaladoc/generateReferenceDocumentation --no-regenerate-expected-links"
./project/scripts/docsLinksStability ./scaladoc/output/reference ./project/scripts/expected-links/reference-expected-links.txt
cd ..
env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

- name: Push changes to scala3-reference-docs
if: github.event_name == 'push'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/launchers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ on:
pull_request:
workflow_dispatch:

env:
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}

jobs:
linux-x86_64:
name: Deploy and Test on Linux x64 architecture
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/scaladoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
build:
env:
AZURE_STORAGE_SAS_TOKEN: ${{ secrets.AZURE_STORAGE_SAS_TOKEN }}
DEVELOCITY_ACCESS_KEY: ${{ secrets.DEVELOCITY_ACCESS_KEY }}
runs-on: ubuntu-latest
if: "github.event_name == 'merge_group'
|| ( github.event_name == 'pull_request'
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Dotty
=====
[![Dotty CI](https://github.com/scala/scala3/workflows/Dotty/badge.svg?branch=main)](https://github.com/scala/scala3/actions?query=branch%3Amain)
[![Join the chat at https://discord.com/invite/scala](https://img.shields.io/discord/632150470000902164)](https://discord.com/invite/scala)
[![Revved up by Develocity](https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A)](https://develocity.scala-lang.org)

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

Expand Down
24 changes: 24 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import sbt.*
import complete.DefaultParsers._
import pl.project13.scala.sbt.JmhPlugin
import pl.project13.scala.sbt.JmhPlugin.JmhKeys.Jmh
import com.gradle.develocity.agent.sbt.DevelocityPlugin.autoImport._
import com.typesafe.sbt.packager.Keys._
import com.typesafe.sbt.packager.MappingsHelper.directory
import com.typesafe.sbt.packager.universal.UniversalPlugin
Expand Down Expand Up @@ -268,6 +269,25 @@ object Build {

// enable verbose exception messages for JUnit
(Test / testOptions) += Tests.Argument(TestFrameworks.JUnit, "-a", "-v", "-s"),

// Configuration to publish build scans to develocity.scala-lang.org
develocityConfiguration := {
val isInsideCI = insideCI.value
val previousConfig = develocityConfiguration.value
val previousBuildScan = previousConfig.buildScan
previousConfig
.withProjectId(ProjectId("scala3"))
.withServer(previousConfig.server.withUrl(Some(url("https://develocity.scala-lang.org"))))
.withBuildScan(
previousBuildScan
.withPublishing(Publishing.onlyIf(_.authenticated))
.withBackgroundUpload(!isInsideCI)
.tag(if (isInsideCI) "CI" else "Local")
.withLinks(previousBuildScan.links ++ GithubEnv.develocityLinks)
.withValues(previousBuildScan.values ++ GithubEnv.develocityValues)
.withObfuscation(previousBuildScan.obfuscation.withIpAddresses(_.map(_ => "0.0.0.0")))
)
}
)

// Settings shared globally (scoped in Global). Used in build.sbt
Expand Down Expand Up @@ -888,6 +908,10 @@ object Build {
sjsSources
} (Set(scalaJSIRSourcesJar)).toSeq
}.taskValue,

// Develocity's Build Cache does not work with our compilation tests
// at the moment.
Test / develocityBuildCacheClient := None,
)

def insertClasspathInArgs(args: List[String], cp: String): List[String] = {
Expand Down
30 changes: 30 additions & 0 deletions project/GithubEnv.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import scala.util.Properties
import sbt.url
import java.net.URL


// https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/variables#default-environment-variables
object GithubEnv {
lazy val repositoryVar: Option[(String, String)] = envVar("GITHUB_REPOSITORY")
lazy val runIdVar: Option[(String, String)] = envVar("GITHUB_RUN_ID")
lazy val shaVar: Option[(String, String)] = envVar("GITHUB_SHA")
lazy val workflowVar: Option[(String, String)] = envVar("GITHUB_WORKFLOW")

lazy val runUrl: Option[(String, URL)] =
for {
(_, repository) <- repositoryVar
(_, runId) <- runIdVar
} yield "GITHUB_RUN" -> url(s"https://github.com/$repository/actions/runs/$runId")
lazy val treeUrl: Option[(String, URL)] =
for {
(_, repository) <- repositoryVar
(_, sha) <- shaVar
} yield "GITHUB_TREE" -> url(s"https://github.com/$repository/tree/$sha")


def develocityValues: Seq[(String, String)] = repositoryVar.toSeq ++ shaVar ++ workflowVar
def develocityLinks: Seq[(String, URL)] = runUrl.toSeq ++ treeUrl

private def envVar(key: String): Option[(String, String)] =
Properties.envOrNone(key).map(key -> _)
}
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.2")
addSbtPlugin("ch.epfl.scala" % "sbt-tasty-mima" % "1.0.0")

addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.10.0")

addSbtPlugin("com.gradle" % "sbt-develocity" % "1.1.1")
Loading