Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement create-slack-message #20

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
id: npm-ci-test
run: npm run ci-test

test-action:
create-slack-message:
name: GitHub Actions Test
runs-on: ubuntu-latest

Expand All @@ -53,12 +53,10 @@ jobs:
id: checkout
uses: actions/checkout@v4

- name: Test Local Action
id: test-action
- name: Create message for Slack posts
id: create-message
uses: ./
with:
milliseconds: 2000

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: echo "${{ steps.create-message.outputs.message }}"
63 changes: 3 additions & 60 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,19 @@
*/

import * as core from '@actions/core'
import * as main from '../src/main'
// import * as main from '../src/main'

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

// Other utilities
const timeRegex = /^\d{2}:\d{2}:\d{2}/
// const runMock = jest.spyOn(main, 'run')

// Mock the GitHub Actions core library
let debugMock: jest.SpiedFunction<typeof core.debug>

Check failure on line 16 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'debugMock' is assigned a value but never used
let errorMock: jest.SpiedFunction<typeof core.error>

Check failure on line 17 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'errorMock' is assigned a value but never used
let getInputMock: jest.SpiedFunction<typeof core.getInput>

Check failure on line 18 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'getInputMock' is assigned a value but never used
let setFailedMock: jest.SpiedFunction<typeof core.setFailed>

Check failure on line 19 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'setFailedMock' is assigned a value but never used
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>

Check failure on line 20 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'setOutputMock' is assigned a value but never used

describe('action', () => {
describe.skip('action', () => {

Check warning on line 22 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Disabled test suite
beforeEach(() => {
jest.clearAllMocks()

Expand All @@ -32,58 +29,4 @@
setFailedMock = jest.spyOn(core, 'setFailed').mockImplementation()
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('sets the time output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
default:
return ''
}
})

await main.run()
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)
)
expect(errorMock).not.toHaveBeenCalled()
})

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})

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'
)
expect(errorMock).not.toHaveBeenCalled()
})
})
25 changes: 0 additions & 25 deletions __tests__/wait.test.ts

This file was deleted.

12 changes: 4 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'
name: 'GitHub notice to Slack'
description:
'This workflow is triggered by the opening of a pull request and notifies
users assigned as reviewers via mention on Slack.'

# Define your inputs here.
inputs:
Expand Down
184 changes: 180 additions & 4 deletions package-lock.json

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

Loading
Loading