Skip to content
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Nebula Build
on:
push:
branches:
- 'main'
pull_request:

jobs:
buildmultijdk:
runs-on: ubuntu-latest
strategy:
matrix:
# test against latest update of some major Java version(s), as well as specific LTS version(s)
java: [17, 21, 25]
name: Gradle Build without Publish
steps:
- uses: actions/checkout@v4
- name: Setup git user
run: |
git config --global user.name "Nebula Plugin Maintainers"
git config --global user.email "nebula-plugins-oss@netflix.com"
- name: Set up JDKs
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
11
17
21
${{ matrix.java }}
java-package: jdk
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-overwrite-existing: true
- name: Gradle build
run: ./gradlew --stacktrace build
env:
JDK_VERSION_FOR_TESTS: ${{ matrix.java }}
89 changes: 0 additions & 89 deletions .github/workflows/nebula.yml

This file was deleted.

48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Nebula Publish
on:
push:
tags:
- v*.*.*
- v*.*.*-rc.*

jobs:
publish:
if: github.event.base_ref == 'refs/heads/main' # tags must be pushed to main
runs-on: ubuntu-latest
name: Gradle Build and Publish
environment:
name: Publish
url: "https://repo1.maven.org/maven2/com/netflix/nebula/nebula-test/"
env:
NETFLIX_OSS_SONATYPE_USERNAME: ${{ secrets.ORG_SONATYPE_USERNAME }}
NETFLIX_OSS_SONATYPE_PASSWORD: ${{ secrets.ORG_SONATYPE_PASSWORD }}
NETFLIX_OSS_SIGNING_KEY: ${{ secrets.ORG_SIGNING_KEY }}
NETFLIX_OSS_SIGNING_PASSWORD: ${{ secrets.ORG_SIGNING_PASSWORD }}
NETFLIX_OSS_REPO_USERNAME: ${{ secrets.ORG_NETFLIXOSS_USERNAME }}
NETFLIX_OSS_REPO_PASSWORD: ${{ secrets.ORG_NETFLIXOSS_PASSWORD }}
steps:
- uses: actions/checkout@v4
- name: Setup git user
run: |
git config --global user.name "Nebula Plugin Maintainers"
git config --global user.email "nebula-plugins-oss@netflix.com"
- name: Set up JDKs
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: |
17
21
java-package: jdk
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
with:
cache-overwrite-existing: true
- name: Gradle build
run: ./gradlew --stacktrace build
- name: Publish candidate
if: contains(github.ref, '-rc.')
run: ./gradlew --info --stacktrace -Prelease.useLastTag=true candidate
- name: Publish release
if: (!contains(github.ref, '-rc.'))
run: ./gradlew --info --stacktrace -Prelease.useLastTag=true final
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@
*/
package nebula.test.dependencies

import nebula.test.functional.GradleRunnerFactory
import nebula.test.gradle.GradleVersionComparator
import org.gradle.api.invocation.Gradle
import org.gradle.testkit.runner.GradleRunner

class GradleDependencyGenerator {
private static final String DEFAULT_GRADLE_VERSION = '5.2.1'
private static final String GRADLE_FIVE_ZERO = '5.0.0'
private static final String LEGACY_PATTERN_LAYOUT = "layout('pattern')"
private static final String PATTERN_LAYOUT = "patternLayout"

static final String STANDARD_SUBPROJECT_BLOCK = '''\
Expand All @@ -49,30 +46,6 @@ class GradleDependencyGenerator {
}
'''.stripIndent()

static final String LEGACY_STANDARD_SUBPROJECT_BLOCK = '''\
subprojects {
apply plugin: 'maven-publish'
apply plugin: 'ivy-publish'
apply plugin: 'java-library'

publishing {
repositories {
maven {
url = "../mavenrepo"
}
ivy {
url = "../ivyrepo"
layout('pattern') {
ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]'
artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'
m2compatible = true
}
}
}
}
}
'''.stripIndent()

static final String BUILD_GRADLE = 'build.gradle'

private boolean generated = false
Expand All @@ -81,23 +54,23 @@ class GradleDependencyGenerator {
File gradleRoot
File ivyRepoDir
File mavenRepoDir
String gradleVersion
String gradleVersion = null

GradleDependencyGenerator(String gradleVersion, DependencyGraph graph, String directory = 'build/testrepogen') {
this.graph = graph
this.gradleRoot = new File(directory)
this.ivyRepoDir = new File(directory, 'ivyrepo')
this.mavenRepoDir = new File(directory, 'mavenrepo')
this.gradleVersion = gradleVersion
generateGradleFiles(gradleVersion)
generateGradleFiles()
}

GradleDependencyGenerator(Gradle gradle, DependencyGraph graph, String directory = 'build/testrepogen') {
this(gradle.gradleVersion, graph, directory)
}

GradleDependencyGenerator(DependencyGraph graph, String directory = 'build/testrepogen') {
this(DEFAULT_GRADLE_VERSION, graph, directory)
this(null as String, graph, directory)
}

File generateTestMavenRepo() {
Expand Down Expand Up @@ -136,8 +109,7 @@ class GradleDependencyGenerator {

String getIvyRepositoryBlock() {
use(GradleVersionComparator) {
boolean isGradleOlderThanGradleFive = gradleVersion.versionLessThan(GRADLE_FIVE_ZERO)
String layoutPattern = isGradleOlderThanGradleFive ? LEGACY_PATTERN_LAYOUT : PATTERN_LAYOUT
String layoutPattern = PATTERN_LAYOUT
return """\
ivy {
url = '${getIvyRepoUrl()}'
Expand All @@ -151,7 +123,7 @@ class GradleDependencyGenerator {
}
}

private void generateGradleFiles(String gradleVersion) {
private void generateGradleFiles() {
use(GradleVersionComparator) {
if (generated) {
return
Expand All @@ -161,7 +133,7 @@ class GradleDependencyGenerator {

gradleRoot.mkdirs()
def rootBuildGradle = new File(gradleRoot, BUILD_GRADLE)
rootBuildGradle.text = gradleVersion.versionLessThan(GRADLE_FIVE_ZERO) ? LEGACY_STANDARD_SUBPROJECT_BLOCK : STANDARD_SUBPROJECT_BLOCK
rootBuildGradle.text = STANDARD_SUBPROJECT_BLOCK
def includes = []
graph.nodes.each { DependencyGraphNode n ->
String subName = "${n.group}.${n.artifact}_${n.version.replaceAll(/\./, '_')}"
Expand Down Expand Up @@ -217,7 +189,10 @@ class GradleDependencyGenerator {
}

private void runTasks(String tasks) {
def runner = GradleRunnerFactory.createTooling() // Could optionally use Launcher
runner.run(gradleRoot, tasks.tokenize()).rethrowFailure()
def runner = GradleRunner.create().withProjectDir(gradleRoot).withArguments(tasks.tokenize())
if (gradleVersion != null) {
runner = runner.withGradleVersion(gradleVersion)
}
runner.run()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import nebula.test.functional.internal.toolingapi.ToolingApiGradleHandleFactory

import java.util.function.Predicate

/**
* @deprecated in favor of TestKit-based tooling
*/
@Deprecated
@CompileStatic
class GradleRunnerFactory {
public static GradleRunner createTooling(boolean fork = false, String version = null, Integer daemonMaxIdleTimeInSeconds = null,
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/nebula/test/dsl/BuildTaskAssert.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static BuildTaskAssert assertThat(BuildTask actual) {
/**
* Assert that the task was run and resulted in the expected outcome
* @param outcome the expected outcome
* @return the same instance of the task assertion for chaining
*/
@Contract("_ -> this")
public BuildTaskAssert hasOutcome(TaskOutcome outcome) {
Expand All @@ -48,6 +49,7 @@ public BuildTaskAssert hasOutcome(TaskOutcome outcome) {
/**
* Assert that the task was run and resulted in any of the expected outcomes
* @param outcomes the expected possible outcomes
* @return the same instance of the task assertion for chaining
*/
@Contract("_ -> this")
public BuildTaskAssert hasOutcome(TaskOutcome... outcomes) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/groovy/nebula/test/ConcreteIntegrationSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package nebula.test

import nebula.test.functional.ExecutionResult
import nebula.test.functional.PreExecutionAction
import spock.lang.Ignore
import spock.lang.Unroll

@Ignore("non-testkit tests don't work in github actions + setup-gradle")
class ConcreteIntegrationSpec extends IntegrationSpec {
def 'runs build'() {
when:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package nebula.test.dependencies

import org.gradle.api.JavaVersion
import org.gradle.api.invocation.Gradle
import spock.lang.Specification

Expand Down Expand Up @@ -113,24 +112,6 @@ class GradleDependencyGeneratorSpec extends Specification {
new File(ivyRepo, 'test/ivy/foo/1.0.0/foo-1.0.0.jar').exists()
}

def 'generate an ivy repo block - gradle version older than 5.x'() {
def directory = 'build/testdependencies/testivyrepo'
def graph = ['test.ivy:foo:1.0.0']
def generator = new GradleDependencyGenerator("4.10.3", new DependencyGraph(graph), directory)

when:
String block = generator.getIvyRepositoryBlock()

then:
block.contains("""
layout('pattern') {
ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]'
artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'
m2compatible = true
}
""")
}

def 'generate an ivy repo block - uses Gradle object newer versions of Gradle'() {
Gradle gradleMock = Mock(Gradle)
def directory = 'build/testdependencies/testivyrepo'
Expand All @@ -153,27 +134,6 @@ class GradleDependencyGeneratorSpec extends Specification {

}

def 'generate an ivy repo block - uses Gradle object old versions of Gradle'() {
Gradle gradleMock = Mock(Gradle)
def directory = 'build/testdependencies/testivyrepo'
def graph = ['test.ivy:foo:1.0.0']

when:
def generator = new GradleDependencyGenerator(gradleMock, new DependencyGraph(graph), directory)
String block = generator.getIvyRepositoryBlock()

then:
1 * gradleMock.getGradleVersion() >> "4.10.3"

block.contains("""
layout('pattern') {
ivy '[organisation]/[module]/[revision]/[module]-[revision]-ivy.[ext]'
artifact '[organisation]/[module]/[revision]/[artifact]-[revision](-[classifier]).[ext]'
m2compatible = true
}
""")
}

def 'generate an ivy repo block - gradle version newer than 5.x'() {
def directory = 'build/testdependencies/testivyrepo'
def graph = ['test.ivy:foo:1.0.0']
Expand Down
Loading