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
20 changes: 10 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ jobs:
- run: npm run build
# - run: npm test
- uses: ./
# - uses: ./
# with:
# use-cache: false
# force-build: true
# install-dependencies: false
- uses: ./
with:
use-cache: false
force-build: true
install-dependencies: false

macos:
runs-on: macos-latest
Expand All @@ -56,11 +56,11 @@ jobs:
- run: npm run build
- run: npm test
- uses: ./
# - uses: ./
# with:
# use-cache: false
# force-build: true
# install-dependencies: false
- uses: ./
with:
use-cache: false
force-build: true
install-dependencies: false

windows:
runs-on: windows-latest
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ The following parameters can be accessed by the `github` context:

Type: `String`<br>

The actually installed version of V, as returned by `v -V`, for example: `V 0.3.4 046dd54`.
The actually installed version of V, as returned by `v version`, for example: `V 0.3.4 046dd54`.

### bin-path

Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ inputs:
outputs:
version:
description: >-
The actually installed version of V, as returned by `v -V`.
The actually installed version of V, as returned by `v version`.
bin-path:
description: >-
The complete path to the directory with the V compiler.
Expand Down
41 changes: 28 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33917,7 +33917,7 @@ async function getRelease(token, type, check, number) {

async function getCommit(sha, token) {
const { commit } = await requestSafely(token, `commits/${sha}`);
const { date } = commit;
const { date } = commit.author;
debug(`commit is ${sha} from ${date}`);
return { name: 'commit', sha, date }
}
Expand All @@ -33933,7 +33933,7 @@ function resolveVersion(token, version) {
const getVersion = versionGetters[version];
if (getVersion) return getVersion(token)
if (semantic.test(version)) return getRelease(token, 'release', semantic, version)
return getCommit(token, version)
return getCommit(version, token)
}

async function getVersion(exePath) {
Expand All @@ -33945,7 +33945,7 @@ async function getVersion(exePath) {
}

let out;
await exec(exePath, ['-V'], {
await exec(exePath, ['version'], {
listeners: {
stdout: data => {
out = out ? Buffer.concat([out, data]) : data;
Expand Down Expand Up @@ -34018,23 +34018,38 @@ async function install(sha, url, useCache, forceBuild) {

debug(`extract ${archive} to ${extractDir}`);
await extractZip(archive, extractDir);

if (wasBuilt) {
info(`Move ${contentDir} to ${exeDir} before building`);
try {
await mv(contentDir, exeDir);
contentDir = exeDir;
} catch (err) {
await rmRF(exeDir);
throw err
}
}

if (mock && platform !== 'win32') {
const exeOrigin = `${extractDir}/v/v`;
const exeOrigin = join(contentDir, 'v');
info(`Make ${exeOrigin} executable`);
await chmod$1(exeOrigin, 0o755);
}

if (wasBuilt) {
if (platform !== 'win32') {
debug(`execute make in ${pkgDir}`);
await exec('make', [], { cwd: pkgDir });
} else {
debug(`execute make.bat in ${contentDir}`);
await exec2('make.bat', { cwd: contentDir, shell: true });
try {
if (platform !== 'win32') {
debug(`execute make in ${contentDir}`);
await exec('make', [], { cwd: contentDir });
} else {
debug(`execute make.bat in ${contentDir}`);
await exec2('make.bat', { cwd: contentDir, shell: true });
}
} catch (err) {
await rmRF(exeDir);
throw err
}
}

if (platform !== 'win32') {
} else if (platform !== 'win32') {
await mkdirP(exeDir);
info(`Populate ${exeDir} with needed files from ${contentDir}`);
try {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

41 changes: 28 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async function getRelease(token, type, check, number) {

async function getCommit(sha, token) {
const { commit } = await requestSafely(token, `commits/${sha}`)
const { date } = commit
const { date } = commit.author
core.debug(`commit is ${sha} from ${date}`)
return { name: 'commit', sha, date }
}
Expand All @@ -143,7 +143,7 @@ function resolveVersion(token, version) {
const getVersion = versionGetters[version]
if (getVersion) return getVersion(token)
if (semantic.test(version)) return getRelease(token, 'release', semantic, version)
return getCommit(token, version)
return getCommit(version, token)
Comment thread
prantlf marked this conversation as resolved.
}

async function getVersion(exePath) {
Expand All @@ -155,7 +155,7 @@ async function getVersion(exePath) {
}

let out
await exec(exePath, ['-V'], {
await exec(exePath, ['version'], {
listeners: {
stdout: data => {
out = out ? Buffer.concat([out, data]) : data
Expand Down Expand Up @@ -228,23 +228,38 @@ async function install(sha, url, useCache, forceBuild) {

core.debug(`extract ${archive} to ${extractDir}`)
await tc.extractZip(archive, extractDir)

if (wasBuilt) {
core.info(`Move ${contentDir} to ${exeDir} before building`)
try {
await io.mv(contentDir, exeDir)
contentDir = exeDir
} catch (err) {
await io.rmRF(exeDir)
throw err
}
}

if (mock && platform !== 'win32') {
const exeOrigin = `${extractDir}/v/v`
const exeOrigin = join(contentDir, 'v')
Comment thread
prantlf marked this conversation as resolved.
core.info(`Make ${exeOrigin} executable`)
await chmod(exeOrigin, 0o755)
}

if (wasBuilt) {
if (platform !== 'win32') {
core.debug(`execute make in ${pkgDir}`)
await exec('make', [], { cwd: pkgDir })
} else {
core.debug(`execute make.bat in ${contentDir}`)
await exec2('make.bat', { cwd: contentDir, shell: true })
try {
if (platform !== 'win32') {
core.debug(`execute make in ${contentDir}`)
await exec('make', [], { cwd: contentDir })
} else {
core.debug(`execute make.bat in ${contentDir}`)
await exec2('make.bat', { cwd: contentDir, shell: true })
}
} catch (err) {
await io.rmRF(exeDir)
throw err
}
}

if (platform !== 'win32') {
} else if (platform !== 'win32') {
await io.mkdirP(exeDir)
core.info(`Populate ${exeDir} with needed files from ${contentDir}`)
try {
Expand Down
19 changes: 13 additions & 6 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ const env = {
MOCK: '1'
}

const exeDir = join(__dirname, '/wksp/v-046dd54') // weekly: 692624b
const exeName = join(exeDir, 'v')
const releaseExeDir = join(__dirname, '/wksp/v-046dd54') // weekly: 692624b
const releaseExeName = join(releaseExeDir, 'v')
const commit = '83e30a8104a3ef1dc966d6eeffb580ef5b90c6fc'
const commitExeDir = join(__dirname, `/wksp/v-${commit.substring(0, 7)}`)
const commitExeName = join(commitExeDir, 'v')
const cwd = join(__dirname, '..')

function exec(command, args) {
return new Promise((resolve, reject) => {
const child = spawn(command, args, { shell: true, cwd, env })
const child = spawn(command, args, { cwd, env })
.on('error', reject)
.on('exit', code => code ? reject(new Error(`'${command}' exited with ${code}`)) : resolve())
child.stdout.on('data', data => process.stdout.write(data.toString()))
child.stderr.on('data', data => process.stderr.write(data.toString()))
})
}

async function test(name) {
async function test(name, exeName = releaseExeName) {
console.log(`----------------------------------------
${name}
----------------------------------------`)
Expand All @@ -55,12 +58,16 @@ async function run() {
await test('install from archive')
await test('skip already installed')

await rm(exeName)
await rm(releaseExeName)
await test('install missing executable from cache')

await rm(exeDir, { recursive: true })
await rm(releaseExeDir, { recursive: true })
await test('install missing directory from cache')

env.INPUT_VERSION = commit
await test('install from a commit', commitExeName)
await access(join(commitExeDir, 'Makefile'))

console.log('done')
}

Expand Down
Binary file not shown.