Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: Update action to use the native API client
- Loading branch information
Showing
16 changed files
with
26,206 additions
and
46,390 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
dist/ | ||
lib/ | ||
node_modules/ | ||
node_modules/ | ||
.github/workflows/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,53 @@ | ||
import { context } from '@actions/github' | ||
import { Client, ClientConfiguration, Logger } from '@octopusdeploy/api-client' | ||
import * as inputs from '../src/input-parameters' | ||
import * as octopus from '../src/push-build-information' | ||
import { CaptureOutput } from './test-helpers' | ||
|
||
const apiClientConfig: ClientConfiguration = { | ||
userAgentApp: 'Test', | ||
apiKey: process.env.OCTOPUS_TEST_API_KEY || 'API-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', | ||
instanceURL: process.env.OCTOPUS_TEST_URL || 'http://localhost:8050' | ||
} | ||
|
||
describe('inputs', () => { | ||
it('successfully get input parameters', async () => { | ||
const inputParameters = inputs.get() | ||
const inputParameters = inputs.get(false) | ||
expect(inputParameters != undefined) | ||
}, 100000) | ||
}) | ||
|
||
describe('build information', () => { | ||
it('successfully pushes build information', async () => { | ||
const inputParameters = inputs.get() | ||
const output = new CaptureOutput() | ||
|
||
const logger: Logger = { | ||
debug: message => output.debug(message), | ||
info: message => output.info(message), | ||
warn: message => output.warn(message), | ||
error: (message, err) => { | ||
if (err !== undefined) { | ||
output.error(err.message) | ||
} else { | ||
output.error(message) | ||
} | ||
} | ||
} | ||
|
||
const config: ClientConfiguration = { | ||
userAgentApp: 'Test', | ||
instanceURL: apiClientConfig.instanceURL, | ||
apiKey: apiClientConfig.apiKey, | ||
logging: logger | ||
} | ||
|
||
const client = await Client.create(config) | ||
|
||
const inputParameters = inputs.get(false) | ||
const runId = context.runId | ||
if (runId === undefined) { | ||
throw new Error('GitHub run number is not defined') | ||
} | ||
await octopus.pushBuildInformation(runId, inputParameters) | ||
await octopus.pushBuildInformationFromInputs(client, runId, inputParameters) | ||
}, 100000) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export class CaptureOutput { | ||
msgs: string[] | ||
|
||
constructor() { | ||
this.msgs = [] | ||
} | ||
|
||
debug(message: string): void { | ||
this.msgs.push(`[DEBUG] ${message}`) | ||
} | ||
info(message: string): void { | ||
this.msgs.push(`[INFO] ${message}`) | ||
} | ||
warn(message: string): void { | ||
this.msgs.push(`[WARN] ${message}`) | ||
} | ||
error(message: string): void { | ||
this.msgs.push(`[ERROR] ${message}`) | ||
} | ||
|
||
getAllMessages(): string[] { | ||
return this.msgs | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.