Skip to content

Commit

Permalink
add yum & alpine based linux support (#91)
Browse files Browse the repository at this point in the history
* add yum based linux support

* add centos 7 tests

* add alpine support

* try doing a different approach
  • Loading branch information
gdams authored Jun 21, 2021
1 parent 8914d53 commit 6fd6868
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 14 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
46 changes: 40 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '';
Expand Down Expand Up @@ -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/*.*
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -3490,17 +3503,38 @@ 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'];
}
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');
}
}
});
}
Expand Down
6 changes: 4 additions & 2 deletions src/aqa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ async function run(): Promise<void> {
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})

Expand Down Expand Up @@ -54,7 +56,7 @@ async function run(): Promise<void> {
vendorTestParams += ` --vendor_dirs ${vendorTestDirs}`
}
if (vendorTestShas !== '') {
vendorTestParams += ` --vendor_shas ${vendorTestShas}`
vendorTestParams += ` --vendor_shas ${vendorTestShas}`
}
await runaqa.runaqaTest(
version,
Expand Down
58 changes: 52 additions & 6 deletions src/runaqa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down Expand Up @@ -150,8 +163,35 @@ async function installDependencyAndSetup(): Promise<void> {
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']
Expand All @@ -161,8 +201,10 @@ async function installDependencyAndSetup(): Promise<void> {
)
}

//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')
}
}
}

Expand All @@ -187,7 +229,11 @@ async function getOpenjdkTestRepo(openjdktestRepo: string): Promise<void> {
process.chdir('aqa-tests')
}

async function runGetSh(tkgRepo: string, openj9Repo: string, vendorTestParams: string): Promise<void> {
async function runGetSh(
tkgRepo: string,
openj9Repo: string,
vendorTestParams: string
): Promise<void> {
let parameters = ''
if (tkgRepo !== 'TKG:master') {
const repoBranch = parseRepoBranch(tkgRepo)
Expand Down

0 comments on commit 6fd6868

Please sign in to comment.