Skip to content

Commit

Permalink
Merge pull request #5 from qt-creator/releases/v1.3
Browse files Browse the repository at this point in the history
Add path-with-slashes output
  • Loading branch information
Maddimax authored Aug 6, 2024
2 parents 753a974 + f9d4ad5 commit f3cf8af
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_TYPESCRIPT_STANDARD: false
VALIDATE_JSCPD: false
13 changes: 12 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ const tmpDir = fs.mkdtempSync(
// Mock the GitHub Actions core library
let errorMock: jest.SpiedFunction<typeof core.error>
let getInputMock: jest.SpiedFunction<typeof core.getInput>
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

errorMock = jest.spyOn(core, 'error').mockImplementation()
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('downloads 14.0.0', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'version':
return '15.0.0-beta1'
return '14.0.0'
case 'unzip-to':
return tmpDir
default:
Expand All @@ -51,5 +53,14 @@ describe('action', () => {
await main.run()
expect(runMock).toHaveReturned()
expect(errorMock).not.toHaveBeenCalled()

expect(setOutputMock).toHaveBeenCalledWith(
'path',
expect.stringContaining(tmpDir)
)
expect(setOutputMock).toHaveBeenCalledWith(
'path-with-slashes',
expect.not.stringContaining('\\')
)
})
})
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async function downloadQtC(urls: string[]): Promise<string[]> {
try {
for (const packageName of packages) {
const fullUrl = `${url}/${packageName}`
console.log(`Downloading ${fullUrl}`)
core.info(`Downloading ${fullUrl}`)
await downloadPackage(fullUrl, `${tmpDir}/${packageName}`)
}
return packages.map(packageName => `${tmpDir}/${packageName}`)
Expand Down Expand Up @@ -101,16 +101,19 @@ export async function run(): Promise<void> {

for (const packageFile of packages) {
// Unzip the downloaded file
console.log(`Unzipping package: ${packageFile}`)
core.info(`Unzipping package: ${packageFile}`)
await extract(packageFile, destination)
}

console.log(`Qt Creator ${version} has been extracted to ${destination}`)
core.info(`Qt Creator ${version} has been extracted to ${destination}`)

// Set outputs for other workflow steps to use
core.setOutput('path', destination)
core.setOutput(
'path-with-slashes',
path.resolve(destination).split(path.sep).join('/')
)
} catch (error) {
console.log('Error:', error)
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
}
Expand Down

0 comments on commit f3cf8af

Please sign in to comment.