mirror of https://github.com/actions/toolkit
Update readme
parent
b3d7aa31c3
commit
4b50f8c52c
Binary file not shown.
After Width: | Height: | Size: 46 KiB |
|
@ -6,7 +6,7 @@ Problem Matchers are a way to scan the output of actions for a specified regex p
|
||||||
|
|
||||||
Currently, GitHub Actions limit the annotation count in a workflow run.
|
Currently, GitHub Actions limit the annotation count in a workflow run.
|
||||||
|
|
||||||
- 10 warning annotations and 10 error annotations per step
|
- 10 warning annotations, 10 error annotations, and 10 notice annotations per step
|
||||||
- 50 annotations per job (sum of annotations from all the steps)
|
- 50 annotations per job (sum of annotations from all the steps)
|
||||||
- 50 annotations per run (separate from the job annotations, these annotations aren’t created by users)
|
- 50 annotations per run (separate from the job annotations, these annotations aren’t created by users)
|
||||||
|
|
||||||
|
|
|
@ -92,6 +92,8 @@ try {
|
||||||
|
|
||||||
// Do stuff
|
// Do stuff
|
||||||
core.info('Output to the actions build log')
|
core.info('Output to the actions build log')
|
||||||
|
|
||||||
|
core.notice('This is a message that will also emit an annotation')
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
core.error(`Error ${err}, action may still succeed though`);
|
core.error(`Error ${err}, action may still succeed though`);
|
||||||
|
@ -115,6 +117,53 @@ const result = await core.group('Do something async', async () => {
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Annotations
|
||||||
|
This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
|
||||||
|
```js
|
||||||
|
core.error('This is a bad error. This will also fail the build.')
|
||||||
|
|
||||||
|
core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
|
||||||
|
|
||||||
|
core.notice('Something happened that you might want to know about.')
|
||||||
|
```
|
||||||
|
|
||||||
|
These will surface to the UI in the Actions page and on Pull Requests. They look something like this:
|
||||||
|
|
||||||
|
![Annotations Image](../../docs/assets/annotations.png)
|
||||||
|
|
||||||
|
These annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring.
|
||||||
|
|
||||||
|
These options are:
|
||||||
|
```typescript
|
||||||
|
export interface AnnotationProperties {
|
||||||
|
/**
|
||||||
|
* A title for the annotation.
|
||||||
|
*/
|
||||||
|
title?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start line for the annotation.
|
||||||
|
*/
|
||||||
|
startLine?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
|
||||||
|
*/
|
||||||
|
endLine?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
*/
|
||||||
|
startColumn?: number
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
|
||||||
|
* Defaults to `startColumn` when `startColumn` is provided.
|
||||||
|
*/
|
||||||
|
endColumn?: number
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
#### Styling output
|
#### Styling output
|
||||||
|
|
||||||
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
|
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
|
||||||
|
|
|
@ -272,8 +272,16 @@ describe('@actions/core', () => {
|
||||||
|
|
||||||
it('error handles parameters correctly', () => {
|
it('error handles parameters correctly', () => {
|
||||||
const message = 'this is my error message'
|
const message = 'this is my error message'
|
||||||
core.error(new Error(message), { title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
core.error(new Error(message), {
|
||||||
assertWriteCalls([`::error title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`])
|
title: 'A title',
|
||||||
|
startColumn: 1,
|
||||||
|
endColumn: 2,
|
||||||
|
startLine: 5,
|
||||||
|
endLine: 5
|
||||||
|
})
|
||||||
|
assertWriteCalls([
|
||||||
|
`::error title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('warning sets the correct message', () => {
|
it('warning sets the correct message', () => {
|
||||||
|
@ -294,12 +302,26 @@ describe('@actions/core', () => {
|
||||||
|
|
||||||
it('warning handles parameters correctly', () => {
|
it('warning handles parameters correctly', () => {
|
||||||
const message = 'this is my error message'
|
const message = 'this is my error message'
|
||||||
core.warning(new Error(message), { title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
core.warning(new Error(message), {
|
||||||
assertWriteCalls([`::warning title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`])
|
title: 'A title',
|
||||||
|
startColumn: 1,
|
||||||
|
endColumn: 2,
|
||||||
|
startLine: 5,
|
||||||
|
endLine: 5
|
||||||
|
})
|
||||||
|
assertWriteCalls([
|
||||||
|
`::warning title=A title,line=5,end_line=5,col=1,end_column=2::Error: ${message}${os.EOL}`
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('annotations map field names correctly', () => {
|
it('annotations map field names correctly', () => {
|
||||||
const commandProperties = toCommandProperties({ title: 'A title', startColumn: 1, endColumn: 2, startLine: 5, endLine: 5 })
|
const commandProperties = toCommandProperties({
|
||||||
|
title: 'A title',
|
||||||
|
startColumn: 1,
|
||||||
|
endColumn: 2,
|
||||||
|
startLine: 5,
|
||||||
|
endLine: 5
|
||||||
|
})
|
||||||
expect(commandProperties.title).toBe('A title')
|
expect(commandProperties.title).toBe('A title')
|
||||||
expect(commandProperties.col).toBe(1)
|
expect(commandProperties.col).toBe(1)
|
||||||
expect(commandProperties.end_column).toBe(2)
|
expect(commandProperties.end_column).toBe(2)
|
||||||
|
|
Loading…
Reference in New Issue