Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
description: 'Branch or tag to use from smalltalkCI repository'
required: false
default: 'master'
smalltalkCI-workspace:
description: 'Path to install smalltalkCI to'
required: false
outputs:
smalltalk-image:
description: 'Smalltalk image selection'
Expand Down
30 changes: 18 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const tc = __nccwpck_require__(784)
const IS_LINUX = process.platform === 'linux'
const IS_WINDOWS = process.platform === 'win32'

const INSTALLATION_DIRECTORY = path.join(os.homedir(), '.smalltalkCI')
const DEFAULT_WORKSPACE = os.homedir()
const DEFAULT_BRANCH = 'master'
const DEFAULT_SOURCE = 'hpi-swa/smalltalkCI'
const LSB_FILE = '/etc/lsb-release'
Expand Down Expand Up @@ -52,20 +52,23 @@ async function run() {
core.setOutput('smalltalk-image', image)
core.setOutput('smalltalk-version', version)

const smalltalkCIWorkspace = core.getInput('smalltalkCI-workspace') || DEFAULT_WORKSPACE
const smalltalkCIBranch = core.getInput('smalltalkCI-branch') || DEFAULT_BRANCH
const smalltalkCISource = core.getInput('smalltalkCI-source') || DEFAULT_SOURCE

const installationDirectory = path.join(smalltalkCIWorkspace, '.smalltalkCI')
let tempDirectory = path.join(smalltalkCIWorkspace, '.smalltalkCI-temp')

/* Download and extract smalltalkCI. */
console.log('Downloading and extracting smalltalkCI...')
let tempDir = path.join(os.homedir(), '.smalltalkCI-temp')
if (IS_WINDOWS) {
const toolPath = await tc.downloadTool(`https://github.com/${smalltalkCISource}/archive/${smalltalkCIBranch}.zip`)
tempDir = await tc.extractZip(toolPath, tempDir)
tempDirectory = await tc.extractZip(toolPath, tempDirectory)
} else {
const toolPath = await tc.downloadTool(`https://github.com/${smalltalkCISource}/archive/${smalltalkCIBranch}.tar.gz`)
tempDir = await tc.extractTar(toolPath, tempDir)
tempDirectory = await tc.extractTar(toolPath, tempDirectory)
}
await io.mv(path.join(tempDir, `smalltalkCI-${smalltalkCIBranch}`), INSTALLATION_DIRECTORY)
await io.mv(path.join(tempDirectory, `smalltalkCI-${smalltalkCIBranch}`), installationDirectory)

/* Install dependencies if any. */
if (IS_LINUX) {
Expand All @@ -85,16 +88,19 @@ async function run() {
}

/* Set up smalltalkci command. */
core.addPath(path.join(INSTALLATION_DIRECTORY, 'bin'))
core.addPath(path.join(installationDirectory, 'bin'))

let envList
if (!IS_WINDOWS) {
/* Find and export smalltalkCI's env vars. */
const envList = child_process.execSync('smalltalkci --print-env').toString()
for (const envItem of envList.split('\n')) {
const parts = envItem.split('=')
if (parts.length == 2) {
core.exportVariable(parts[0], parts[1])
}
envList = child_process.execSync('smalltalkci --print-env').toString()
} else {
envList = child_process.execSync('bash -l -c ".smalltalkCI/bin/smalltalkci --print-env"').toString()
}
for (const envItem of envList.split('\n')) {
const parts = envItem.split('=')
if (parts.length == 2) {
core.exportVariable(parts[0], parts[1])
}
}
} catch (error) {
Expand Down
30 changes: 18 additions & 12 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const tc = require('@actions/tool-cache')
const IS_LINUX = process.platform === 'linux'
const IS_WINDOWS = process.platform === 'win32'

const INSTALLATION_DIRECTORY = path.join(os.homedir(), '.smalltalkCI')
const DEFAULT_WORKSPACE = os.homedir()
const DEFAULT_BRANCH = 'master'
const DEFAULT_SOURCE = 'hpi-swa/smalltalkCI'
const LSB_FILE = '/etc/lsb-release'
Expand Down Expand Up @@ -45,20 +45,23 @@ async function run() {
core.setOutput('smalltalk-image', image)
core.setOutput('smalltalk-version', version)

const smalltalkCIWorkspace = core.getInput('smalltalkCI-workspace') || DEFAULT_WORKSPACE
const smalltalkCIBranch = core.getInput('smalltalkCI-branch') || DEFAULT_BRANCH
const smalltalkCISource = core.getInput('smalltalkCI-source') || DEFAULT_SOURCE

const installationDirectory = path.join(smalltalkCIWorkspace, '.smalltalkCI')
let tempDirectory = path.join(smalltalkCIWorkspace, '.smalltalkCI-temp')

/* Download and extract smalltalkCI. */
console.log('Downloading and extracting smalltalkCI...')
let tempDir = path.join(os.homedir(), '.smalltalkCI-temp')
if (IS_WINDOWS) {
const toolPath = await tc.downloadTool(`https://github.com/${smalltalkCISource}/archive/${smalltalkCIBranch}.zip`)
tempDir = await tc.extractZip(toolPath, tempDir)
tempDirectory = await tc.extractZip(toolPath, tempDirectory)
} else {
const toolPath = await tc.downloadTool(`https://github.com/${smalltalkCISource}/archive/${smalltalkCIBranch}.tar.gz`)
tempDir = await tc.extractTar(toolPath, tempDir)
tempDirectory = await tc.extractTar(toolPath, tempDirectory)
}
await io.mv(path.join(tempDir, `smalltalkCI-${smalltalkCIBranch}`), INSTALLATION_DIRECTORY)
await io.mv(path.join(tempDirectory, `smalltalkCI-${smalltalkCIBranch}`), installationDirectory)

/* Install dependencies if any. */
if (IS_LINUX) {
Expand All @@ -78,16 +81,19 @@ async function run() {
}

/* Set up smalltalkci command. */
core.addPath(path.join(INSTALLATION_DIRECTORY, 'bin'))
core.addPath(path.join(installationDirectory, 'bin'))

let envList
if (!IS_WINDOWS) {
/* Find and export smalltalkCI's env vars. */
const envList = child_process.execSync('smalltalkci --print-env').toString()
for (const envItem of envList.split('\n')) {
const parts = envItem.split('=')
if (parts.length == 2) {
core.exportVariable(parts[0], parts[1])
}
envList = child_process.execSync('smalltalkci --print-env').toString()
} else {
envList = child_process.execSync('bash -l -c ".smalltalkCI/bin/smalltalkci --print-env"').toString()
}
for (const envItem of envList.split('\n')) {
const parts = envItem.split('=')
if (parts.length == 2) {
core.exportVariable(parts[0], parts[1])
}
}
} catch (error) {
Expand Down