Skip to content

Commit

Permalink
[CI] Publish build scans to develocity.scala-lang.org
Browse files Browse the repository at this point in the history
  • Loading branch information
adpi2 committed Aug 19, 2024
1 parent b64afad commit 0f827c6
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 3 deletions.
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
20 changes: 20 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
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.0.1")

0 comments on commit 0f827c6

Please sign in to comment.