Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 12 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
26 changes: 24 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down Expand Up @@ -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 :=
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
@@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down Expand Up @@ -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...")
Expand Down Expand Up @@ -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 {
Expand Down
Loading