mirror of https://github.com/actions/toolkit
Add `file` property to `AnnotationProperties` (#896)
parent
ea81280a4d
commit
60145e408c
|
@ -142,6 +142,11 @@ export interface AnnotationProperties {
|
||||||
*/
|
*/
|
||||||
title?: string
|
title?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the file for which the annotation should be created.
|
||||||
|
*/
|
||||||
|
file?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The start line for the annotation.
|
* The start line for the annotation.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -274,13 +274,14 @@ describe('@actions/core', () => {
|
||||||
const message = 'this is my error message'
|
const message = 'this is my error message'
|
||||||
core.error(new Error(message), {
|
core.error(new Error(message), {
|
||||||
title: 'A title',
|
title: 'A title',
|
||||||
|
file: 'root/test.txt',
|
||||||
startColumn: 1,
|
startColumn: 1,
|
||||||
endColumn: 2,
|
endColumn: 2,
|
||||||
startLine: 5,
|
startLine: 5,
|
||||||
endLine: 5
|
endLine: 5
|
||||||
})
|
})
|
||||||
assertWriteCalls([
|
assertWriteCalls([
|
||||||
`::error title=A title,line=5,endLine=5,col=1,endColumn=2::Error: ${message}${os.EOL}`
|
`::error title=A title,file=root/test.txt,line=5,endLine=5,col=1,endColumn=2::Error: ${message}${os.EOL}`
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -304,25 +305,59 @@ describe('@actions/core', () => {
|
||||||
const message = 'this is my error message'
|
const message = 'this is my error message'
|
||||||
core.warning(new Error(message), {
|
core.warning(new Error(message), {
|
||||||
title: 'A title',
|
title: 'A title',
|
||||||
|
file: 'root/test.txt',
|
||||||
startColumn: 1,
|
startColumn: 1,
|
||||||
endColumn: 2,
|
endColumn: 2,
|
||||||
startLine: 5,
|
startLine: 5,
|
||||||
endLine: 5
|
endLine: 5
|
||||||
})
|
})
|
||||||
assertWriteCalls([
|
assertWriteCalls([
|
||||||
`::warning title=A title,line=5,endLine=5,col=1,endColumn=2::Error: ${message}${os.EOL}`
|
`::warning title=A title,file=root/test.txt,line=5,endLine=5,col=1,endColumn=2::Error: ${message}${os.EOL}`
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('notice sets the correct message', () => {
|
||||||
|
core.notice('Notice')
|
||||||
|
assertWriteCalls([`::notice::Notice${os.EOL}`])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('notice escapes the message', () => {
|
||||||
|
core.notice('\r\nnotice\n')
|
||||||
|
assertWriteCalls([`::notice::%0D%0Anotice%0A${os.EOL}`])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('notice handles an error object', () => {
|
||||||
|
const message = 'this is my error message'
|
||||||
|
core.notice(new Error(message))
|
||||||
|
assertWriteCalls([`::notice::Error: ${message}${os.EOL}`])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('notice handles parameters correctly', () => {
|
||||||
|
const message = 'this is my error message'
|
||||||
|
core.notice(new Error(message), {
|
||||||
|
title: 'A title',
|
||||||
|
file: 'root/test.txt',
|
||||||
|
startColumn: 1,
|
||||||
|
endColumn: 2,
|
||||||
|
startLine: 5,
|
||||||
|
endLine: 5
|
||||||
|
})
|
||||||
|
assertWriteCalls([
|
||||||
|
`::notice title=A title,file=root/test.txt,line=5,endLine=5,col=1,endColumn=2::Error: ${message}${os.EOL}`
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('annotations map field names correctly', () => {
|
it('annotations map field names correctly', () => {
|
||||||
const commandProperties = toCommandProperties({
|
const commandProperties = toCommandProperties({
|
||||||
title: 'A title',
|
title: 'A title',
|
||||||
|
file: 'root/test.txt',
|
||||||
startColumn: 1,
|
startColumn: 1,
|
||||||
endColumn: 2,
|
endColumn: 2,
|
||||||
startLine: 5,
|
startLine: 5,
|
||||||
endLine: 5
|
endLine: 5
|
||||||
})
|
})
|
||||||
expect(commandProperties.title).toBe('A title')
|
expect(commandProperties.title).toBe('A title')
|
||||||
|
expect(commandProperties.file).toBe('root/test.txt')
|
||||||
expect(commandProperties.col).toBe(1)
|
expect(commandProperties.col).toBe(1)
|
||||||
expect(commandProperties.endColumn).toBe(2)
|
expect(commandProperties.endColumn).toBe(2)
|
||||||
expect(commandProperties.line).toBe(5)
|
expect(commandProperties.line).toBe(5)
|
||||||
|
|
|
@ -41,6 +41,11 @@ export interface AnnotationProperties {
|
||||||
*/
|
*/
|
||||||
title?: string
|
title?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path of the file for which the annotation should be created.
|
||||||
|
*/
|
||||||
|
file?: string
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The start line for the annotation.
|
* The start line for the annotation.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -32,6 +32,7 @@ export function toCommandProperties(
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: annotationProperties.title,
|
title: annotationProperties.title,
|
||||||
|
file: annotationProperties.file,
|
||||||
line: annotationProperties.startLine,
|
line: annotationProperties.startLine,
|
||||||
endLine: annotationProperties.endLine,
|
endLine: annotationProperties.endLine,
|
||||||
col: annotationProperties.startColumn,
|
col: annotationProperties.startColumn,
|
||||||
|
|
Loading…
Reference in New Issue