From 0b817f405475aaef2df1815472bc539c4bf21361 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 31 Jan 2023 20:07:37 -0800 Subject: [PATCH] Change workflow to keep JDBC repo, but refresh the branch. Update path. Signed-off-by: Yury-Fridlyand --- integ-test/build.gradle | 42 ++++++++++++------- .../org/opensearch/sql/devJdbc/CursorIT.java | 2 +- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/integ-test/build.gradle b/integ-test/build.gradle index ea052eb735..5c8163e301 100644 --- a/integ-test/build.gradle +++ b/integ-test/build.gradle @@ -148,24 +148,35 @@ task stopPrometheus(type: KillProcessTask) { stopPrometheus.mustRunAfter startPrometheus -task deleteJdbcDriverRepo { - // Delete local clone of the sql-jdbc repo - file("sql-jdbc").deleteDir() -} - task cloneJdbcDriverRepo { - doFirst { - file("sql-jdbc").deleteDir() - + if (file("${buildDir}/sql-jdbc").exists()) { exec { - // clone the sql-jdbc repo locally - commandLine 'git', 'clone', '--branch', System.getProperty("jdbcBranch", 'main'), System.getProperty('jdbcRepo', 'https://github.com/opensearch-project/sql-jdbc.git') + workingDir "${buildDir}/sql-jdbc" + commandLine 'git', 'remote', 'remove', 'origin' + } + exec { + workingDir "${buildDir}/sql-jdbc" + commandLine 'git', 'remote', 'add', 'origin', System.getProperty('jdbcRepo', 'https://github.com/opensearch-project/sql-jdbc.git') } - // TODO would fail on windows exec { - workingDir 'sql-jdbc' - commandLine 'sh', 'gradlew', 'shadowJar' + workingDir "${buildDir}/sql-jdbc" + commandLine 'git', 'fetch', 'origin' } + exec { + workingDir "${buildDir}/sql-jdbc" + commandLine 'git', 'reset', '--hard', 'origin/' + System.getProperty("jdbcBranch", 'main') + } + } else { + exec { + workingDir buildDir + // clone the sql-jdbc repo locally + commandLine 'git', 'clone', '--branch', System.getProperty("jdbcBranch", 'main'), System.getProperty('jdbcRepo', 'https://github.com/opensearch-project/sql-jdbc.git') + } + } + // TODO would fail on windows + exec { + workingDir "${buildDir}/sql-jdbc" + commandLine 'sh', 'gradlew', 'shadowJar' } } @@ -213,15 +224,14 @@ task integDevJdbcTest(type: RestIntegTestTask) { } if (System.getProperty("jdbcFile") != null) { - file("sql-jdbc/build/libs").mkdirs() + file("${buildDir}/sql-jdbc/build/libs").mkdirs() copy { from System.getProperty("jdbcFile") - into "sql-jdbc/build/libs" + into "${buildDir}/sql-jdbc/build/libs" } } else { dependsOn cloneJdbcDriverRepo } - finalizedBy deleteJdbcDriverRepo systemProperty 'tests.security.manager', 'false' systemProperty('project.root', project.projectDir.absolutePath) diff --git a/integ-test/src/test/java/org/opensearch/sql/devJdbc/CursorIT.java b/integ-test/src/test/java/org/opensearch/sql/devJdbc/CursorIT.java index afd2e52606..835f032aa0 100644 --- a/integ-test/src/test/java/org/opensearch/sql/devJdbc/CursorIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/devJdbc/CursorIT.java @@ -57,7 +57,7 @@ public void init() { @BeforeClass @SneakyThrows public static void loadDriver() { - var buildDir = String.format("%s/sql-jdbc/build/libs", System.getProperty("project.root")); + var buildDir = String.format("%s/build/sql-jdbc/build/libs", System.getProperty("project.root")); var driverFiles = new File(buildDir). listFiles(pathname -> pathname.getAbsolutePath().endsWith(".jar"));