Skip to content

Commit 8b013f1

Browse files
committed
chore: refactors and cleanups
Signed-off-by: Sam Gammon <sam@elide.ventures>
1 parent c0c4c8c commit 8b013f1

16 files changed

Lines changed: 148 additions & 324 deletions

__tests__/command.test.ts

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ mock.module('@actions/core', () => ({
2222
addPath: jest.fn()
2323
}))
2424

25-
const { prewarm, info, obtainVersion, ElideCommand, ElideArgument } =
26-
await import('../src/command')
25+
const { elideInfo, obtainVersion, ElideCommand, ElideArgument } = await import(
26+
'../src/command'
27+
)
2728

2829
describe('command', () => {
2930
beforeEach(() => {
@@ -39,20 +40,10 @@ describe('command', () => {
3940
})
4041
})
4142

42-
it('prewarm should execute the info command', async () => {
43-
await prewarm('/usr/bin/elide')
43+
it('elideInfo should execute the info command', async () => {
44+
await elideInfo('/usr/bin/elide')
4445
expect(infoMock).toHaveBeenCalledWith(
45-
'Prewarming Elide at bin: /usr/bin/elide'
46-
)
47-
expect(execMock).toHaveBeenCalledWith('"/usr/bin/elide"', [
48-
ElideCommand.INFO
49-
])
50-
})
51-
52-
it('info should execute the info command', async () => {
53-
await info('/usr/bin/elide')
54-
expect(debugMock).toHaveBeenCalledWith(
55-
'Printing runtime info at bin: /usr/bin/elide'
46+
'Running Elide info at bin: /usr/bin/elide'
5647
)
5748
expect(execMock).toHaveBeenCalledWith('"/usr/bin/elide"', [
5849
ElideCommand.INFO
@@ -82,8 +73,8 @@ describe('command', () => {
8273
expect(version).toBe('1.0.0')
8374
})
8475

85-
it('prewarm should propagate exec errors', async () => {
76+
it('elideInfo should propagate exec errors', async () => {
8677
execMock.mockRejectedValue(new Error('exec failed'))
87-
await expect(prewarm('/bad/path')).rejects.toThrow('exec failed')
78+
await expect(elideInfo('/bad/path')).rejects.toThrow('exec failed')
8879
})
8980
})

__tests__/install-apt.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ mock.module('@actions/core', () => ({
3131
}))
3232
mock.module('../src/command', () => ({
3333
obtainVersion: obtainVersionMock,
34-
prewarm: jest.fn(),
35-
info: jest.fn()
34+
elideInfo: jest.fn()
3635
}))
3736

3837
const { installViaApt } = await import('../src/install-apt')

__tests__/install-script.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ mock.module('@actions/tool-cache', () => ({
4040
}))
4141
mock.module('../src/command', () => ({
4242
obtainVersion: obtainVersionMock,
43-
prewarm: jest.fn(),
44-
info: jest.fn()
43+
elideInfo: jest.fn()
4544
}))
4645

4746
const { installViaScript } = await import('../src/install-script')

__tests__/main.test.ts

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ const errorMock = jest.fn()
1616
const addPathMock = jest.fn()
1717
const isDebianLikeMock = jest.fn().mockResolvedValue(false)
1818
const downloadToolMock = jest.fn().mockResolvedValue('/tmp/install.sh')
19-
const prewarmMock = jest.fn().mockResolvedValue(undefined)
20-
const cmdInfoMock = jest.fn().mockResolvedValue(undefined)
19+
const elideInfoMock = jest.fn().mockResolvedValue(undefined)
2120
const obtainVersionMock = jest.fn().mockResolvedValue('1.0.0')
2221

2322
// Mock modules before any project imports
@@ -38,6 +37,7 @@ mock.module('@actions/core', () => ({
3837
error: errorMock,
3938
warning: warningMock,
4039
getInput: getInputMock,
40+
getBooleanInput: jest.fn().mockReturnValue(true),
4141
setFailed: setFailedMock,
4242
setOutput: setOutputMock,
4343
addPath: addPathMock
@@ -50,8 +50,7 @@ mock.module('@actions/tool-cache', () => ({
5050
find: jest.fn()
5151
}))
5252
mock.module('../src/command', () => ({
53-
prewarm: prewarmMock,
54-
info: cmdInfoMock,
53+
elideInfo: elideInfoMock,
5554
obtainVersion: obtainVersionMock,
5655
ElideCommand: { RUN: 'run', INFO: 'info' },
5756
ElideArgument: { VERSION: '--version' }
@@ -63,7 +62,7 @@ mock.module('../src/platform', () => ({
6362
const main = await import('../src/main')
6463
const { default: buildOptions, OptionName } = await import('../src/options')
6564
const { ElideArch, ElideOS } = await import('../src/releases')
66-
const { ActionOutputName } = await import('../src/outputs')
65+
const { ActionOutputName } = await import('../src/main')
6766

6867
const setupMocks = () => {
6968
debugMock.mockImplementation((...args: unknown[]) =>
@@ -97,8 +96,7 @@ describe('action', () => {
9796
addPathMock.mockClear()
9897
isDebianLikeMock.mockClear()
9998
downloadToolMock.mockClear()
100-
prewarmMock.mockClear()
101-
cmdInfoMock.mockClear()
99+
elideInfoMock.mockClear()
102100
obtainVersionMock.mockClear()
103101
// Default: getInput returns empty
104102
getInputMock.mockReturnValue('')
@@ -115,8 +113,7 @@ describe('action', () => {
115113
stderr: '',
116114
exitCode: 0
117115
})
118-
prewarmMock.mockResolvedValue(undefined)
119-
cmdInfoMock.mockResolvedValue(undefined)
116+
elideInfoMock.mockResolvedValue(undefined)
120117
obtainVersionMock.mockResolvedValue('1.0.0')
121118
})
122119

@@ -129,7 +126,6 @@ describe('action', () => {
129126
expect(getInputMock).toHaveBeenCalledWith(OptionName.ARCH)
130127
expect(getInputMock).toHaveBeenCalledWith(OptionName.TOKEN)
131128
expect(getInputMock).toHaveBeenCalledWith(OptionName.CUSTOM_URL)
132-
expect(getInputMock).toHaveBeenCalledWith(OptionName.EXPORT_PATH)
133129
})
134130

135131
it('sets the `path` and `version` outputs', async () => {
@@ -196,23 +192,13 @@ describe('action', () => {
196192
)
197193
})
198194

199-
it('should gracefully handle prewarm failure', async () => {
195+
it('should gracefully handle post-install info failure', async () => {
200196
setupMocks()
201-
prewarmMock.mockRejectedValueOnce(new Error('prewarm boom'))
197+
elideInfoMock.mockRejectedValueOnce(new Error('info boom'))
202198
await main.run({ force: true })
203199
expect(setFailedMock).not.toHaveBeenCalled()
204200
expect(debugMock).toHaveBeenCalledWith(
205-
expect.stringContaining('Prewarm failed; proceeding anyway')
206-
)
207-
})
208-
209-
it('should gracefully handle info command failure', async () => {
210-
setupMocks()
211-
cmdInfoMock.mockRejectedValue(new Error('info boom'))
212-
await main.run({ force: true })
213-
expect(setFailedMock).not.toHaveBeenCalled()
214-
expect(debugMock).toHaveBeenCalledWith(
215-
expect.stringContaining('Info command failed; proceeding anyway')
201+
expect.stringContaining('Post-install info failed; proceeding anyway')
216202
)
217203
})
218204

__tests__/releases-download.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ mock.module('octokit', () => ({
5353
}))
5454
mock.module('../src/command', () => ({
5555
obtainVersion: obtainVersionMock,
56-
prewarm: jest.fn(),
57-
info: jest.fn()
56+
elideInfo: jest.fn()
5857
}))
5958

6059
const { downloadRelease, resolveLatestVersion } = await import(
@@ -415,15 +414,4 @@ describe('downloadRelease', () => {
415414
expect(findMock).toHaveBeenCalledWith('elide', '1.0.0', 'aarch64')
416415
})
417416
})
418-
419-
it('should not wrap with directory root for alpha7/alpha8', async () => {
420-
const options = buildOptions({
421-
os: 'linux',
422-
arch: 'amd64',
423-
version: '1.0.0-alpha7'
424-
})
425-
const result = await downloadRelease(options)
426-
// alpha7 has the early-return path in unpackRelease
427-
expect(result).toBeDefined()
428-
})
429417
})

__tests__/releases.test.ts

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ describe('buildDownloadUrl', () => {
5757
version: '1.0.0',
5858
channel: 'release'
5959
})
60-
const { url } = await buildDownloadUrl(options, {
61-
tag_name: '1.0.0',
62-
userProvided: true
63-
})
60+
const { url } = await buildDownloadUrl(options)
6461
expect(url.toString()).toBe(
6562
'https://elide.zip/artifacts/release/1.0.0/elide.linux-amd64.tgz'
6663
)
@@ -73,10 +70,7 @@ describe('buildDownloadUrl', () => {
7370
version: '1.0.0',
7471
channel: 'release'
7572
})
76-
const { url } = await buildDownloadUrl(options, {
77-
tag_name: '1.0.0',
78-
userProvided: true
79-
})
73+
const { url } = await buildDownloadUrl(options)
8074
expect(url.toString()).toBe(
8175
'https://elide.zip/artifacts/release/1.0.0/elide.macos-arm64.tgz'
8276
)
@@ -89,10 +83,7 @@ describe('buildDownloadUrl', () => {
8983
version: '1.0.0',
9084
channel: 'release'
9185
})
92-
const { url } = await buildDownloadUrl(options, {
93-
tag_name: '1.0.0',
94-
userProvided: true
95-
})
86+
const { url } = await buildDownloadUrl(options)
9687
expect(url.toString()).toBe(
9788
'https://elide.zip/artifacts/release/1.0.0/elide.macos-amd64.tgz'
9889
)
@@ -105,10 +96,7 @@ describe('buildDownloadUrl', () => {
10596
version: '1.0.0',
10697
channel: 'release'
10798
})
108-
const { url, archiveType } = await buildDownloadUrl(options, {
109-
tag_name: '1.0.0',
110-
userProvided: true
111-
})
99+
const { url, archiveType } = await buildDownloadUrl(options)
112100
expect(url.toString()).toBe(
113101
'https://elide.zip/artifacts/release/1.0.0/elide.windows-amd64.zip'
114102
)
@@ -124,10 +112,7 @@ describe('buildDownloadUrl', () => {
124112
version: '1.0.0-beta10',
125113
channel: 'release'
126114
})
127-
const { url } = await buildDownloadUrl(options, {
128-
tag_name: '1.0.0-beta10',
129-
userProvided: true
130-
})
115+
const { url } = await buildDownloadUrl(options)
131116
expect(url.toString()).toBe(
132117
'https://elide.zip/artifacts/release/1.0.0-beta10/elide.linux-amd64.tgz'
133118
)
@@ -140,10 +125,7 @@ describe('buildDownloadUrl', () => {
140125
version: '1.0.0-alpha7',
141126
channel: 'release'
142127
})
143-
const { url } = await buildDownloadUrl(options, {
144-
tag_name: '1.0.0-alpha7',
145-
userProvided: true
146-
})
128+
const { url } = await buildDownloadUrl(options)
147129
expect(url.toString()).toBe(
148130
'https://elide.zip/artifacts/release/1.0.0-alpha7/elide.macos-arm64.tgz'
149131
)
@@ -157,10 +139,7 @@ describe('buildDownloadUrl', () => {
157139
arch: 'amd64',
158140
version: '1.0.0'
159141
})
160-
const { url } = await buildDownloadUrl(options, {
161-
tag_name: '1.0.0',
162-
userProvided: true
163-
})
142+
const { url } = await buildDownloadUrl(options)
164143
expect(url.toString()).toBe(
165144
'https://elide.zip/artifacts/nightly/1.0.0/elide.linux-amd64.tgz'
166145
)
@@ -172,10 +151,7 @@ describe('buildDownloadUrl', () => {
172151
arch: 'amd64',
173152
version: 'latest'
174153
})
175-
const { url } = await buildDownloadUrl(options, {
176-
tag_name: 'ignored',
177-
userProvided: false
178-
})
154+
const { url } = await buildDownloadUrl(options)
179155
expect(url.toString()).toBe(
180156
'https://elide.zip/artifacts/nightly/latest/elide.linux-amd64.tgz'
181157
)
@@ -190,10 +166,7 @@ describe('buildDownloadUrl', () => {
190166
version: 'latest',
191167
channel: 'preview'
192168
})
193-
const { url } = await buildDownloadUrl(options, {
194-
tag_name: 'ignored',
195-
userProvided: false
196-
})
169+
const { url } = await buildDownloadUrl(options)
197170
expect(url.toString()).toBe(
198171
'https://elide.zip/artifacts/preview/latest/elide.macos-arm64.tgz'
199172
)
@@ -207,10 +180,7 @@ describe('buildDownloadUrl', () => {
207180
arch: 'amd64',
208181
version: 'latest'
209182
})
210-
const { url, archiveType } = await buildDownloadUrl(options, {
211-
tag_name: 'ignored',
212-
userProvided: false
213-
})
183+
const { url, archiveType } = await buildDownloadUrl(options)
214184
expect(url.toString()).toBe(
215185
'https://elide.zip/artifacts/nightly/latest/elide.windows-amd64.zip'
216186
)
@@ -225,10 +195,7 @@ describe('buildDownloadUrl', () => {
225195
version: '1.0.0',
226196
channel: 'release'
227197
})
228-
const { url, archiveType } = await buildDownloadUrl(options, {
229-
tag_name: '1.0.0',
230-
userProvided: true
231-
})
198+
const { url, archiveType } = await buildDownloadUrl(options)
232199
expect(url.toString()).toBe(
233200
'https://elide.zip/artifacts/release/1.0.0/elide.linux-amd64.txz'
234201
)

action.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inputs:
2424
description: 'Architecture'
2525
required: false
2626

27-
target:
27+
install_path:
2828
description: 'Custom install path'
2929
required: false
3030

@@ -35,12 +35,21 @@ inputs:
3535
export_path:
3636
description: 'Export to Path'
3737
required: false
38-
default: true
38+
default: 'true'
39+
40+
no_cache:
41+
description: 'Disable tool caching'
42+
required: false
43+
default: 'false'
3944

4045
custom_url:
4146
description: 'Custom Download URL'
4247
required: false
4348

49+
version_tag:
50+
description: 'Version tag for custom download URL'
51+
required: false
52+
4453
token:
4554
description: 'GitHub Token'
4655
required: false
@@ -49,6 +58,9 @@ outputs:
4958
path:
5059
description: 'Path to Elide'
5160

61+
version:
62+
description: 'Installed Elide version'
63+
5264
runs:
5365
using: node24
5466
main: dist/index.js

dist/index.js

Lines changed: 24 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)