Skip to content

Commit

Permalink
Add two optional parameters so the action's user can choose a differe… (
Browse files Browse the repository at this point in the history
#4)

* Add two optional parameters so the action's user can choose a different fork or branch of smalltalkCI to use.
Fixes #3

* Made code review suggestions

* Minor changes; regenerate index.js

* Adjust descriptions

Co-authored-by: Fabio Niephaus <[email protected]>
  • Loading branch information
gcotelli and fniephaus authored May 12, 2020
1 parent fd75bf3 commit 0cb033f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 11 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,19 @@ jobs:
timeout-minutes: 15
```
### Use a different branch or fork
```yaml
steps:
- uses: actions/checkout@v2
- uses: hpi-swa/setup-smalltalkCI@v1
id: smalltalkci
with:
smalltalk-version: 'Squeak64-trunk'
smalltalkCI-branch: 'testing-branch'
smalltalkCI-source: 'myfork/smalltalkCI'
- run: smalltalkci -s ${{ steps.smalltalkci.outputs.smalltalk-version }}
timeout-minutes: 15
```
[smalltalkCI]: https://github.com/hpi-swa/smalltalkCI
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ inputs:
description: 'Smalltalk image selection (see smalltalkCI''s list of
supported images)'
required: true
smalltalkCI-source:
description: 'GitHub slug of the smalltalkCI source repository'
required: false
default: 'hpi-swa/smalltalkCI'
smalltalkCI-branch:
description: 'Branch or tag to use from smalltalkCI repository'
required: false
default: 'master'
outputs:
smalltalk-version:
description: 'Smalltalk image selection'
Expand Down
13 changes: 8 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,9 @@ const exec = __webpack_require__(986)
const io = __webpack_require__(1)
const tc = __webpack_require__(533)

const SCI_BRANCH = 'master'
const INSTALLATION_DIRECTORY = path.join(os.homedir(), '.smalltalkCI')
const DEFAULT_BRANCH = 'master'
const DEFAULT_SOURCE = 'hpi-swa/smalltalkCI'
const DEFAULT_64BIT_DEPS = 'libpulse0'
const DEFAULT_32BIT_DEPS = 'libc6-i386 libuuid1:i386 libssl1.0.0:i386'
const PHARO_32BIT_DEPS = `${DEFAULT_32BIT_DEPS} libcairo2:i386`
Expand All @@ -983,19 +984,21 @@ async function run() {
try {
const version = core.getInput('smalltalk-version', { required: true })
core.setOutput('smalltalk-version', version)
const smalltalkCIBranch = core.getInput('smalltalkCI-branch') || DEFAULT_BRANCH
const smalltalkCISource = core.getInput('smalltalkCI-source') || DEFAULT_SOURCE

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

/* Install dependencies if any. */
if (isLinux()) {
Expand All @@ -1016,7 +1019,7 @@ async function run() {

/* Set up smalltalkci command. */
core.addPath(path.join(INSTALLATION_DIRECTORY, 'bin'))
}
}
catch (error) {
core.setFailed(error.message)
}
Expand Down
13 changes: 8 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const exec = require('@actions/exec')
const io = require('@actions/io')
const tc = require('@actions/tool-cache')

const SCI_BRANCH = 'master'
const INSTALLATION_DIRECTORY = path.join(os.homedir(), '.smalltalkCI')
const DEFAULT_BRANCH = 'master'
const DEFAULT_SOURCE = 'hpi-swa/smalltalkCI'
const DEFAULT_64BIT_DEPS = 'libpulse0'
const DEFAULT_32BIT_DEPS = 'libc6-i386 libuuid1:i386 libssl1.0.0:i386'
const PHARO_32BIT_DEPS = `${DEFAULT_32BIT_DEPS} libcairo2:i386`
Expand All @@ -17,19 +18,21 @@ async function run() {
try {
const version = core.getInput('smalltalk-version', { required: true })
core.setOutput('smalltalk-version', version)
const smalltalkCIBranch = core.getInput('smalltalkCI-branch') || DEFAULT_BRANCH
const smalltalkCISource = core.getInput('smalltalkCI-source') || DEFAULT_SOURCE

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

/* Install dependencies if any. */
if (isLinux()) {
Expand All @@ -50,7 +53,7 @@ async function run() {

/* Set up smalltalkci command. */
core.addPath(path.join(INSTALLATION_DIRECTORY, 'bin'))
}
}
catch (error) {
core.setFailed(error.message)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "setup-smalltalkCI",
"version": "1.0.0",
"version": "1.1.0",
"description": "This GitHub Action sets up smalltalkCI for testing Smalltalk projects.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 0cb033f

Please sign in to comment.