Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
07d3c7257a | ||
|
|
a2dda6f539 | ||
|
|
45dc50cabe |
+1
-1
@@ -16,7 +16,7 @@ If you've encountered a problem, please let us know by [submitting an issue](htt
|
|||||||
|
|
||||||
## Enhancements and feature requests
|
## Enhancements and feature requests
|
||||||
|
|
||||||
If you've got an idea for a new feature, please submit as [an issue](https://github.com/actions/dependency-review-action/issues/new) so that the community can see it, and we can discuss it there. We may not be able to respond to every single issue, but will make a best effort!
|
If you've got an idea for a new feature or a significant change to the code or its dependencies, please submit as [an issue](https://github.com/actions/dependency-review-action/issues/new) so that the community can see it, and we can discuss it there. We may not be able to respond to every single issue, but will make a best effort!
|
||||||
|
|
||||||
If you'd like to make a contribution yourself, we ask that before significant effort is put into code changes, that we have agreement that the change aligns with our strategy for the action. Since this is a verified Action owned by GitHub we want to make sure that contributions are high quality, and that they maintain consistency with the rest of the action's behavior.
|
If you'd like to make a contribution yourself, we ask that before significant effort is put into code changes, that we have agreement that the change aligns with our strategy for the action. Since this is a verified Action owned by GitHub we want to make sure that contributions are high quality, and that they maintain consistency with the rest of the action's behavior.
|
||||||
|
|
||||||
|
|||||||
@@ -124,6 +124,51 @@ test('it raises an error when no refs are provided and the event is not a pull r
|
|||||||
).toThrow()
|
).toThrow()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const pullRequestLikeEvents = [
|
||||||
|
'pull_request',
|
||||||
|
'pull_request_target',
|
||||||
|
'merge_group'
|
||||||
|
]
|
||||||
|
|
||||||
|
test.each(pullRequestLikeEvents)(
|
||||||
|
'it uses the given refs even when the event is %s',
|
||||||
|
async eventName => {
|
||||||
|
setInput('base-ref', 'a-custom-base-ref')
|
||||||
|
setInput('head-ref', 'a-custom-head-ref')
|
||||||
|
|
||||||
|
const refs = getRefs(await readConfig(), {
|
||||||
|
payload: {
|
||||||
|
pull_request: {
|
||||||
|
number: 42,
|
||||||
|
base: {sha: 'pr-base-ref'},
|
||||||
|
head: {sha: 'pr-head-ref'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eventName
|
||||||
|
})
|
||||||
|
expect(refs.base).toEqual('a-custom-base-ref')
|
||||||
|
expect(refs.head).toEqual('a-custom-head-ref')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
test.each(pullRequestLikeEvents)(
|
||||||
|
'it uses the event refs when the event is %s and the no refs are input',
|
||||||
|
async eventName => {
|
||||||
|
const refs = getRefs(await readConfig(), {
|
||||||
|
payload: {
|
||||||
|
pull_request: {
|
||||||
|
number: 42,
|
||||||
|
base: {sha: 'pr-base-ref'},
|
||||||
|
head: {sha: 'pr-head-ref'}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
eventName
|
||||||
|
})
|
||||||
|
expect(refs.base).toEqual('pr-base-ref')
|
||||||
|
expect(refs.head).toEqual('pr-head-ref')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
test('it defaults to runtime scope', async () => {
|
test('it defaults to runtime scope', async () => {
|
||||||
const config = await readConfig()
|
const config = await readConfig()
|
||||||
expect(config.fail_on_scopes).toEqual(['runtime'])
|
expect(config.fail_on_scopes).toEqual(['runtime'])
|
||||||
|
|||||||
+5
-4
@@ -315,7 +315,8 @@ function getRefs(config, context) {
|
|||||||
// If possible, source default base & head refs from the GitHub event.
|
// If possible, source default base & head refs from the GitHub event.
|
||||||
// The base/head ref from the config take priority, if provided.
|
// The base/head ref from the config take priority, if provided.
|
||||||
if (context.eventName === 'pull_request' ||
|
if (context.eventName === 'pull_request' ||
|
||||||
context.eventName === 'pull_request_target') {
|
context.eventName === 'pull_request_target' ||
|
||||||
|
context.eventName === 'merge_group') {
|
||||||
const pull_request = schemas_1.PullRequestSchema.parse(context.payload.pull_request);
|
const pull_request = schemas_1.PullRequestSchema.parse(context.payload.pull_request);
|
||||||
base_ref = base_ref || pull_request.base.sha;
|
base_ref = base_ref || pull_request.base.sha;
|
||||||
head_ref = head_ref || pull_request.head.sha;
|
head_ref = head_ref || pull_request.head.sha;
|
||||||
@@ -323,17 +324,17 @@ function getRefs(config, context) {
|
|||||||
if (!base_ref && !head_ref) {
|
if (!base_ref && !head_ref) {
|
||||||
throw new Error('Both a base ref and head ref must be provided, either via the `base_ref`/`head_ref` ' +
|
throw new Error('Both a base ref and head ref must be provided, either via the `base_ref`/`head_ref` ' +
|
||||||
'config options, `base-ref`/`head-ref` workflow action options, or by running a ' +
|
'config options, `base-ref`/`head-ref` workflow action options, or by running a ' +
|
||||||
'`pull_request`/`pull_request_target` workflow.');
|
'`pull_request`/`pull_request_target`/`merge_group` workflow.');
|
||||||
}
|
}
|
||||||
else if (!base_ref) {
|
else if (!base_ref) {
|
||||||
throw new Error('A base ref must be provided, either via the `base_ref` config option, ' +
|
throw new Error('A base ref must be provided, either via the `base_ref` config option, ' +
|
||||||
'`base-ref` workflow action option, or by running a ' +
|
'`base-ref` workflow action option, or by running a ' +
|
||||||
'`pull_request`/`pull_request_target` workflow.');
|
'`pull_request`/`pull_request_target`/`merge_group` workflow.');
|
||||||
}
|
}
|
||||||
else if (!head_ref) {
|
else if (!head_ref) {
|
||||||
throw new Error('A head ref must be provided, either via the `head_ref` config option, ' +
|
throw new Error('A head ref must be provided, either via the `head_ref` config option, ' +
|
||||||
'`head-ref` workflow action option, or by running a ' +
|
'`head-ref` workflow action option, or by running a ' +
|
||||||
'or by running a `pull_request`/`pull_request_target` workflow.');
|
'or by running a `pull_request`/`pull_request_target`/`merge_group` workflow.');
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
base: base_ref,
|
base: base_ref,
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-4
@@ -11,7 +11,8 @@ export function getRefs(
|
|||||||
// The base/head ref from the config take priority, if provided.
|
// The base/head ref from the config take priority, if provided.
|
||||||
if (
|
if (
|
||||||
context.eventName === 'pull_request' ||
|
context.eventName === 'pull_request' ||
|
||||||
context.eventName === 'pull_request_target'
|
context.eventName === 'pull_request_target' ||
|
||||||
|
context.eventName === 'merge_group'
|
||||||
) {
|
) {
|
||||||
const pull_request = PullRequestSchema.parse(context.payload.pull_request)
|
const pull_request = PullRequestSchema.parse(context.payload.pull_request)
|
||||||
base_ref = base_ref || pull_request.base.sha
|
base_ref = base_ref || pull_request.base.sha
|
||||||
@@ -22,19 +23,19 @@ export function getRefs(
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
'Both a base ref and head ref must be provided, either via the `base_ref`/`head_ref` ' +
|
'Both a base ref and head ref must be provided, either via the `base_ref`/`head_ref` ' +
|
||||||
'config options, `base-ref`/`head-ref` workflow action options, or by running a ' +
|
'config options, `base-ref`/`head-ref` workflow action options, or by running a ' +
|
||||||
'`pull_request`/`pull_request_target` workflow.'
|
'`pull_request`/`pull_request_target`/`merge_group` workflow.'
|
||||||
)
|
)
|
||||||
} else if (!base_ref) {
|
} else if (!base_ref) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'A base ref must be provided, either via the `base_ref` config option, ' +
|
'A base ref must be provided, either via the `base_ref` config option, ' +
|
||||||
'`base-ref` workflow action option, or by running a ' +
|
'`base-ref` workflow action option, or by running a ' +
|
||||||
'`pull_request`/`pull_request_target` workflow.'
|
'`pull_request`/`pull_request_target`/`merge_group` workflow.'
|
||||||
)
|
)
|
||||||
} else if (!head_ref) {
|
} else if (!head_ref) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'A head ref must be provided, either via the `head_ref` config option, ' +
|
'A head ref must be provided, either via the `head_ref` config option, ' +
|
||||||
'`head-ref` workflow action option, or by running a ' +
|
'`head-ref` workflow action option, or by running a ' +
|
||||||
'or by running a `pull_request`/`pull_request_target` workflow.'
|
'or by running a `pull_request`/`pull_request_target`/`merge_group` workflow.'
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user