8000 input: PR options ignore title and check PR commits · openmsa/commit-message-checker@883f3ba · GitHub
[go: up one dir, main page]

Skip to content

Commit 883f3ba

Browse files
committed
input: PR options ignore title and check PR commits
this make it possible to igore partially or completely the PR payload. The commits associated with the pull request can be checked instead of checking the pull request payload. The parameter are: - excludeTitle: 'true | false' - excludeDescription: 'true | false' - checkAllCommitMessages: 'true | false' by default, all options comes false.
1 parent c688892 commit 883f3ba

File tree

6 files changed

+1990
-30
lines changed

6 files changed

+1990
-30
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v1
14-
- run: |
14+
- name: Build & Test
15+
env:
16+
ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17+
run: |
1518
npm install
1619
npm run all
20+
1721
test: # make sure the action works on a clean machine without building
1822
runs-on: ubuntu-latest
1923
steps:

__tests__/input-helper.test.ts

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ describe('input-helper tests', () => {
178178
}
179179
inputs.pattern = 'some-pattern'
180180
inputs.error = 'some-error'
181-
inputs.excludeDescription = '1'
181+
inputs.excludeDescription = 'true'
182182
const checkerArguments: ICheckerArguments = await inputHelper.getInputs()
183183
expect(checkerArguments).toBeTruthy()
184184
expect(checkerArguments.pattern).toBe('some-pattern')
@@ -187,6 +187,80 @@ describe('input-helper tests', () => {
187187
expect(checkerArguments.messages[0]).toBe('some-title')
188188
})
189189

190+
it('excludes pull_request title', async () => {
191+
mockGitHub.context = {
192+
eventName: 'pull_request',
193+
payload: {
194+
pull_request: {
195+
title: 'some-title',
196+
body: 'some-body'
197+
}
198+
}
199+
}
200+
inputs.pattern = 'some-pattern'
201+
inputs.error = 'some-error'
202+
inputs.excludeTitle = 'true'
203+
const checkerArguments: ICheckerArguments = await inputHelper.getInputs()
204+
expect(checkerArguments).toBeTruthy()
205+
expect(checkerArguments.pattern).toBe('some-pattern')
206+
expect(checkerArguments.error).toBe('some-error')
207+
expect(checkerArguments.messages).toBeTruthy()
208+
expect(checkerArguments.messages[0]).toBe('some-body')
209+
})
210+
211+
it('excludes pull_request title and body', async () => {
212+
mockGitHub.context = {
213+
eventName: 'pull_request',
214+
payload: {
215+
pull_request: {
216+
title: 'some-title',
217+
body: 'some-body'
218+
}
219+
}
220+
}
221+
inputs.pattern = 'some-pattern'
222+
inputs.error = 'some-error'
223+
inputs.excludeDescription = 'true'
224+
inputs.excludeTitle = 'true'
225+
const checkerArguments: ICheckerArguments = await inputHelper.getInputs()
226+
expect(checkerArguments).toBeTruthy()
227+
expect(checkerArguments.pattern).toBe('some-pattern')
228+
expect(checkerArguments.error).toBe('some-error')
229+
expect(checkerArguments.messages).toBeTruthy()
230+
expect(checkerArguments.messages.length).toBe(0)
231+
})
232+
233+
it('should check pull_request commits', async () => {
234+
mockGitHub.context = {
235+
eventName: 'pull_request',
236+
payload: {
237+
pull_request: {
238+
title: 'some-title',
239+
body: 'some-body',
240+
number: 62 // This pull request has exactly two commits
241+
},
242+
repository: {
243+
owner: {
244+
name: 'TotalCross'
245+
},
246+
name: 'totalcross'
247+
}
248+
}
249+
}
250+
inputs.pattern = 'some-pattern'
251+
inputs.error = 'some-error'
252+
inputs.excludeDescription = 'true'
253+
inputs.excludeTitle = 'true'
254+
inputs.checkAllCommitMessages = 'true'
255+
inputs.accessToken = process.env.ACCESS_TOKEN
256+
const checkerArguments: ICheckerArguments = await inputHelper.getInputs()
257+
expect(checkerArguments).toBeTruthy()
258+
expect(checkerArguments.pattern).toBe('some-pattern')
259+
expect(checkerArguments.error).toBe('some-error')
260+
expect(checkerArguments.messages).toBeTruthy()
261+
expect(checkerArguments.messages.length).toBe(2)
262+
})
263+
190264
it('push payload is optional', async () => {
191265
mockGitHub.context = {
192266
eventName: 'push',

0 commit comments

Comments
 (0)
0