Skip to content

Commit b8f037a

Browse files
authored
Merge pull request #4 from ansjcy/setup-gradle-for-plugin
Set up gradle and CI for query insights
2 parents c952cbc + b481985 commit b8f037a

File tree

26 files changed

+682
-60
lines changed

26 files changed

+682
-60
lines changed

.github/workflows/ci.yml

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Build and Test
2+
on:
3+
push:
4+
branches:
5+
- "*"
6+
pull_request:
7+
branches:
8+
- "*"
9+
jobs:
10+
Get-CI-Image-Tag:
11+
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
12+
with:
13+
product: opensearch
14+
15+
build-linux:
16+
needs: Get-CI-Image-Tag
17+
strategy:
18+
matrix:
19+
java: [11, 17, 21]
20+
os: [ ubuntu-latest ]
21+
name: Build and Test query-insights plugin with JDK ${{ matrix.java }} on ${{ matrix.os }}
22+
runs-on: ${{ matrix.os }}
23+
container:
24+
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
25+
# this image tag is subject to change as more dependencies and updates will arrive over time
26+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
27+
# need to switch to root so that github actions can install runner binary on container without permission issues.
28+
options: --user root
29+
30+
steps:
31+
# This step uses the checkout Github action: https://github.com/actions/checkout
32+
- name: Checkout Branch
33+
uses: actions/checkout@v2
34+
35+
# This step uses the setup-java Github action: https://github.com/actions/setup-java
36+
- name: Setup Java ${{ matrix.java }}
37+
uses: actions/setup-java@v1
38+
with:
39+
java-version: ${{ matrix.java }}
40+
41+
- name: Build and Test
42+
run: |
43+
chown -R 1000:1000 `pwd`
44+
su `id -un 1000` -c "java -version && ./gradlew build"
45+
plugin=`basename $(ls build/distributions/*.zip)`
46+
echo plugin $plugin
47+
48+
- name: Create Artifact Path
49+
run: |
50+
mkdir -p query-insights-artifacts
51+
cp ./build/distributions/*.zip query-insights-artifacts
52+
53+
- name: Upload Coverage Report
54+
uses: codecov/codecov-action@v1
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}
57+
58+
- name: Upload failed logs
59+
uses: actions/upload-artifact@v2
60+
if: failure()
61+
with:
62+
name: logs-ubuntu
63+
path: build/testclusters/integTest-*/logs/*
64+
65+
- name: Upload Artifacts
66+
uses: actions/upload-artifact@v1
67+
with:
68+
name: query-insights-plugin-${{ matrix.os }}
69+
path: query-insights-artifacts
70+
71+
build-windows-macos:
72+
env:
73+
BUILD_ARGS: ${{ matrix.os_build_args }}
74+
WORKING_DIR: ${{ matrix.working_directory }}.
75+
strategy:
76+
matrix:
77+
java: [11, 17]
78+
os: [ windows-latest, macos-latest ]
79+
include:
80+
- os: windows-latest
81+
os_build_args: -x integTest
82+
working_directory: X:\
83+
os_java_options: -Xmx4096M
84+
- os: macos-latest
85+
os_build_args: -x jacocoTestReport
86+
87+
name: Build and Test query-insights plugin with JDK ${{ matrix.java }} on ${{ matrix.os }}
88+
runs-on: ${{ matrix.os }}
89+
90+
steps:
91+
- name: Checkout Branch
92+
uses: actions/checkout@v2
93+
94+
# This is a hack, but this step creates a link to the X: mounted drive, which makes the path
95+
# short enough to work on Windows
96+
- name: Shorten Path
97+
if: ${{ matrix.os == 'windows-latest' }}
98+
run: subst 'X:' .
99+
100+
- name: Setup Java ${{ matrix.java }}
101+
uses: actions/setup-java@v1
102+
with:
103+
java-version: ${{ matrix.java }}
104+
105+
- name: Build and Test
106+
working-directory: ${{ env.WORKING_DIR }}
107+
run: ./gradlew build ${{ env.BUILD_ARGS }}
108+
env:
109+
_JAVA_OPTIONS: ${{ matrix.os_java_options }}
110+
111+
- name: Create Artifact Path
112+
run: |
113+
mkdir -p query-insights-artifacts
114+
cp ./build/distributions/*.zip query-insights-artifacts
115+
116+
- name: Upload failed logs
117+
uses: actions/upload-artifact@v2
118+
if: ${{ failure() && matrix.os == 'macos-latest' }}
119+
with:
120+
name: logs-mac
121+
path: build/testclusters/integTest-*/logs/*
122+
123+
- name: Upload failed logs
124+
uses: actions/upload-artifact@v2
125+
if: ${{ failure() && matrix.os == 'windows-latest' }}
126+
with:
127+
name: logs-windows
128+
path: build\testclusters\integTest-*\logs\*
129+
130+
- name: Upload Artifacts
131+
uses: actions/upload-artifact@v1
132+
with:
133+
name: query-insights-plugin-${{ matrix.os }}
134+
path: query-insights-artifacts

COMMUNICATIONS.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# OpenSearch Project Communication
22

3-
- [Overview](#overview)
4-
- [Slack](#slack)
5-
- [Getting Started](#getting-started)
6-
- [Workspace Channels](#workspace-channels)
7-
- [Tips](#tips)
3+
- [OpenSearch Project Communication](#opensearch-project-communication)
4+
- [Overview](#overview)
5+
- [Slack](#slack)
6+
- [Getting Started](#getting-started)
7+
- [Workspace Channels](#workspace-channels)
8+
- [Tips](#tips)
89

910
## Overview
1011

NOTICE NOTICE.txt

File renamed without changes.

build.gradle

+111-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,116 @@
1-
/*
2-
* SPDX-License-Identifier: Apache-2.0
3-
*
4-
* The OpenSearch Contributors require contributions made to
5-
* this file be licensed under the Apache-2.0 license or a
6-
* compatible open source license.
7-
*
8-
* Modifications Copyright OpenSearch Contributors. See
9-
* GitHub history for details.
10-
*/
1+
import org.opensearch.gradle.test.RestIntegTestTask
2+
3+
apply plugin: 'java'
4+
apply plugin: 'idea'
5+
apply plugin: 'eclipse'
6+
apply plugin: 'opensearch.opensearchplugin'
7+
apply plugin: 'opensearch.pluginzip'
8+
9+
def pluginName = 'query-insights'
10+
def pluginDescription = 'OpenSearch Query Insights plugin'
11+
def projectPath = 'org.opensearch'
12+
def pathToPlugin = 'plugin.insights'
13+
def pluginClassName = 'QueryInsightsPlugin'
14+
15+
publishing {
16+
publications {
17+
pluginZip(MavenPublication) { publication ->
18+
pom {
19+
name = pluginName
20+
description = pluginDescription
21+
groupId = "org.opensearch.plugin"
22+
licenses {
23+
license {
24+
name = "The Apache License, Version 2.0"
25+
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
26+
}
27+
}
28+
developers {
29+
developer {
30+
name = "OpenSearch"
31+
url = "https://github.com/opensearch-project/opensearch-plugin-template-java"
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
1138

1239
opensearchplugin {
13-
description 'OpenSearch Query Insights Plugin.'
14-
classname 'org.opensearch.plugin.insights.QueryInsightsPlugin'
40+
name pluginName
41+
description pluginDescription
42+
classname "${projectPath}.${pathToPlugin}.${pluginClassName}"
43+
licenseFile rootProject.file('LICENSE.txt')
44+
noticeFile rootProject.file('NOTICE.txt')
45+
}
46+
47+
// This requires an additional Jar not published as part of build-tools
48+
loggerUsageCheck.enabled = false
49+
50+
// No need to validate pom, as we do not upload to maven/sonatype
51+
validateNebulaPom.enabled = false
52+
53+
buildscript {
54+
ext {
55+
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
56+
}
57+
58+
repositories {
59+
mavenLocal()
60+
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
61+
mavenCentral()
62+
maven { url "https://plugins.gradle.org/m2/" }
63+
}
64+
65+
dependencies {
66+
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
67+
}
68+
}
69+
70+
repositories {
71+
mavenLocal()
72+
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
73+
mavenCentral()
74+
maven { url "https://plugins.gradle.org/m2/" }
1575
}
1676

17-
dependencies {
77+
test {
78+
include '**/*Tests.class'
1879
}
80+
81+
task integTest(type: RestIntegTestTask) {
82+
description = "Run tests against a cluster"
83+
testClassesDirs = sourceSets.test.output.classesDirs
84+
classpath = sourceSets.test.runtimeClasspath
85+
}
86+
tasks.named("check").configure { dependsOn(integTest) }
87+
88+
integTest {
89+
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
90+
if (System.getProperty("test.debug") != null) {
91+
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
92+
}
93+
}
94+
95+
testClusters.integTest {
96+
testDistribution = "INTEG_TEST"
97+
98+
// This installs our plugin into the testClusters
99+
plugin(project.tasks.bundlePlugin.archiveFile)
100+
}
101+
102+
run {
103+
useCluster testClusters.integTest
104+
}
105+
106+
// updateVersion: Task to auto update version to the next development iteration
107+
task updateVersion {
108+
onlyIf { System.getProperty('newVersion') }
109+
doLast {
110+
ext.newVersion = System.getProperty('newVersion')
111+
println "Setting version to ${newVersion}."
112+
// String tokenization to support -SNAPSHOT
113+
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
114+
}
115+
}
116+

gradle.properties

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# The OpenSearch Contributors require contributions made to
5+
# this file be licensed under the Apache-2.0 license or a
6+
# compatible open source license.
7+
#
8+
9+
org.gradle.caching=true
10+
org.gradle.warning.mode=none
11+
org.gradle.parallel=true

gradle/wrapper/gradle-wrapper.jar

42.4 KB
Binary file not shown.
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# SPDX-License-Identifier: Apache-2.0
3+
#
4+
# The OpenSearch Contributors require contributions made to
5+
# this file be licensed under the Apache-2.0 license or a
6+
# compatible open source license.
7+
#
8+
9+
distributionBase=GRADLE_USER_HOME
10+
distributionPath=wrapper/dists
11+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-all.zip
12+
zipStoreBase=GRADLE_USER_HOME
13+
zipStorePath=wrapper/dists
14+
distributionSha256Sum=f8b4f4772d302c8ff580bc40d0f56e715de69b163546944f787c87abf209c961

0 commit comments

Comments
 (0)