Skip to content

Commit

Permalink
set up gradle and CI for query insights
Browse files Browse the repository at this point in the history
Signed-off-by: Chenyang Ji <[email protected]>
  • Loading branch information
ansjcy committed Jun 18, 2024
1 parent c952cbc commit b481985
Show file tree
Hide file tree
Showing 26 changed files with 682 additions and 60 deletions.
134 changes: 134 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Build and Test
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch

build-linux:
needs: Get-CI-Image-Tag
strategy:
matrix:
java: [11, 17, 21]
os: [ ubuntu-latest ]
name: Build and Test query-insights plugin with JDK ${{ matrix.java }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root

steps:
# This step uses the checkout Github action: https://github.com/actions/checkout
- name: Checkout Branch
uses: actions/checkout@v2

# This step uses the setup-java Github action: https://github.com/actions/setup-java
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Build and Test
run: |
chown -R 1000:1000 `pwd`
su `id -un 1000` -c "java -version && ./gradlew build"
plugin=`basename $(ls build/distributions/*.zip)`
echo plugin $plugin
- name: Create Artifact Path
run: |
mkdir -p query-insights-artifacts
cp ./build/distributions/*.zip query-insights-artifacts
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload failed logs
uses: actions/upload-artifact@v2
if: failure()
with:
name: logs-ubuntu
path: build/testclusters/integTest-*/logs/*

- name: Upload Artifacts
uses: actions/upload-artifact@v1
with:
name: query-insights-plugin-${{ matrix.os }}
path: query-insights-artifacts

build-windows-macos:
env:
BUILD_ARGS: ${{ matrix.os_build_args }}
WORKING_DIR: ${{ matrix.working_directory }}.
strategy:
matrix:
java: [11, 17]
os: [ windows-latest, macos-latest ]
include:
- os: windows-latest
os_build_args: -x integTest
working_directory: X:\
os_java_options: -Xmx4096M
- os: macos-latest
os_build_args: -x jacocoTestReport

name: Build and Test query-insights plugin with JDK ${{ matrix.java }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout Branch
uses: actions/checkout@v2

# This is a hack, but this step creates a link to the X: mounted drive, which makes the path
# short enough to work on Windows
- name: Shorten Path
if: ${{ matrix.os == 'windows-latest' }}
run: subst 'X:' .

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Build and Test
working-directory: ${{ env.WORKING_DIR }}
run: ./gradlew build ${{ env.BUILD_ARGS }}
env:
_JAVA_OPTIONS: ${{ matrix.os_java_options }}

- name: Create Artifact Path
run: |
mkdir -p query-insights-artifacts
cp ./build/distributions/*.zip query-insights-artifacts
- name: Upload failed logs
uses: actions/upload-artifact@v2
if: ${{ failure() && matrix.os == 'macos-latest' }}
with:
name: logs-mac
path: build/testclusters/integTest-*/logs/*

- name: Upload failed logs
uses: actions/upload-artifact@v2
if: ${{ failure() && matrix.os == 'windows-latest' }}
with:
name: logs-windows
path: build\testclusters\integTest-*\logs\*

- name: Upload Artifacts
uses: actions/upload-artifact@v1
with:
name: query-insights-plugin-${{ matrix.os }}
path: query-insights-artifacts
11 changes: 6 additions & 5 deletions COMMUNICATIONS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# OpenSearch Project Communication

- [Overview](#overview)
- [Slack](#slack)
- [Getting Started](#getting-started)
- [Workspace Channels](#workspace-channels)
- [Tips](#tips)
- [OpenSearch Project Communication](#opensearch-project-communication)
- [Overview](#overview)
- [Slack](#slack)
- [Getting Started](#getting-started)
- [Workspace Channels](#workspace-channels)
- [Tips](#tips)

## Overview

Expand Down
File renamed without changes.
124 changes: 111 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,116 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/
import org.opensearch.gradle.test.RestIntegTestTask

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.pluginzip'

def pluginName = 'query-insights'
def pluginDescription = 'OpenSearch Query Insights plugin'
def projectPath = 'org.opensearch'
def pathToPlugin = 'plugin.insights'
def pluginClassName = 'QueryInsightsPlugin'

publishing {
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = pluginName
description = pluginDescription
groupId = "org.opensearch.plugin"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/opensearch-plugin-template-java"
}
}
}
}
}
}

opensearchplugin {
description 'OpenSearch Query Insights Plugin.'
classname 'org.opensearch.plugin.insights.QueryInsightsPlugin'
name pluginName
description pluginDescription
classname "${projectPath}.${pathToPlugin}.${pluginClassName}"
licenseFile rootProject.file('LICENSE.txt')
noticeFile rootProject.file('NOTICE.txt')
}

// This requires an additional Jar not published as part of build-tools
loggerUsageCheck.enabled = false

// No need to validate pom, as we do not upload to maven/sonatype
validateNebulaPom.enabled = false

buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
}

repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
}
}

repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}

dependencies {
test {
include '**/*Tests.class'
}

task integTest(type: RestIntegTestTask) {
description = "Run tests against a cluster"
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
}
tasks.named("check").configure { dependsOn(integTest) }

integTest {
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
if (System.getProperty("test.debug") != null) {
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
}
}

testClusters.integTest {
testDistribution = "INTEG_TEST"

// This installs our plugin into the testClusters
plugin(project.tasks.bundlePlugin.archiveFile)
}

run {
useCluster testClusters.integTest
}

// updateVersion: Task to auto update version to the next development iteration
task updateVersion {
onlyIf { System.getProperty('newVersion') }
doLast {
ext.newVersion = System.getProperty('newVersion')
println "Setting version to ${newVersion}."
// String tokenization to support -SNAPSHOT
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}

11 changes: 11 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#

org.gradle.caching=true
org.gradle.warning.mode=none
org.gradle.parallel=true
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
14 changes: 14 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961
Loading

0 comments on commit b481985

Please sign in to comment.