Skip to content

Commit 87c58dd

Browse files
authored
Merge pull request #23 from qt-creator/fix-download
Immediately display warning on error
2 parents 58e19fe + 64ad11e commit 87c58dd

File tree

8 files changed

+30
-19
lines changed

8 files changed

+30
-19
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ jobs:
6262

6363
- name: Print Output
6464
id: output
65-
run: echo "${{ steps.test-action.outputs.path }}"
65+
run: ls -lach "${{ steps.test-action.outputs.path }}"

__tests__/main.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ describe('action', () => {
3737
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
3838
})
3939

40-
it('downloads 14.0.0', async () => {
40+
it('downloads 15.0.0', async () => {
4141
// Set the action's inputs as return values from core.getInput()
4242
getInputMock.mockImplementation(name => {
4343
switch (name) {
4444
case 'version':
45-
return '14.0.0'
45+
return '15.0.0'
4646
case 'unzip-to':
4747
return tmpDir
48+
case 'platform':
49+
return 'linux_x64'
4850
default:
4951
return ''
5052
}

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ inputs:
1717
description: 'Where to unzip the Qt Creator files to'
1818
required: true
1919
default: 'qt-creator'
20+
platform:
21+
description: 'Overwrite platform detection'
22+
required: false
2023

2124
# Define your outputs here.
2225
outputs:

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

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

src/main.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async function downloadQtC(urls: string[]): Promise<string[]> {
4343
}
4444
return packages.map(packageName => `${tmpDir}/${packageName}`)
4545
} catch (error) {
46+
core.warning((error as Error).message)
4647
errors.push((error as Error).message)
4748
}
4849
}
@@ -73,16 +74,18 @@ export async function run(): Promise<void> {
7374
try {
7475
const version: string = core.getInput('version')
7576
const destination: string = core.getInput('unzip-to')
77+
const platformInput: string = core.getInput('platform')
7678

77-
if (!(process.platform in PlatformMap)) {
79+
if (!platformInput && !(process.platform in PlatformMap)) {
7880
core.setFailed(`Unsupported platform: ${process.platform}`)
7981
return
8082
}
8183

8284
const platformName: string =
8385
PlatformMap[process.platform as keyof typeof PlatformMap]
8486
const arch = process.platform === 'darwin' ? 'x64' : process.arch
85-
const platform = `${platformName}_${arch}`
87+
88+
const platform = platformInput ? platformInput : `${platformName}_${arch}`
8689

8790
// Extract the major and minor versions
8891
const [major, minor] = version.split('.').slice(0, 2)
@@ -115,6 +118,6 @@ export async function run(): Promise<void> {
115118
)
116119
} catch (error) {
117120
// Fail the workflow run if an error occurs
118-
if (error instanceof Error) core.setFailed(error.message)
121+
core.setFailed((error as Error).message)
119122
}
120123
}

0 commit comments

Comments
 (0)