This commit is contained in:
839 2020-06-12 22:38:51 +09:00
Родитель 6131983147
Коммит 5927ffe12c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B320DBCCE13B7629
2 изменённых файлов: 48 добавлений и 1 удалений

Просмотреть файл

@ -7,6 +7,8 @@ process.env.GITHUB_SHA = 'b24f03a32e093fe8d55e23cfd0bb314069633b2f';
process.env.GITHUB_REF = 'refs/heads/feature/19';
process.env.GITHUB_EVENT_NAME = 'push';
process.env.GITHUB_TOKEN = 'test-token';
process.env.GITHUB_RUN_ID = '1';
process.env.GITHUB_JOB = 'notification';
import {
Client,
@ -79,6 +81,14 @@ const workflow = (): Field => {
};
};
const job = (): Field => {
return {
short: true,
title: 'job',
value: `<https://github.com/8398a7/action-slack/runs/762195612|${process.env.GITHUB_JOB}>`,
};
};
const fixedFields = (client: Client, sha?: string) => {
return client.filterField(
[
@ -86,6 +96,7 @@ const fixedFields = (client: Client, sha?: string) => {
client.includesField('message') ? message() : undefined,
client.includesField('commit') ? commit() : undefined,
client.includesField('author') ? author() : undefined,
client.includesField('job') ? job() : undefined,
client.includesField('action') ? action(sha) : undefined,
client.includesField('eventName') ? eventName() : undefined,
client.includesField('ref') ? ref() : undefined,
@ -126,6 +137,12 @@ beforeAll(() => {
.persist()
.get(`/repos/8398a7/action-slack/commits/${process.env.GITHUB_SHA}`)
.reply(200, () => getApiFixture('repos.commits.get'));
nock('https://api.github.com')
.persist()
.get(
`/repos/8398a7/action-slack/actions/runs/${process.env.GITHUB_RUN_ID}/jobs`,
)
.reply(200, () => getApiFixture('actions.runs.jobs'));
});
afterAll(() => {
nock.cleanAll();
@ -151,7 +168,7 @@ describe('8398a7/action-slack', () => {
icon_emoji: '',
icon_url: '',
channel: '',
fields: 'repo,message,commit,author,action,eventName,ref,workflow',
fields: 'repo,message,commit,author,action,eventName,ref,workflow,job',
};
const client = new Client(withParams, process.env.GITHUB_TOKEN, '');
const payload = getTemplate(client, `${successMsg}\n`);

Просмотреть файл

@ -0,0 +1,30 @@
{
"total_count": 1,
"jobs": [
{
"id": 762195612,
"run_id": 132308092,
"run_url": "https://api.github.com/repos/8398a7/action-slack/actions/runs/132308092",
"node_id": "MDg6Q2hlY2tSdW43NjIxOTU2MTI=",
"head_sha": "cd15a66fc57d465564195faeb5308a63b4317cde",
"url": "https://api.github.com/repos/8398a7/action-slack/actions/jobs/762195612",
"html_url": "https://github.com/8398a7/action-slack/runs/762195612",
"status": "in_progress",
"conclusion": null,
"started_at": "2020-06-11T15:05:49Z",
"completed_at": null,
"name": "notification",
"steps": [
{
"name": "Set up job",
"status": "in_progress",
"conclusion": null,
"number": 1,
"started_at": "2020-06-11T15:05:49.000Z",
"completed_at": null
}
],
"check_run_url": "https://api.github.com/repos/8398a7/action-slack/check-runs/762195612"
}
]
}