Skip to content

Commit

Permalink
Define our inputs and strip template implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
simu committed Oct 31, 2023
1 parent 9f67f7a commit dc43db6
Show file tree
Hide file tree
Showing 11 changed files with 23,612 additions and 422 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,3 @@ jobs:
- name: Test Local Action
id: test-action
uses: ./
with:
milliseconds: 1000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
3 changes: 0 additions & 3 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
pull_request:
branches:
- main
push:
branches-ignore:
- main

jobs:
lint:
Expand Down
35 changes: 13 additions & 22 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ import * as main from '../src/main'
const debugMock = jest.spyOn(core, 'debug')
const getInputMock = jest.spyOn(core, 'getInput')
const setFailedMock = jest.spyOn(core, 'setFailed')
const setOutputMock = jest.spyOn(core, 'setOutput')

// Mock the action's main function
const runMock = jest.spyOn(main, 'run')

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()
Expand All @@ -30,8 +26,12 @@ describe('action', () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'milliseconds':
return '500'
case 'patch-label':
return 'patch'
case 'minor-label':
return 'bump:minor'
case 'major-label':
return 'bump:major'
default:
return ''
}
Expand All @@ -41,28 +41,20 @@ describe('action', () => {
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
'Using patch, bump:minor, bump:major to determine SemVer bump ...'
)
})

it('sets a failed status', async () => {
it('raises an error on an empty input', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
case 'patch-label':
return 'patch'
case 'minor-label':
return 'bump:minor'
default:
return ''
}
Expand All @@ -71,10 +63,9 @@ describe('action', () => {
await main.run()
expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
"Empty bump labels aren't supported"
)
})
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

28 changes: 15 additions & 13 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'SemVer tags from PR labels'
description: 'This action creates SemVer tags from PR labels'
author: 'VSHN AG'

# Define your inputs here.
inputs:
milliseconds:
description: 'Your input description here'
required: true
default: '1000'

# Define your outputs here.
outputs:
time:
description: 'Your output description here'
patch-label:
description: 'Label which indicates a patch-level SemVer bump'
required: false
default: 'bump:patch'
minor-label:
description: 'Label which indicates a minor-level SemVer bump'
required: false
default: 'bump:minor'
major-label:
description: 'Label which indicates a major-level SemVer bump'
required: false
default: 'bump:major'

runs:
using: node20
Expand Down
Loading

0 comments on commit dc43db6

Please sign in to comment.