Skip to content
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

Updates to gradle build file #48

Merged
merged 2 commits into from
Aug 20, 2021
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
19 changes: 1 addition & 18 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout RCA package
uses: actions/checkout@v2
with:
repository: opensearch-project/performance-analyzer-rca
path: ./tmp/rca
- name: Checkout Performance Analyzer package
uses: actions/checkout@v2
with:
Expand All @@ -23,22 +18,10 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.12
- name: Build RCA with Gradle
working-directory: ./tmp/rca
run: ./gradlew build -x test
- name: Publish RCA jar to maven local
working-directory: ./tmp/rca
run: ./gradlew publishToMavenLocal
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/pa
run: rm -f licenses/performanceanalyzer-rca-1.0.0.0.jar.sha1
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
- name: Build Artifacts
working-directory: ./tmp/pa
run: |
./gradlew build buildDeb buildRpm --refresh-dependencies -Dbuild.snapshot=false -x javadoc
./gradlew build buildDeb buildRpm --refresh-dependencies -Dbuild.snapshot=false -Dperformance-analyzer-rca.build=true -Dperformance-analyzer-rca.branch=main -x javadoc
mkdir artifacts
artifact=`ls build/distributions/*.zip`
rpm_artifact=`ls build/distributions/*.rpm`
Expand Down
23 changes: 3 additions & 20 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@ on:
- "*"

jobs:
build_rca_pkg:
build_pa_pkg:
runs-on: [ubuntu-latest]
name: Building RCA package
name: Building PA package
steps:
- name: Checkout RCA package
uses: actions/checkout@v2
with:
repository: opensearch-project/performance-analyzer-rca
path: ./tmp/rca
- name: Checkout Performance Analyzer package
uses: actions/checkout@v2
with:
Expand All @@ -30,12 +25,6 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 1.12
- name: Build RCA with Gradle
working-directory: ./tmp/rca
run: ./gradlew build -x test
- name: Publish RCA jar to maven local
working-directory: ./tmp/rca
run: ./gradlew publishToMavenLocal
# dependencies: OpenSearch
- name: Checkout OpenSearch
uses: actions/checkout@v2
Expand All @@ -46,12 +35,6 @@ jobs:
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.snapshot=false
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/pa
run: rm -f licenses/performanceanalyzer-rca-1.0.0.0.jar.sha1
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
# Explicitly set the docker-compose program path so that our build scripts in RCA can run the program
# This is necessary because of the Github Actions environment and the workingDir of the Gradle environment
- name: Set docker-compose path
Expand All @@ -61,7 +44,7 @@ jobs:
run: sudo sysctl -w vm.max_map_count=262144
- name: Build PA and run Unit Tests
working-directory: ./tmp/pa
run: ./gradlew build
run: ./gradlew build -Dperformance-analyzer-rca.build=true -Dperformance-analyzer-rca.branch=main
- name: Generate Jacoco coverage report
working-directory: ./tmp/pa
run: ./gradlew jacocoTestReport
Expand Down
88 changes: 51 additions & 37 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* GitHub history for details.
*/

/*
/*
* Copyright <2019> Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
Expand All @@ -29,7 +29,8 @@ buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "1.0.0")
}
// This isn't applying from repositories.gradle so repeating it here

// Used to resolve build file dependencies
repositories {
mavenCentral()
mavenLocal()
Expand Down Expand Up @@ -69,6 +70,15 @@ spotbugsTest {
ext {
opensearchVersion = '1.0.0'
isSnapshot = "true" == System.getProperty("build.snapshot", "true")

// The RCA branch that will be built. Default value is main.
rcaProjectBranch = findProperty("performance-analyzer-rca.branch") ?: "main"

// If true, then the build will clone the RCA Project into $rcaProjectDir
cloneRcaProject = "true" == System.getProperty("performance-analyzer-rca.build", "true")

// By default we will look for RCA in a peer directory
rcaProjectDir = findProperty("performance-analyzer-rca.path") ?: "../performance-analyzer-rca"
}

group = "org.opensearch"
Expand All @@ -79,12 +89,8 @@ if (isSnapshot) {

apply plugin: 'opensearch.opensearchplugin'

ext {
projectSubstitutions = [:]
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
gitDefaultBranch = 'main'
}
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')

spotless {
java {
Expand All @@ -107,8 +113,6 @@ test {

licenseHeaders.enabled = true
validateNebulaPom.enabled = false


loggerUsageCheck.enabled = false

opensearchplugin {
Expand All @@ -129,7 +133,7 @@ compileJava {
}

javadoc {
options.addStringOption("-add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED")
options.addStringOption("-add-exports", "jdk.attach/sun.tools.attach=ALL-UNNAMED")
}

project.afterEvaluate {
Expand All @@ -152,7 +156,6 @@ repositories {
jcenter()
}


configurations {
includeJars
}
Expand Down Expand Up @@ -207,7 +210,6 @@ jacocoTestCoverageVerification {
}
}


// to run coverage verification during the build (and fail when appropriate)
check.dependsOn jacocoTestCoverageVerification

Expand All @@ -230,13 +232,13 @@ dependencies {
}

configurations.all {
resolutionStrategy {
force 'junit:junit:4.13.1'
force "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
force "com.fasterxml.jackson.module:jackson-module-paranamer:${jacksonVersion}"
}
resolutionStrategy {
force 'junit:junit:4.13.1'
force "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
force "com.fasterxml.jackson.module:jackson-module-paranamer:${jacksonVersion}"
}
}

compile ('com.google.guava:guava:28.2-jre') {
Expand Down Expand Up @@ -297,48 +299,54 @@ gradle.startParameter.excludedTaskNames += [ "forbiddenApisMain",
"forbiddenApisTest",
"thirdPartyAudit",
"testingConventions"]
import java.nio.file.Paths

import org.ajoberstar.gradle.git.tasks.GitClone
import org.opensearch.gradle.test.RestIntegTestTask

String rcaDir
String rcaArtifactsDir

static def propEnabled(property) {
return System.getProperty(property) != null && System.getProperty(property).toLowerCase().equals("true")
}

// The following Gradle tasks are used to create a PA/RCA enabled OpenSearch cluster
// Pass the -Dtests.enableIT property to Gradle to run ITs

/**
* cloneGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
* to the Gradle JVM
*/
task cloneGitRepo(type: GitClone) {
rcaDir = Paths.get(getProject().getBuildDir().toString(), "performance-analyzer-rca").toString()
def destination = file(rcaDir)
def destination = file(rcaProjectDir)
uri = "https://github.com/opensearch-project/performance-analyzer-rca.git"
branch = gitDefaultBranch
branch = rcaProjectBranch
destinationPath = destination
bare = false
enabled = !destination.exists() // to clone only once
enabled = cloneRcaProject && !destination.exists() // to clone only once

doFirst {
logger.info("Cloning performance-analyzer-rca into ${rcaProjectDir}")
}
}

task buildRca() {
dependsOn(cloneGitRepo)

doFirst {
logger.info("Building performance-analyzer-rca project in ${rcaProjectDir}")
}

doLast {
exec {
workingDir("$rcaDir")
workingDir("$rcaProjectDir")
commandLine './gradlew', 'build', '-x', 'test'
}
exec {
workingDir("$rcaDir")
workingDir("$rcaProjectDir")
commandLine './gradlew', 'publishToMavenLocal'
}
exec {
def licenseDir = "$projectDir/licenses"
workingDir("$licenseDir")
commandLine 'rm', "performanceanalyzer-rca-1.0.0.0.jar.sha1"
commandLine 'rm', "-f", "performanceanalyzer-rca-1.0.0.0.jar.sha1"
}
exec {
workingDir("$projectDir")
Expand All @@ -347,16 +355,23 @@ task buildRca() {
}
}

// This value is set by the unpackRca task
def rcaArtifactsDir

task unpackRca(type: Copy) {
dependsOn(buildRca)
from(zipTree("$rcaDir/build/distributions/performance-analyzer-rca.zip")) {
from(zipTree("$rcaProjectDir/build/distributions/performance-analyzer-rca.zip")) {
}
into "$rcaProjectDir/build/distributions"
rcaArtifactsDir = "$rcaProjectDir/build/distributions/performance-analyzer-rca/"

doLast {
logger.info("Unpacked performance-analyzer-rca artifacts into ${rcaProjectDir}")
}
into "$rcaDir/build/distributions"
rcaArtifactsDir = "$rcaDir/build/distributions/performance-analyzer-rca/"
}

bundlePlugin {
dependsOn 'cloneGitRepo'
dependsOn 'unpackRca'
from("$rcaArtifactsDir/pa_config") {
into "pa_config"
}
Expand Down Expand Up @@ -399,7 +414,7 @@ task setupOpenSearchCluster() {
}
doLast {
exec {
workingDir(rcaDir)
workingDir(rcaProjectDir)
commandLine './gradlew', 'enableRca'
}
sleep(30000)
Expand Down Expand Up @@ -527,4 +542,3 @@ afterEvaluate {
}

bundlePlugin.mustRunAfter unpackRca
build.dependsOn unpackRca