Skip to content

Commit

Permalink
Modify behavior when pass in customized sdk url
Browse files Browse the repository at this point in the history
- add input parameters for get.sh
- use get.sh to get the sdk for customized sdk

Signed-off-by: renfeiw <renfeiw@ca.ibm.com>
  • Loading branch information
renfeiw committed Nov 10, 2021
1 parent 5d8ecaf commit 1ac84a2
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 18 deletions.
10 changes: 8 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 56 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand All @@ -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') &&
Expand All @@ -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 !== '') {
Expand All @@ -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);
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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`];
Expand Down Expand Up @@ -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) {
Expand All @@ -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}`);
}
Expand Down
20 changes: 17 additions & 3 deletions src/aqa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import * as runaqa from './runaqa'
async function run(): Promise<void> {
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})
Expand All @@ -26,10 +30,12 @@ async function run(): Promise<void> {
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}`
)
}

Expand All @@ -44,7 +50,10 @@ async function run(): Promise<void> {
`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.'
)
Expand All @@ -61,9 +70,14 @@ async function run(): Promise<void> {
if (vendorTestShas !== '') {
vendorTestParams += ` --vendor_shas ${vendorTestShas}`
}
if (sdkdir === '') {
sdkdir = process.cwd()
}
await runaqa.runaqaTest(
version,
jdksource,
customizedSdkUrl,
sdkdir,
buildList,
target,
customTarget,
Expand Down
59 changes: 55 additions & 4 deletions src/runaqa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if (!tempDirectory) {
export async function runaqaTest(
version: string,
jdksource: string,
customizedSdkUrl: string,
sdkdir: string,
buildList: string,
target: string,
customTarget: string,
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<void> {
let parameters = ''
if (tkgRepo.length !== 0) {
Expand All @@ -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 {
Expand Down

0 comments on commit 1ac84a2

Please sign in to comment.