From 6fd68688345b96eedd83b69131559f5e965af289 Mon Sep 17 00:00:00 2001 From: George Adams Date: Mon, 21 Jun 2021 15:27:03 +0100 Subject: [PATCH] add yum & alpine based linux support (#91) * add yum based linux support * add centos 7 tests * add alpine support * try doing a different approach --- .github/workflows/test.yml | 17 +++++++++++ dist/index.js | 46 ++++++++++++++++++++++++++---- src/aqa.ts | 6 ++-- src/runaqa.ts | 58 ++++++++++++++++++++++++++++++++++---- 4 files changed, 113 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7123e94..3dba86d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,23 @@ jobs: jdksource: 'github-hosted' build_list: 'openjdk' target: '_jdk_custom' + openjdk_disto: # make sure build/ci work properly with other distros + runs-on: ubuntu-latest + container: + image: ${{ matrix.image }} + strategy: + fail-fast: false + matrix: + image: [adoptopenjdk/centos7_build_image, adoptopenjdk/alpine3_build_image] + steps: + - uses: actions/checkout@v1 + - name: AQA + uses: ./ + with: + version: '8' + jdksource: 'github-hosted' + build_list: 'openjdk' + target: '_jdk_custom' functional: # make sure build/ci work properly runs-on: ${{ matrix.os }} strategy: diff --git a/dist/index.js b/dist/index.js index 1b13a76..616beea 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2957,7 +2957,9 @@ function run() { const openj9Repo = core.getInput('openj9_repo', { required: false }); const tkgRepo = core.getInput('tkg_Repo', { required: false }); const vendorTestRepos = core.getInput('vendor_testRepos', { required: false }); - const vendorTestBranches = core.getInput('vendor_testBranches', { required: false }); + const vendorTestBranches = core.getInput('vendor_testBranches', { + required: false + }); const vendorTestDirs = core.getInput('vendor_testDirs', { required: false }); const vendorTestShas = core.getInput('vendor_testShas', { required: false }); let vendorTestParams = ''; @@ -3402,8 +3404,12 @@ function runaqaTest(version, jdksource, buildList, target, customTarget, openjdk yield runGetSh(tkgRepo, openj9Repo, vendorTestParams); //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'; + if (fs.existsSync('/usr/bin/yum')) { + sevenzexe = '7za'; + } // Test.dependency only has one level of archive directory, none of actions toolkit support mv files by regex. Using 7zip discards the directory directly - yield exec.exec(`7z e ${dependents} -o${process.env.GITHUB_WORKSPACE}/aqa-tests/TKG/lib`); + yield exec.exec(`${sevenzexe} e ${dependents} -o${process.env.GITHUB_WORKSPACE}/aqa-tests/TKG/lib`); if (buildList.includes('system')) { dependents = yield tc.downloadTool('https://ci.adoptopenjdk.net/view/all/job/systemtest.getDependency/lastSuccessfulBuild/artifact/*zip*/dependents.zip'); // System.dependency has different levels of archive structures archive/systemtest_prereqs/*.* @@ -3442,7 +3448,11 @@ function runaqaTest(version, jdksource, buildList, target, customTarget, openjdk } exports.runaqaTest = runaqaTest; 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`]; + if (javaHome === undefined) { + javaHome = process.env['JAVA_HOME']; + } if (jdksource === 'install-jdk') { // work with AdoptOpenJDK/install-sdk if (`JDK_${version}` in process.env) { @@ -3456,6 +3466,9 @@ function getTestJdkHome(version, jdksource) { if (IS_WINDOWS && jdksource === 'github-hosted') { javaHome = javaHome.replace(/Program Files/g, 'Progra~1'); } + if (javaHome === undefined) { + core.error('JDK could not be found'); + } return javaHome; } // This function is an alternative of extra install step in workflow or alternative install action. This could also be implemented as github action @@ -3490,8 +3503,27 @@ function installDependencyAndSetup() { yield exec.exec('sudo sysctl -w kern.sysv.shmmax=125839605760'); } else { - yield exec.exec('sudo apt-get update'); - yield exec.exec('sudo apt-get install ant-contrib -y'); + if (fs.existsSync('/usr/bin/apt-get')) { + // Debian Based + yield exec.exec('sudo apt-get update'); + yield exec.exec('sudo apt-get install ant-contrib -y'); + } + else if (fs.existsSync('/usr/bin/yum')) { + // RPM Based + yield exec.exec('sudo yum update -y'); + yield exec.exec('sudo yum install p7zip -y'); + const antContribFile = yield tc.downloadTool(`https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.zip/download`); + yield tc.extractZip(`${antContribFile}`, `${tempDirectory}`); + yield io.cp(`${tempDirectory}/ant-contrib/lib/ant-contrib.jar`, `${process.env.ANT_HOME}\\lib`); + } + else if (fs.existsSync('/sbin/apk')) { + // Alpine Based + yield exec.exec('apk update'); + yield exec.exec('apk add p7zip'); + const antContribFile = yield tc.downloadTool(`https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.zip/download`); + yield tc.extractZip(`${antContribFile}`, `${tempDirectory}`); + yield io.cp(`${tempDirectory}/ant-contrib/lib/ant-contrib.jar`, `${process.env.ANT_HOME}\\lib`); + } //environment if ('RUNNER_USER' in process.env) { process.env['LOGNAME'] = process.env['RUNNER_USER']; @@ -3499,8 +3531,10 @@ function installDependencyAndSetup() { else { core.warning('RUNNER_USER is not the GitHub Actions environment variables shell script. Container is configured differently. Please check the updated lists of environment variables.'); } - //disable apport - yield exec.exec('sudo service apport stop'); + if (fs.existsSync('/usr/bin/apt-get')) { + //disable apport + yield exec.exec('sudo service apport stop'); + } } }); } diff --git a/src/aqa.ts b/src/aqa.ts index 6693372..c28aa7a 100644 --- a/src/aqa.ts +++ b/src/aqa.ts @@ -12,7 +12,9 @@ async function run(): Promise { const openj9Repo = core.getInput('openj9_repo', {required: false}) const tkgRepo = core.getInput('tkg_Repo', {required: false}) const vendorTestRepos = core.getInput('vendor_testRepos', {required: false}) - const vendorTestBranches = core.getInput('vendor_testBranches', {required: false}) + const vendorTestBranches = core.getInput('vendor_testBranches', { + required: false + }) const vendorTestDirs = core.getInput('vendor_testDirs', {required: false}) const vendorTestShas = core.getInput('vendor_testShas', {required: false}) @@ -54,7 +56,7 @@ async function run(): Promise { vendorTestParams += ` --vendor_dirs ${vendorTestDirs}` } if (vendorTestShas !== '') { - vendorTestParams += ` --vendor_shas ${vendorTestShas}` + vendorTestParams += ` --vendor_shas ${vendorTestShas}` } await runaqa.runaqaTest( version, diff --git a/src/runaqa.ts b/src/runaqa.ts index 5eabc47..ecb6e33 100644 --- a/src/runaqa.ts +++ b/src/runaqa.ts @@ -47,9 +47,15 @@ export async function runaqaTest( let dependents = await tc.downloadTool( 'https://ci.adoptopenjdk.net/view/all/job/test.getDependency/lastSuccessfulBuild/artifact//*zip*/dependents.zip' ) + + let sevenzexe = '7z' + if (fs.existsSync('/usr/bin/yum')) { + sevenzexe = '7za' + } + // Test.dependency only has one level of archive directory, none of actions toolkit support mv files by regex. Using 7zip discards the directory directly await exec.exec( - `7z e ${dependents} -o${process.env.GITHUB_WORKSPACE}/aqa-tests/TKG/lib` + `${sevenzexe} e ${dependents} -o${process.env.GITHUB_WORKSPACE}/aqa-tests/TKG/lib` ) if (buildList.includes('system')) { @@ -96,7 +102,11 @@ export async function runaqaTest( } 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 + if (javaHome === undefined) { + javaHome = process.env['JAVA_HOME'] as string + } if (jdksource === 'install-jdk') { // work with AdoptOpenJDK/install-sdk if (`JDK_${version}` in process.env) { @@ -109,6 +119,9 @@ function getTestJdkHome(version: string, jdksource: string): string { if (IS_WINDOWS && jdksource === 'github-hosted') { javaHome = javaHome.replace(/Program Files/g, 'Progra~1') } + if (javaHome === undefined) { + core.error('JDK could not be found') + } return javaHome } @@ -150,8 +163,35 @@ async function installDependencyAndSetup(): Promise { await exec.exec('sudo sysctl -w kern.sysv.shmall=655360') await exec.exec('sudo sysctl -w kern.sysv.shmmax=125839605760') } else { - await exec.exec('sudo apt-get update') - await exec.exec('sudo apt-get install ant-contrib -y') + if (fs.existsSync('/usr/bin/apt-get')) { + // Debian Based + await exec.exec('sudo apt-get update') + await exec.exec('sudo apt-get install ant-contrib -y') + } else if (fs.existsSync('/usr/bin/yum')) { + // RPM Based + await exec.exec('sudo yum update -y') + await exec.exec('sudo yum install p7zip -y') + const antContribFile = await tc.downloadTool( + `https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.zip/download` + ) + await tc.extractZip(`${antContribFile}`, `${tempDirectory}`) + await io.cp( + `${tempDirectory}/ant-contrib/lib/ant-contrib.jar`, + `${process.env.ANT_HOME}\\lib` + ) + } else if (fs.existsSync('/sbin/apk')) { + // Alpine Based + await exec.exec('apk update') + await exec.exec('apk add p7zip') + const antContribFile = await tc.downloadTool( + `https://sourceforge.net/projects/ant-contrib/files/ant-contrib/ant-contrib-1.0b2/ant-contrib-1.0b2-bin.zip/download` + ) + await tc.extractZip(`${antContribFile}`, `${tempDirectory}`) + await io.cp( + `${tempDirectory}/ant-contrib/lib/ant-contrib.jar`, + `${process.env.ANT_HOME}\\lib` + ) + } //environment if ('RUNNER_USER' in process.env) { process.env['LOGNAME'] = process.env['RUNNER_USER'] @@ -161,8 +201,10 @@ async function installDependencyAndSetup(): Promise { ) } - //disable apport - await exec.exec('sudo service apport stop') + if (fs.existsSync('/usr/bin/apt-get')) { + //disable apport + await exec.exec('sudo service apport stop') + } } } @@ -187,7 +229,11 @@ async function getOpenjdkTestRepo(openjdktestRepo: string): Promise { process.chdir('aqa-tests') } -async function runGetSh(tkgRepo: string, openj9Repo: string, vendorTestParams: string): Promise { +async function runGetSh( + tkgRepo: string, + openj9Repo: string, + vendorTestParams: string +): Promise { let parameters = '' if (tkgRepo !== 'TKG:master') { const repoBranch = parseRepoBranch(tkgRepo)