This repository has been archived by the owner on May 1, 2024. It is now read-only.
generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Sibz/releases/next
Releases/next
- Loading branch information
Showing
11 changed files
with
364 additions
and
111 deletions.
There are no files selected for viewing
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,14 @@ | ||
name: "smoke-screen-tests" | ||
on: | ||
push: | ||
branches-ignore: | ||
- master | ||
|
||
jobs: | ||
sst: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- run: | | ||
npm install | ||
npm test |
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
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
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,106 @@ | ||
import test from 'ava'; | ||
import makeStatusRequest, { CoreActionsForTesting, CommitState, ERR_INVALID_OWNER, ERR_INVALID_STATE} from '../src/makeStatusRequest' | ||
import inputNames from '../src/inputNames' | ||
|
||
const INPUT_CONTEXT = "test context"; | ||
const INPUT_OWNER = "TestOwner"; | ||
const INPUT_OWNER_INVALID = "-TestOwner"; | ||
const INPUT_REPOSITORY = "Test.Repository-1"; | ||
const INPUT_REPOSITORY_WITHOWNER = INPUT_OWNER + "/Test.Repository-1"; | ||
const INPUT_STATE: CommitState = "success"; | ||
const INPUT_STATE_INVALID: CommitState = "failed" as CommitState; | ||
const INPUT_DESC = "Test Description"; | ||
const INPUT_SHA = "TestSHA"; | ||
const INPUT_TARGETURL = "test/uri"; | ||
|
||
const actionsCore: CoreActionsForTesting = { | ||
getInput: (arg:string) => { | ||
switch(arg) { | ||
case inputNames.context: | ||
return INPUT_CONTEXT; | ||
case inputNames.owner: | ||
return INPUT_OWNER; | ||
case inputNames.repo: | ||
return INPUT_REPOSITORY; | ||
case inputNames.state: | ||
return INPUT_STATE; | ||
case inputNames.desc: | ||
return INPUT_DESC; | ||
case inputNames.sha: | ||
return INPUT_SHA; | ||
case inputNames.target_url: | ||
return INPUT_TARGETURL; | ||
default: | ||
return "input not in test mock"; | ||
} | ||
} | ||
} | ||
const actionsCoreAlt1: CoreActionsForTesting = { | ||
getInput: (arg:string) => { | ||
switch(arg) { | ||
case inputNames.repo: | ||
return INPUT_REPOSITORY_WITHOWNER; | ||
default: | ||
return actionsCore.getInput(arg); | ||
} | ||
} | ||
} | ||
|
||
const actionsCoreAlt2: CoreActionsForTesting = { | ||
getInput: (arg:string) => { | ||
switch(arg) { | ||
case inputNames.owner: | ||
return INPUT_OWNER_INVALID; | ||
default: | ||
return actionsCore.getInput(arg); | ||
} | ||
} | ||
} | ||
|
||
const actionsCoreAlt3: CoreActionsForTesting = { | ||
getInput: (arg:string) => { | ||
switch(arg) { | ||
case inputNames.state: | ||
return INPUT_STATE_INVALID; | ||
default: | ||
return actionsCore.getInput(arg); | ||
} | ||
} | ||
} | ||
|
||
|
||
test("should getInput context", t=> { | ||
t.is(makeStatusRequest(actionsCore).context, INPUT_CONTEXT); | ||
}); | ||
test("should getInput owner", t=> { | ||
t.is(makeStatusRequest(actionsCore).owner, INPUT_OWNER); | ||
}); | ||
test("should getInput repo", t=> { | ||
t.is(makeStatusRequest(actionsCore).repo, INPUT_REPOSITORY); | ||
}); | ||
test("should getInput state", t=> { | ||
t.is(makeStatusRequest(actionsCore).state, INPUT_STATE); | ||
}); | ||
test("should getInput description", t=> { | ||
t.is(makeStatusRequest(actionsCore).description, INPUT_DESC); | ||
}); | ||
test("should getInput sha", t=> { | ||
t.is(makeStatusRequest(actionsCore).sha, INPUT_SHA); | ||
}); | ||
test("should getInput target_url", t=> { | ||
t.is(makeStatusRequest(actionsCore).target_url, INPUT_TARGETURL); | ||
}); | ||
|
||
test("should getInput repo and remove leading owner name", t=> { | ||
t.is(makeStatusRequest(actionsCoreAlt1).repo, INPUT_REPOSITORY); | ||
}); | ||
|
||
test("when owner is not a valid GitHub username, should throw", t=> { | ||
let err = t.throws(()=> makeStatusRequest(actionsCoreAlt2)); | ||
t.is(err.message, ERR_INVALID_OWNER) | ||
}); | ||
|
||
test("should validate state", t=> { | ||
let err = t.throws(()=> makeStatusRequest(actionsCoreAlt3)); | ||
t.is(err.message, ERR_INVALID_STATE) | ||
}); |
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 |
---|---|---|
@@ -1,31 +1,39 @@ | ||
name: 'github-status-action' | ||
description: 'Adds a check status on a commit, github reports the last status added for a particular context.' | ||
description: 'Adds a check status on a commit, GitHub reports the last status added for a particular context.' | ||
author: 'Sibz@EntityZero' | ||
branding: | ||
icon: 'check' | ||
color: 'green' | ||
inputs: | ||
authToken: | ||
description: 'Use secrets.GITHUB_TOKEN or your own token if you need to trigger other workflows the use "on: status"' | ||
required: true | ||
state: | ||
description: 'The status of the check: success, error, failure or pending' | ||
required: true | ||
context: | ||
description: 'The context, this is displayed as the name of the check' | ||
required: true | ||
default: 'default' | ||
required: false | ||
description: | ||
description: 'Short text explaining the status of the check' | ||
required: true | ||
state: | ||
description: 'The status of the check: success, error, failure or pending' | ||
required: true | ||
default: '' | ||
required: false | ||
owner: | ||
description: 'Repostory onwer, defaults to context github.repository_owner if ommited' | ||
description: 'Repostory onwer, defaults to context github.repository_owner if omited' | ||
default: ${{ github.repository_owner }} | ||
required: false | ||
repository: | ||
description: 'Repository, default to context github.repository if ommited' | ||
description: 'Repository, default to context github.repository if omited' | ||
default: ${{ github.repository }} | ||
required: false | ||
sha: | ||
description: 'SHA of commit to update status on, defaults to context github.sha' | ||
default: ${{ github.sha }} | ||
required: false | ||
target_url: | ||
description: 'URL/URI to use for further details.' | ||
required: false | ||
runs: | ||
using: 'node12' | ||
main: 'dist/index.js' |
Oops, something went wrong.