Skip to content

Commit

Permalink
Rename inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
ncalteen committed Sep 24, 2023
1 parent a81d48b commit c281302
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/issue-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ jobs:
id: validate
uses: issue-ops/validator@main
with:
issue_form_template: example-template.yml
parsed_issue_body: ${{ steps.parse.outputs.json }}
issue-form-template: example-template.yml
parsed-issue-body: ${{ steps.parse.outputs.json }}
workspace: ${{ github.workspace }}

- name: Output Validation Results
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ jobs:
id: validate
uses: issue-ops/[email protected]
with:
issue_form_template: example-template.yml
issue_number: ${{ github.event.issue.number }}
parsed_issue_body: ${{ steps.parse.outputs.json }}
issue-form-template: example-template.yml
issue-number: ${{ github.event.issue.number }}
parsed-issue-body: ${{ steps.parse.outputs.json }}
workspace: ${{ github.workspace }}

- if: ${{ steps.validate.outputs.result == 'failure' }}
Expand Down
86 changes: 43 additions & 43 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ describe('main', () => {
it('retrieves the inputs', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'false'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand All @@ -67,22 +67,22 @@ describe('main', () => {

await main.run()

expect(core.getInput).toHaveBeenCalledWith('add_comment', {
expect(core.getInput).toHaveBeenCalledWith('add-comment', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('issue_number', {
expect(core.getInput).toHaveBeenCalledWith('issue-number', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('issue_form_template', {
expect(core.getInput).toHaveBeenCalledWith('issue-form-template', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('parsed_issue_body', {
expect(core.getInput).toHaveBeenCalledWith('parsed-issue-body', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('repository', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('github_token', {
expect(core.getInput).toHaveBeenCalledWith('github-token', {
required: true
})
expect(core.getInput).toHaveBeenCalledWith('workspace', { required: true })
Expand All @@ -91,15 +91,15 @@ describe('main', () => {
it('fails when the issue form template does not exist', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'false'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand All @@ -119,18 +119,18 @@ describe('main', () => {
)
})

it('does not add a comment when add_comment is false', async () => {
it('does not add a comment when add-comment is false', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'false'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand Down Expand Up @@ -192,18 +192,18 @@ describe('main', () => {
expect(mocktokit.rest.issues.createComment).not.toHaveBeenCalled()
})

it('adds a failure comment when add_comment is true', async () => {
it('adds a failure comment when add-comment is true', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'true'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand Down Expand Up @@ -279,15 +279,15 @@ describe('main', () => {
it('adds a default failure comment if no template is provided', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'true'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand Down Expand Up @@ -352,18 +352,18 @@ describe('main', () => {
expect(mocktokit.rest.issues.createComment).toHaveBeenCalled()
})

it('adds a success comment when add_comment is true', async () => {
it('adds a success comment when add-comment is true', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'true'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand Down Expand Up @@ -438,15 +438,15 @@ describe('main', () => {
it('adds a default success comment if no template is provided', async () => {
jest.spyOn(core, 'getInput').mockImplementation((name: string) => {
switch (name) {
case 'add_comment':
case 'add-comment':
return 'true'
case 'github_token':
case 'github-token':
return '12345'
case 'issue_form_template':
case 'issue-form-template':
return 'example-request.yml'
case 'issue_number':
case 'issue-number':
return '1'
case 'parsed_issue_body':
case 'parsed-issue-body':
return parsedIssue
case 'repository':
return 'issue-ops/validator'
Expand Down
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ branding:
color: blue

inputs:
add_comment:
add-comment:
description: Whether to comment on the issue with a success/failure message
required: false
default: 'true'
github_token:
github-token:
description: The GitHub API token to use
required: false
default: ${{ github.token }}
issue_form_template:
issue-form-template:
description: The issue form template file name (e.g. `new-repository.yml`)
required: true
issue_number:
issue-number:
description: The issue number
required: true
default: ${{ github.event.issue.number }}
parsed_issue_body:
parsed-issue-body:
description: The issue body parsed by `issue-ops/parser`
required: true
default: ${{ github.event.issue.body }}
Expand Down
10 changes: 5 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ import { validate } from './validate'
export async function run(): Promise<void> {
// Get inputs
const addComment: boolean =
core.getInput('add_comment', {
core.getInput('add-comment', {
required: true
}) === 'true'
const issueNumber: number = parseInt(
core.getInput('issue_number', { required: true }),
core.getInput('issue-number', { required: true }),
10
)
const parsedIssue: ParsedBody = JSON.parse(
core.getInput('parsed_issue_body', { required: true })
core.getInput('parsed-issue-body', { required: true })
)
const repository: string = core.getInput('repository', {
required: true
})
const template: string = core.getInput('issue_form_template', {
const template: string = core.getInput('issue-form-template', {
required: true
})
const token: string = core.getInput('github_token', { required: true })
const token: string = core.getInput('github-token', { required: true })
const workspace: string = core
.getInput('workspace', { required: true })
.replace(/\/+$/, '') // Remove trailing slashes
Expand Down

0 comments on commit c281302

Please sign in to comment.