diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcd76fc..190522b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest] - scala: [2.12.20] + scala: [2.12.20, 3.7.3] java: [temurin@8, temurin@11, temurin@17, temurin@21] exclude: - java: temurin@8 @@ -79,7 +79,7 @@ jobs: - name: Check that workflows are up to date run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck - - run: sbt '++ ${{ matrix.scala }}' test scripted + - run: sbt '++ ${{ matrix.scala }}' test runScriptedTests - name: Compress target directories run: tar cf targets.tar target project/target @@ -151,6 +151,16 @@ jobs: tar xf targets.tar rm targets.tar + - name: Download target directories (3.7.3) + uses: actions/download-artifact@v4 + with: + name: target-${{ matrix.os }}-3.7.3-${{ matrix.java }} + + - name: Inflate target directories (3.7.3) + run: | + tar xf targets.tar + rm targets.tar + - name: Publish project env: PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }} diff --git a/build.sbt b/build.sbt index 000ce99..17a152c 100644 --- a/build.sbt +++ b/build.sbt @@ -4,9 +4,31 @@ sbtPlugin := true enablePlugins(SbtPlugin) lazy val scala212 = "2.12.20" -ThisBuild / crossScalaVersions := Seq(scala212) +lazy val scala3 = "3.7.3" +ThisBuild / crossScalaVersions := Seq(scala212, scala3) ThisBuild / scalaVersion := scala212 +pluginCrossBuild / sbtVersion := { + scalaBinaryVersion.value match { + case "2.12" => + sbtVersion.value + case _ => + "2.0.0-RC6" + } +} + +TaskKey[Unit]("runScriptedTests") := Def.taskDyn { + scalaBinaryVersion.value match { + case "3" => + // TODO enable sbt 2 test + Def.task { + streams.value.log.warn("skip sbt 2 scripted test") + } + case _ => + scripted.toTask("") + } +}.value + organization := "com.github.sbt" homepage := Some(url("https://github.com/sbt/sbt-pull-request-validator")) @@ -65,7 +87,7 @@ ThisBuild / dynver := { sbtdynver.DynVer.getGitDescribeOutput(d).mkVersion(versionFmt, fallbackVersion(d)) } -ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "scripted"))) +ThisBuild / githubWorkflowBuild := Seq(WorkflowStep.Sbt(List("test", "runScriptedTests"))) ThisBuild / githubWorkflowTargetTags ++= Seq("v*") ThisBuild / githubWorkflowPublishTargetBranches := diff --git a/src/main/scala-2/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala b/src/main/scala-2/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala new file mode 100644 index 0000000..64ecdb8 --- /dev/null +++ b/src/main/scala-2/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala @@ -0,0 +1,22 @@ +/* + * Sbt Pull Request Validator + * Copyright Lightbend and Hewlett Packard Enterprise + * + * Licensed under Apache License 2.0 + * SPDX-License-Identifier: Apache-2.0 + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package com.github.sbt.pullrequestvalidator + +import sbt.Credentials +import sbt.librarymanagement.ivy.DirectCredentials + +private[pullrequestvalidator] object ValidatePullRequestCompat { + def credentialsForHost(sc: Seq[Credentials], host: String): Option[DirectCredentials] = + sbt.Credentials.forHost(sc, host) + + def testFull = sbt.Keys.test +} diff --git a/src/main/scala-3/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala b/src/main/scala-3/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala new file mode 100644 index 0000000..7fbc7d8 --- /dev/null +++ b/src/main/scala-3/com/github/sbt/pullrequestvalidator/ValidatePullRequestCompat.scala @@ -0,0 +1,23 @@ +/* + * Sbt Pull Request Validator + * Copyright Lightbend and Hewlett Packard Enterprise + * + * Licensed under Apache License 2.0 + * SPDX-License-Identifier: Apache-2.0 + * + * See the NOTICE file distributed with this work for + * additional information regarding copyright ownership. + */ + +package com.github.sbt.pullrequestvalidator + +import sbt.Credentials +import sbt.internal.librarymanagement.ivy.IvyCredentials +import sbt.librarymanagement.Credentials.DirectCredentials + +private[pullrequestvalidator] object ValidatePullRequestCompat { + def credentialsForHost(sc: Seq[Credentials], host: String): Option[DirectCredentials] = + IvyCredentials.forHost(sc, host) + + def testFull = sbt.Keys.testFull +} diff --git a/src/main/scala/com/github/sbt/pullrequestvalidator/ValidatePullRequest.scala b/src/main/scala/com/github/sbt/pullrequestvalidator/ValidatePullRequest.scala index a641516..07754aa 100644 --- a/src/main/scala/com/github/sbt/pullrequestvalidator/ValidatePullRequest.scala +++ b/src/main/scala/com/github/sbt/pullrequestvalidator/ValidatePullRequest.scala @@ -76,19 +76,26 @@ object ValidatePullRequest extends AutoPlugin { lazy val prValidatorGithubRepository = settingKey[Option[String]]( "Optional name of the repository where Pull Requests are created. Necessary for explicit 'enforced build all'" ) + @transient lazy val prValidatorGithubEnforcedBuildAll = taskKey[Boolean]("Checks via GitHub API if comments included the PLS BUILD ALL keyword.") + @transient lazy val prValidatorTravisNonPrEnforcedBuildAll = taskKey[Boolean]("Checks whether this is a non PR build on Travis.") + @transient lazy val prValidatorEnforcedBuildAll = taskKey[Boolean]("Whether an enforced build all is done.") // determining touched dirs and projects + @transient lazy val prValidatorChangedProjects = taskKey[Changes]("List of touched projects in this PR branch") + @transient lazy val prValidatorProjectBuildTasks = taskKey[Seq[TaskKey[?]]]("The tasks that should be run, according to what has changed") // running validation + @transient lazy val validatePullRequest = taskKey[Unit]("Validate pull request") + @transient lazy val validatePullRequestBuildAll = taskKey[Unit]("Validate pull request, building all projects") } @@ -161,7 +168,7 @@ object ValidatePullRequest extends AutoPlugin { val buildAllMagicPhrase = prValidatorBuildAllKeyword.value val githubRepository = prValidatorGithubRepository.value val githubEndpoint = prValidatorGithubEndpoint.value - val githubCredentials = Credentials.forHost(credentials.value, githubEndpoint.getHost) + val githubCredentials = ValidatePullRequestCompat.credentialsForHost(credentials.value, githubEndpoint.getHost) pullRequestId.exists { prId => log.info("Checking GitHub comments for PR validation options...") @@ -291,7 +298,7 @@ object ValidatePullRequest extends AutoPlugin { Seq() } }, - prValidatorTasks := Seq(Test / test), + prValidatorTasks := Seq(Test / ValidatePullRequestCompat.testFull), prValidatorBuildAllTasks := prValidatorTasks.value, prValidatorEnforcedBuildAllTasks := prValidatorBuildAllTasks.value, validatePullRequest := Def.taskDyn {