Skip to content

Commit

Permalink
Merge pull request #160 from act10ns/add-more-tests
Browse files Browse the repository at this point in the history
Add more tests and debug logging
  • Loading branch information
satterly authored Nov 13, 2020
2 parents a8a3419 + 02d782d commit ddd0517
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 0 deletions.
139 changes: 139 additions & 0 deletions __tests__/fixtures/manual.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
{
"inputs": null,
"organization": {
"avatar_url": "https://avatars1.githubusercontent.com/u/65077766?v=4",
"description": "Automate your GitHub workflows with custom actions",
"events_url": "https://api.github.com/orgs/act10ns/events",
"hooks_url": "https://api.github.com/orgs/act10ns/hooks",
"id": 65077766,
"issues_url": "https://api.github.com/orgs/act10ns/issues",
"login": "act10ns",
"members_url": "https://api.github.com/orgs/act10ns/members{/member}",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjY1MDc3NzY2",
"public_members_url": "https://api.github.com/orgs/act10ns/public_members{/member}",
"repos_url": "https://api.github.com/orgs/act10ns/repos",
"url": "https://api.github.com/orgs/act10ns"
},
"ref": "refs/heads/master",
"repository": {
"archive_url": "https://api.github.com/repos/act10ns/slack/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/act10ns/slack/assignees{/user}",
"blobs_url": "https://api.github.com/repos/act10ns/slack/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/act10ns/slack/branches{/branch}",
"clone_url": "https://github.com/act10ns/slack.git",
"collaborators_url": "https://api.github.com/repos/act10ns/slack/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/act10ns/slack/comments{/number}",
"commits_url": "https://api.github.com/repos/act10ns/slack/commits{/sha}",
"compare_url": "https://api.github.com/repos/act10ns/slack/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/act10ns/slack/contents/{+path}",
"contributors_url": "https://api.github.com/repos/act10ns/slack/contributors",
"created_at": "2020-05-09T14:04:36Z",
"default_branch": "master",
"deployments_url": "https://api.github.com/repos/act10ns/slack/deployments",
"description": "Slack messages for GitHub Action workflows, jobs and steps",
"disabled": false,
"downloads_url": "https://api.github.com/repos/act10ns/slack/downloads",
"events_url": "https://api.github.com/repos/act10ns/slack/events",
"fork": false,
"forks": 1,
"forks_count": 1,
"forks_url": "https://api.github.com/repos/act10ns/slack/forks",
"full_name": "act10ns/slack",
"git_commits_url": "https://api.github.com/repos/act10ns/slack/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/act10ns/slack/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/act10ns/slack/git/tags{/sha}",
"git_url": "git://github.com/act10ns/slack.git",
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": "https://github.com/marketplace/actions/slack-github-actions-slack-integration",
"hooks_url": "https://api.github.com/repos/act10ns/slack/hooks",
"html_url": "https://github.com/act10ns/slack",
"id": 262583918,
"issue_comment_url": "https://api.github.com/repos/act10ns/slack/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/act10ns/slack/issues/events{/number}",
"issues_url": "https://api.github.com/repos/act10ns/slack/issues{/number}",
"keys_url": "https://api.github.com/repos/act10ns/slack/keys{/key_id}",
"labels_url": "https://api.github.com/repos/act10ns/slack/labels{/name}",
"language": "TypeScript",
"languages_url": "https://api.github.com/repos/act10ns/slack/languages",
"license": {
"key": "mit",
"name": "MIT License",
"node_id": "MDc6TGljZW5zZTEz",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit"
},
"merges_url": "https://api.github.com/repos/act10ns/slack/merges",
"milestones_url": "https://api.github.com/repos/act10ns/slack/milestones{/number}",
"mirror_url": null,
"name": "slack",
"node_id": "MDEwOlJlcG9zaXRvcnkyNjI1ODM5MTg=",
"notifications_url": "https://api.github.com/repos/act10ns/slack/notifications{?since,all,participating}",
"open_issues": 12,
"open_issues_count": 12,
"owner": {
"avatar_url": "https://avatars1.githubusercontent.com/u/65077766?v=4",
"events_url": "https://api.github.com/users/act10ns/events{/privacy}",
"followers_url": "https://api.github.com/users/act10ns/followers",
"following_url": "https://api.github.com/users/act10ns/following{/other_user}",
"gists_url": "https://api.github.com/users/act10ns/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/act10ns",
"id": 65077766,
"login": "act10ns",
"node_id": "MDEyOk9yZ2FuaXphdGlvbjY1MDc3NzY2",
"organizations_url": "https://api.github.com/users/act10ns/orgs",
"received_events_url": "https://api.github.com/users/act10ns/received_events",
"repos_url": "https://api.github.com/users/act10ns/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/act10ns/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/act10ns/subscriptions",
"type": "Organization",
"url": "https://api.github.com/users/act10ns"
},
"private": false,
"pulls_url": "https://api.github.com/repos/act10ns/slack/pulls{/number}",
"pushed_at": "2020-11-12T23:04:39Z",
"releases_url": "https://api.github.com/repos/act10ns/slack/releases{/id}",
"size": 1424,
"ssh_url": "[email protected]:act10ns/slack.git",
"stargazers_count": 22,
"stargazers_url": "https://api.github.com/repos/act10ns/slack/stargazers",
"statuses_url": "https://api.github.com/repos/act10ns/slack/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/act10ns/slack/subscribers",
"subscription_url": "https://api.github.com/repos/act10ns/slack/subscription",
"svn_url": "https://github.com/act10ns/slack",
"tags_url": "https://api.github.com/repos/act10ns/slack/tags",
"teams_url": "https://api.github.com/repos/act10ns/slack/teams",
"trees_url": "https://api.github.com/repos/act10ns/slack/git/trees{/sha}",
"updated_at": "2020-11-12T23:02:42Z",
"url": "https://api.github.com/repos/act10ns/slack",
"watchers": 22,
"watchers_count": 22
},
"sender": {
"avatar_url": "https://avatars0.githubusercontent.com/u/615057?v=4",
"events_url": "https://api.github.com/users/satterly/events{/privacy}",
"followers_url": "https://api.github.com/users/satterly/followers",
"following_url": "https://api.github.com/users/satterly/following{/other_user}",
"gists_url": "https://api.github.com/users/satterly/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/satterly",
"id": 615057,
"login": "satterly",
"node_id": "MDQ6VXNlcjYxNTA1Nw==",
"organizations_url": "https://api.github.com/users/satterly/orgs",
"received_events_url": "https://api.github.com/users/satterly/received_events",
"repos_url": "https://api.github.com/users/satterly/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/satterly/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/satterly/subscriptions",
"type": "User",
"url": "https://api.github.com/users/satterly"
},
"workflow": ".github/workflows/manual.yml"
}
3 changes: 3 additions & 0 deletions __tests__/fixtures/schedule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"schedule": "*/15 * * * *"
}
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import send from './slack'

async function run(): Promise<void> {

try {
const url = process.env.SLACK_WEBHOOK_URL as string
const jobName = process.env.GITHUB_JOB as string
Expand Down
7 changes: 7 additions & 0 deletions src/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ async function send(
jobSteps: object,
channel?: string
): Promise<IncomingWebhookResult> {

core.debug('******** ENVVAR ********')
for (var k of Object.keys(process.env).sort()) {
core.debug(`${k} = ${process.env[k]}`)
}

core.debug('******** PAYLOAD ********')
core.debug(JSON.stringify(context.payload, null, 2))

const workflow = context.workflow
Expand Down

0 comments on commit ddd0517

Please sign in to comment.