diff --git a/action.yml b/action.yml index 872ff56..a8b9041 100644 --- a/action.yml +++ b/action.yml @@ -2,9 +2,15 @@ name: 'Running AQA test' description: 'Running AQA test' author: 'Sophia Guo' inputs: - jdksource: # AdoptOpenJDK/install-jdk, github-hosted environment, upstream - description: 'github-hosted default or customized' + jdksource: # upstream, github-hosted, install-jdk, nightly, customized + description: 'upstream, github-hosted, install-jdk, nightly, customized' default: 'upstream' + customizedSdkUrl: + description: 'if jdksource is nightly or customized, this is the url for customized sdk' + required: false + sdkdir: + description: 'if jdksource is nightly or customized, please provide preferred directory to store sdk' + required: false version: # jdk version description: 'testing jdk version (Required when jdksource is github-hosted or install-jdk.)' required: false diff --git a/dist/index.js b/dist/index.js index e3387f8..2b12e1e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2949,12 +2949,18 @@ function run() { return __awaiter(this, void 0, void 0, function* () { try { const jdksource = core.getInput('jdksource', { required: false }); + const customizedSdkUrl = core.getInput('customizedSdkUrl', { + required: false + }); + let sdkdir = core.getInput('sdkdir', { required: false }); const version = core.getInput('version', { required: false }); const buildList = core.getInput('build_list', { required: false }); const target = core.getInput('target', { required: false }); const customTarget = core.getInput('custom_target', { required: false }); const aqatestsRepo = core.getInput('aqa-testsRepo', { required: false }); - const aqasystemtestsRepo = core.getInput('aqa-systemtestsRepo', { required: false }); + const aqasystemtestsRepo = core.getInput('aqa-systemtestsRepo', { + required: false + }); const openj9Repo = core.getInput('openj9_repo', { required: false }); const tkgRepo = core.getInput('tkg_Repo', { required: false }); const vendorTestRepos = core.getInput('vendor_testRepos', { required: false }); @@ -2967,8 +2973,10 @@ function run() { // let arch = core.getInput("architecture", { required: false }) if (jdksource !== 'upstream' && jdksource !== 'github-hosted' && - jdksource !== 'install-jdk') { - core.error(`jdksource should be one of [upstream, github-hosted, install-jdk]. Found: ${jdksource}`); + jdksource !== 'install-jdk' && + jdksource !== 'nightly' && + jdksource !== 'customized') { + core.error(`jdksource should be one of [upstream, github-hosted, install-jdk, nightly, customized]. Found: ${jdksource}`); } if (buildList !== 'openjdk' && !buildList.startsWith('external') && @@ -2977,7 +2985,8 @@ function run() { !buildList.startsWith('system')) { core.setFailed(`buildList should be one of or sub dir of [openjdk, external, functional, system, perf]. Found: ${buildList}`); } - if (jdksource !== 'upstream' && version.length === 0) { + if ((jdksource === 'github-hosted' || jdksource === 'install-jdk') && + version.length === 0) { core.setFailed('Please provide jdkversion if jdksource is github-hosted installed or AdoptOpenJKD/install-jdk installed.'); } if (vendorTestRepos !== '') { @@ -2992,7 +3001,10 @@ function run() { if (vendorTestShas !== '') { vendorTestParams += ` --vendor_shas ${vendorTestShas}`; } - yield runaqa.runaqaTest(version, jdksource, buildList, target, customTarget, aqatestsRepo, openj9Repo, tkgRepo, vendorTestParams, aqasystemtestsRepo); + if (sdkdir === '') { + sdkdir = process.cwd(); + } + yield runaqa.runaqaTest(version, jdksource, customizedSdkUrl, sdkdir, buildList, target, customTarget, aqatestsRepo, openj9Repo, tkgRepo, vendorTestParams, aqasystemtestsRepo); } catch (error) { core.setFailed(error.message); @@ -3394,15 +3406,23 @@ if (!tempDirectory) { } tempDirectory = path.join(baseLocation, 'actions', 'temp'); } -function runaqaTest(version, jdksource, buildList, target, customTarget, aqatestsRepo, openj9Repo, tkgRepo, vendorTestParams, aqasystemtestsRepo) { +function runaqaTest(version, jdksource, customizedSdkUrl, sdkdir, buildList, target, customTarget, aqatestsRepo, openj9Repo, tkgRepo, vendorTestParams, aqasystemtestsRepo) { return __awaiter(this, void 0, void 0, function* () { yield installDependencyAndSetup(); setSpec(); process.env.BUILD_LIST = buildList; - if (!('TEST_JDK_HOME' in process.env)) + if ((jdksource === 'upstream' || + jdksource === 'github-hosted' || + jdksource === 'install-jdk') && + !('TEST_JDK_HOME' in process.env)) { process.env.TEST_JDK_HOME = getTestJdkHome(version, jdksource); + } + if (!('TEST_JDK_HOME' in process.env)) { + process.env.TEST_JDK_HOME = `${sdkdir}/openjdkbinary/j2sdk-image`; + } yield getAqaTestsRepo(aqatestsRepo); - yield runGetSh(tkgRepo, openj9Repo, vendorTestParams); + yield runGetSh(tkgRepo, openj9Repo, vendorTestParams, jdksource, customizedSdkUrl, sdkdir); + resetJDKHomeFromProperties(); //Get Dependencies, using /*zip*/dependents.zip to avoid loop every available files let dependents = yield tc.downloadTool('https://ci.adoptopenjdk.net/view/all/job/test.getDependency/lastSuccessfulBuild/artifact//*zip*/dependents.zip'); let sevenzexe = '7z'; @@ -3451,6 +3471,24 @@ function runaqaTest(version, jdksource, buildList, target, customTarget, aqatest }); } exports.runaqaTest = runaqaTest; +function resetJDKHomeFromProperties() { + const pfile = `${process.env.GITHUB_WORKSPACE}/aqa-tests/job.properties`; + if (fs.existsSync(pfile)) { + const lines = fs + .readFileSync(pfile, 'utf-8') + .replace(/\r\n/g, '\n') + .split('\n') + .filter(Boolean); + for (const l of lines) { + const regexp = /TEST_JDK_HOME=(.*)/; + const match = regexp.exec(l); + if (match && match[1]) { + process.env.TEST_JDK_HOME = match[1]; + core.info(`Reset TEST_JDK_HOME from ${process.env.TEST_JDK_HOME}`); + } + } + } +} function getTestJdkHome(version, jdksource) { // Try JAVA_HOME first and then fall back to GITHUB actions default location let javaHome = process.env[`JAVA_HOME_${version}_X64`]; @@ -3568,7 +3606,7 @@ function getAqaSystemTestsRepo(aqasystemtestsRepo) { process.env.ADOPTOPENJDK_SYSTEMTEST_REPO = repoBranch[0]; process.env.ADOPTOPENJDK_SYSTEMTEST_BRANCH = repoBranch[1]; } -function runGetSh(tkgRepo, openj9Repo, vendorTestParams) { +function runGetSh(tkgRepo, openj9Repo, vendorTestParams, jdksource, customizedSdkUrl, sdkdir) { return __awaiter(this, void 0, void 0, function* () { let parameters = ''; if (tkgRepo.length !== 0) { @@ -3579,6 +3617,15 @@ function runGetSh(tkgRepo, openj9Repo, vendorTestParams) { const repoBranch = parseRepoBranch(openj9Repo); parameters += ` --openj9_branch ${repoBranch[1]} --openj9_repo https://github.com/${repoBranch[0]}.git`; } + if (jdksource.length !== 0) { + parameters += ` --sdk_resource ${jdksource}`; + } + if (customizedSdkUrl.length !== 0) { + parameters += ` --customizedURL ${customizedSdkUrl}`; + } + if (sdkdir.length !== 0) { + parameters += ` --sdkdir ${sdkdir}`; + } if (IS_WINDOWS) { yield exec.exec(`bash ./get.sh ${parameters} ${vendorTestParams}`); } diff --git a/src/aqa.ts b/src/aqa.ts index 3da6256..c4d2f07 100644 --- a/src/aqa.ts +++ b/src/aqa.ts @@ -4,6 +4,10 @@ import * as runaqa from './runaqa' async function run(): Promise { try { const jdksource = core.getInput('jdksource', {required: false}) + const customizedSdkUrl = core.getInput('customizedSdkUrl', { + required: false + }) + let sdkdir = core.getInput('sdkdir', {required: false}) const version = core.getInput('version', {required: false}) const buildList = core.getInput('build_list', {required: false}) const target = core.getInput('target', {required: false}) @@ -26,10 +30,12 @@ async function run(): Promise { if ( jdksource !== 'upstream' && jdksource !== 'github-hosted' && - jdksource !== 'install-jdk' + jdksource !== 'install-jdk' && + jdksource !== 'nightly' && + jdksource !== 'customized' ) { core.error( - `jdksource should be one of [upstream, github-hosted, install-jdk]. Found: ${jdksource}` + `jdksource should be one of [upstream, github-hosted, install-jdk, nightly, customized]. Found: ${jdksource}` ) } @@ -44,7 +50,10 @@ async function run(): Promise { `buildList should be one of or sub dir of [openjdk, external, functional, system, perf]. Found: ${buildList}` ) } - if (jdksource !== 'upstream' && version.length === 0) { + if ( + (jdksource === 'github-hosted' || jdksource === 'install-jdk') && + version.length === 0 + ) { core.setFailed( 'Please provide jdkversion if jdksource is github-hosted installed or AdoptOpenJKD/install-jdk installed.' ) @@ -61,9 +70,14 @@ async function run(): Promise { if (vendorTestShas !== '') { vendorTestParams += ` --vendor_shas ${vendorTestShas}` } + if (sdkdir === '') { + sdkdir = process.cwd() + } await runaqa.runaqaTest( version, jdksource, + customizedSdkUrl, + sdkdir, buildList, target, customTarget, diff --git a/src/runaqa.ts b/src/runaqa.ts index 18a1df4..70690b7 100644 --- a/src/runaqa.ts +++ b/src/runaqa.ts @@ -26,6 +26,8 @@ if (!tempDirectory) { export async function runaqaTest( version: string, jdksource: string, + customizedSdkUrl: string, + sdkdir: string, buildList: string, target: string, customTarget: string, @@ -38,11 +40,30 @@ export async function runaqaTest( await installDependencyAndSetup() setSpec() process.env.BUILD_LIST = buildList - if (!('TEST_JDK_HOME' in process.env)) + if ( + (jdksource === 'upstream' || + jdksource === 'github-hosted' || + jdksource === 'install-jdk') && + !('TEST_JDK_HOME' in process.env) + ) { process.env.TEST_JDK_HOME = getTestJdkHome(version, jdksource) + } + + if (!('TEST_JDK_HOME' in process.env)) { + process.env.TEST_JDK_HOME = `${sdkdir}/openjdkbinary/j2sdk-image` + } await getAqaTestsRepo(aqatestsRepo) - await runGetSh(tkgRepo, openj9Repo, vendorTestParams) + await runGetSh( + tkgRepo, + openj9Repo, + vendorTestParams, + jdksource, + customizedSdkUrl, + sdkdir + ) + + resetJDKHomeFromProperties() //Get Dependencies, using /*zip*/dependents.zip to avoid loop every available files let dependents = await tc.downloadTool( @@ -105,6 +126,25 @@ export async function runaqaTest( } } +function resetJDKHomeFromProperties(): void { + const pfile = `${process.env.GITHUB_WORKSPACE}/aqa-tests/job.properties` + if (fs.existsSync(pfile)) { + const lines = fs + .readFileSync(pfile, 'utf-8') + .replace(/\r\n/g, '\n') + .split('\n') + .filter(Boolean) + for (const l of lines) { + const regexp = /TEST_JDK_HOME=(.*)/ + const match = regexp.exec(l) + if (match && match[1]) { + process.env.TEST_JDK_HOME = match[1] + core.info(`Reset TEST_JDK_HOME to ${process.env.TEST_JDK_HOME}`) + } + } + } +} + function getTestJdkHome(version: string, jdksource: string): string { // Try JAVA_HOME first and then fall back to GITHUB actions default location let javaHome = process.env[`JAVA_HOME_${version}_X64`] as string @@ -242,7 +282,10 @@ function getAqaSystemTestsRepo(aqasystemtestsRepo: string): void { async function runGetSh( tkgRepo: string, openj9Repo: string, - vendorTestParams: string + vendorTestParams: string, + jdksource: string, + customizedSdkUrl: string, + sdkdir: string ): Promise { let parameters = '' if (tkgRepo.length !== 0) { @@ -253,7 +296,15 @@ async function runGetSh( const repoBranch = parseRepoBranch(openj9Repo) parameters += ` --openj9_branch ${repoBranch[1]} --openj9_repo https://github.com/${repoBranch[0]}.git` } - + if (jdksource.length !== 0) { + parameters += ` --sdk_resource ${jdksource}` + } + if (customizedSdkUrl.length !== 0) { + parameters += ` --customizedURL ${customizedSdkUrl}` + } + if (sdkdir.length !== 0) { + parameters += ` --sdkdir ${sdkdir}` + } if (IS_WINDOWS) { await exec.exec(`bash ./get.sh ${parameters} ${vendorTestParams}`) } else {