generated from actions/typescript-action
-
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
check reusable workflow's job name pattern
- Loading branch information
Showing
3 changed files
with
112 additions
and
2 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
__tests__/fixtures/actions.reusable-workflow-job-name.jobs.json
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,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": "call-reusable / 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" | ||
} | ||
] | ||
} |
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,72 @@ | ||
import nock from 'nock'; | ||
|
||
process.env.GITHUB_RUN_ID = '2'; | ||
|
||
import { | ||
gitHubToken, | ||
gitHubBaseUrl, | ||
newWith, | ||
setupNockCommit, | ||
setupNockJobs, | ||
successMsg, | ||
webhookUrl, | ||
} from './helper'; | ||
import { Client, With, Success } from '../src/client'; | ||
|
||
beforeAll(() => { | ||
nock.disableNetConnect(); | ||
setupNockCommit(process.env.GITHUB_SHA as string); | ||
setupNockJobs( | ||
process.env.GITHUB_RUN_ID as string, | ||
'actions.reusable-workflow-job-name.jobs', | ||
); | ||
}); | ||
afterAll(() => { | ||
nock.cleanAll(); | ||
nock.enableNetConnect(); | ||
}); | ||
|
||
describe('job_name', () => { | ||
beforeEach(() => { | ||
process.env.GITHUB_REPOSITORY = '8398a7/action-slack'; | ||
process.env.GITHUB_EVENT_NAME = 'push'; | ||
const github = require('@actions/github'); | ||
github.context.payload = {}; | ||
}); | ||
|
||
it('works even if the job is in reusable workflow', async () => { | ||
const withParams: With = { | ||
...newWith(), | ||
status: Success, | ||
fields: 'job,took', | ||
}; | ||
const client = new Client( | ||
withParams, | ||
gitHubToken, | ||
gitHubBaseUrl, | ||
webhookUrl, | ||
); | ||
expect(await client.prepare('')).toStrictEqual({ | ||
text: successMsg, | ||
attachments: [ | ||
{ | ||
author_name: '', | ||
color: 'good', | ||
fields: [ | ||
{ | ||
short: true, | ||
title: 'job', | ||
value: | ||
'<https://github.com/8398a7/action-slack/runs/762195612|notification>', | ||
}, | ||
{ short: true, title: 'took', value: '1 hour 1 min 1 sec' }, | ||
], | ||
}, | ||
], | ||
username: '', | ||
icon_emoji: '', | ||
icon_url: '', | ||
channel: '', | ||
}); | ||
}); | ||
}); |
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