Fix alpine container installation (#189)

* Change test tool for future alpine CI testing

* replace node with jq as it doesnt require any build on alpine

* Fix alpine musl container install

* add tests around mise install in alpine container

* add support for musl os
Fixes: https://github.com/jdx/mise-action/issues/186

* alpine needs bash to run test.sh script

* remove unneeded logs

* Update test.yml

* Update test.yml
This commit is contained in:
Victor LEFEBVRE 2025-05-12 14:15:17 +02:00 committed by GitHub
parent d20b46e041
commit 923c9f44ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 86 additions and 42 deletions

View file

@ -93,7 +93,7 @@ async function restoreMiseCache(): Promise<string | undefined> {
].join('\n')
)
const prefix = core.getInput('cache_key_prefix') || 'mise-v0'
let primaryKey = `${prefix}-${getOS()}-${os.arch()}-${fileHash}`
let primaryKey = `${prefix}-${await getTarget()}-${fileHash}`
if (version) {
primaryKey = `${primaryKey}-${version}`
}
@ -127,13 +127,13 @@ async function setupMise(version: string): Promise<void> {
const miseBinDir = path.join(miseDir(), 'bin')
const miseBinPath = path.join(
miseBinDir,
getOS() === 'windows' ? 'mise.exe' : 'mise'
process.platform === 'win32' ? 'mise.exe' : 'mise'
)
if (!fs.existsSync(path.join(miseBinPath))) {
core.startGroup(version ? `Download mise@${version}` : 'Setup mise')
await fs.promises.mkdir(miseBinDir, { recursive: true })
const ext =
getOS() === 'windows'
process.platform === 'win32'
? '.zip'
: version && version.startsWith('2024')
? ''
@ -141,7 +141,7 @@ async function setupMise(version: string): Promise<void> {
? '.tar.zst'
: '.tar.gz'
version = (version || (await latestMiseVersion())).replace(/^v/, '')
const url = `https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${getOS()}-${os.arch()}${ext}`
const url = `https://github.com/jdx/mise/releases/download/v${version}/mise-v${version}-${await getTarget()}${ext}`
const archivePath = path.join(os.tmpdir(), `mise${ext}`)
switch (ext) {
case '.zip':
@ -201,17 +201,6 @@ async function setMiseToml(): Promise<void> {
}
}
function getOS(): string {
switch (process.platform) {
case 'darwin':
return 'macos'
case 'win32':
return 'windows'
default:
return process.platform
}
}
const testMise = async (): Promise<number> => mise(['--version'])
const miseInstall = async (): Promise<number> =>
mise([`install ${core.getInput('install_args')}`])
@ -271,3 +260,30 @@ async function saveCache(cacheKey: string): Promise<void> {
core.info(`Cache saved from ${cachePath} with key: ${cacheKey}`)
})
}
async function getTarget(): Promise<string> {
let { arch } = process
// quick overwrite to abide by release format
if (arch === 'arm') arch = 'armv7' as NodeJS.Architecture
switch (process.platform) {
case 'darwin':
return `macos-${arch}`
case 'win32':
return `windows-${arch}`
case 'linux':
return `linux-${arch}${(await isMusl()) ? '-musl' : ''}`
default:
throw new Error(`Unsupported platform ${process.platform}`)
}
}
async function isMusl() {
// `ldd --version` always returns 1 and print to stderr
const { stderr } = await exec.getExecOutput('ldd', ['--version'], {
failOnStdErr: false,
ignoreReturnCode: true
})
return stderr.indexOf('musl') > -1
}