Skip to content

Commit 99df971

Browse files
authored
Merge pull request #5 from Maddimax/releases/v1
First release
2 parents d6c6cd5 + 98ac48b commit 99df971

File tree

12 files changed

+6132
-151
lines changed

12 files changed

+6132
-151
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ jobs:
5757
id: test-action
5858
uses: ./
5959
with:
60-
milliseconds: 2000
60+
version: 14.0.0
61+
unzip-to: qt-creator
6162

6263
- name: Print Output
6364
id: output
64-
run: echo "${{ steps.test-action.outputs.time }}"
65+
run: echo "${{ steps.test-action.outputs.path }}"

__tests__/main.test.ts

Lines changed: 14 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -8,82 +8,48 @@
88

99
import * as core from '@actions/core'
1010
import * as main from '../src/main'
11+
import * as fs from 'fs'
12+
import * as path from 'path'
13+
import * as os from 'os'
1114

1215
// Mock the action's main function
1316
const runMock = jest.spyOn(main, 'run')
1417

18+
jest.setTimeout(60 * 1000)
19+
20+
const tmpDir = fs.mkdtempSync(
21+
path.join(os.tmpdir(), 'qt-creator-downloader-test')
22+
)
23+
1524
// Other utilities
16-
const timeRegex = /^\d{2}:\d{2}:\d{2}/
1725

1826
// Mock the GitHub Actions core library
19-
let debugMock: jest.SpiedFunction<typeof core.debug>
2027
let errorMock: jest.SpiedFunction<typeof core.error>
2128
let getInputMock: jest.SpiedFunction<typeof core.getInput>
22-
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>
23-
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
2429

2530
describe('action', () => {
2631
beforeEach(() => {
2732
jest.clearAllMocks()
2833

29-
debugMock = jest.spyOn(core, 'debug').mockImplementation()
3034
errorMock = jest.spyOn(core, 'error').mockImplementation()
3135
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
32-
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
33-
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
3436
})
3537

36-
it('sets the time output', async () => {
38+
it('downloads 14.0.0', async () => {
3739
// Set the action's inputs as return values from core.getInput()
3840
getInputMock.mockImplementation(name => {
3941
switch (name) {
40-
case 'milliseconds':
41-
return '500'
42+
case 'version':
43+
return '14.0.0'
44+
case 'unzip-to':
45+
return tmpDir
4246
default:
4347
return ''
4448
}
4549
})
4650

4751
await main.run()
4852
expect(runMock).toHaveReturned()
49-
50-
// Verify that all of the core library functions were called correctly
51-
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
52-
expect(debugMock).toHaveBeenNthCalledWith(
53-
2,
54-
expect.stringMatching(timeRegex)
55-
)
56-
expect(debugMock).toHaveBeenNthCalledWith(
57-
3,
58-
expect.stringMatching(timeRegex)
59-
)
60-
expect(setOutputMock).toHaveBeenNthCalledWith(
61-
1,
62-
'time',
63-
expect.stringMatching(timeRegex)
64-
)
65-
expect(errorMock).not.toHaveBeenCalled()
66-
})
67-
68-
it('sets a failed status', async () => {
69-
// Set the action's inputs as return values from core.getInput()
70-
getInputMock.mockImplementation(name => {
71-
switch (name) {
72-
case 'milliseconds':
73-
return 'this is not a number'
74-
default:
75-
return ''
76-
}
77-
})
78-
79-
await main.run()
80-
expect(runMock).toHaveReturned()
81-
82-
// Verify that all of the core library functions were called correctly
83-
expect(setFailedMock).toHaveBeenNthCalledWith(
84-
1,
85-
'milliseconds not a number'
86-
)
8753
expect(errorMock).not.toHaveBeenCalled()
8854
})
8955
})

__tests__/wait.test.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

action.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
1-
name: 'The name of your action here'
2-
description: 'Provide a description here'
3-
author: 'Your name or organization here'
1+
name: 'Install Qt Creator development files'
2+
description: 'Installs Qt Creator and its _dev packages'
3+
author: 'The Qt Company'
44

55
# Add your action's branding here. This will appear on the GitHub Marketplace.
66
branding:
7-
icon: 'heart'
8-
color: 'red'
7+
icon: 'archive'
8+
color: 'green'
99

1010
# Define your inputs here.
1111
inputs:
12-
milliseconds:
13-
description: 'Your input description here'
12+
version:
13+
description: 'The version to install'
1414
required: true
15-
default: '1000'
15+
default: '14.0.0'
16+
unzip-to:
17+
description: 'Where to unzip the Qt Creator files to'
18+
required: true
19+
default: 'qt-creator'
1620

1721
# Define your outputs here.
1822
outputs:
19-
time:
20-
description: 'Your output description here'
23+
path:
24+
description: 'Path to the extracted files.'
2125

2226
runs:
2327
using: node20

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)