forked from hpi-swa/setup-smalltalkCI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
106 lines (87 loc) · 2.93 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
const os = require('os')
const path = require('path')
const core = require('@actions/core')
const exec = require('@actions/exec')
const io = require('@actions/io')
const tc = require('@actions/tool-cache')
const SCI_REPO_URL = 'https://github.com/ba-st-dependencies/smalltalkCI'
const SCI_BRANCH = '2.9.4'
const INSTALLATION_DIRECTORY = path.join(os.homedir(), '.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`
async function run() {
try {
const version = core.getInput('smalltalk-version', { required: true })
core.setOutput('smalltalk-version', version)
/* 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(`${SCI_REPO_URL}/archive/${SCI_BRANCH}.zip`)
tempDir = await tc.extractZip(toolPath, tempDir)
}
else {
const toolPath = await tc.downloadTool(`${SCI_REPO_URL}/archive/${SCI_BRANCH}.tar.gz`)
tempDir = await tc.extractTar(toolPath, tempDir)
}
await io.mv(path.join(tempDir, `smalltalkCI-${SCI_BRANCH}`), INSTALLATION_DIRECTORY)
/* Install dependencies if any. */
if (isLinux()) {
if (is64bit(version)) {
if (isSqueak(version) || isEtoys(version)) {
install64bitDependencies(DEFAULT_64BIT_DEPS)
}
} else {
if (isSqueak(version) || isEtoys(version)) {
await install32bitDependencies(DEFAULT_32BIT_DEPS)
} else if (isPharo(version) || isMoose(version)) {
await install32bitDependencies(PHARO_32BIT_DEPS)
} else if (isGemstone(version)) {
// TODO
}
}
}
/* Set up smalltalkci command. */
core.addPath(path.join(INSTALLATION_DIRECTORY, 'bin'))
}
catch (error) {
core.setFailed(error.message)
}
}
async function install64bitDependencies(deps) {
await exec.exec(`sudo apt-get install -qq --no-install-recommends ${deps}`)
}
async function install32bitDependencies(deps) {
await exec.exec('sudo dpkg --add-architecture i386')
await exec.exec('sudo apt-get update')
await exec.exec(`sudo apt-get install -qq --no-install-recommends ${deps}`)
}
function isLinux() {
return process.platform === 'linux'
}
function isWindows() {
return process.platform === 'win32'
}
function is64bit(version) {
return /^[a-zA-Z]*64-/.test(version)
}
function isSqueak(version) {
return isPlatform(version, 'squeak')
}
function isEtoys(version) {
return isPlatform(version, 'etoys')
}
function isPharo(version) {
return isPlatform(version, 'pharo')
}
function isMoose(version) {
return isPlatform(version, 'moose')
}
function isGemstone(version) {
return isPlatform(version, 'gemstone')
}
function isPlatform(version, name) {
return version.toLowerCase().startsWith(name)
}
run()