enable un unchecked indexed access

This commit is contained in:
Matthew Costabile
2023-02-27 13:15:25 +00:00
parent 11ef9e1e8d
commit 5f0c606906
9 changed files with 224 additions and 222 deletions

View File

@@ -1,20 +1,20 @@
--- ---
name: "@actions/core" name: '@actions/core'
version: 1.10.0 version: 1.10.0
type: npm type: npm
summary: Actions core lib summary: Actions core lib
homepage: https://github.com/actions/toolkit/tree/main/packages/core homepage: https://github.com/actions/toolkit/tree/main/packages/core
license: mit license: mit
licenses: licenses:
- sources: LICENSE.md - sources: LICENSE.md
text: |- text: |-
The MIT License (MIT) The MIT License (MIT)
Copyright 2019 GitHub Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: [] notices: []

View File

@@ -6,15 +6,15 @@ summary: RFC4122 (v1, v4, and v5) UUIDs
homepage: homepage:
license: mit license: mit
licenses: licenses:
- sources: LICENSE.md - sources: LICENSE.md
text: | text: |
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2010-2020 Robert Kieffer and other contributors Copyright (c) 2010-2020 Robert Kieffer and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
notices: [] notices: []

View File

@@ -144,6 +144,7 @@ Using these events ensure that a given issue or pull request, in the workflow's
_See [Encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for more information_ _See [Encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for more information_
## Setting a specific status or column name to the project item ## Setting a specific status or column name to the project item
If you want to add an issue to a custom default column in a project (i.e. other than 'Todo'), you can do this directly via the project UI. You don't need to add anything else to your YAML workflow file to get this to work. If you want to add an issue to a custom default column in a project (i.e. other than 'Todo'), you can do this directly via the project UI. You don't need to add anything else to your YAML workflow file to get this to work.
Use the [Add To GitHub Projects](https://github.com/marketplace/actions/add-to-github-projects) action to assign newly opened issues to the project. And then in the project UI simply [specify which column to use as the default](https://docs.github.com/en/issues/planning-and-tracking-with-projects/learning-about-projects/quickstart-for-projects#configure-built-in-automation)! Use the [Add To GitHub Projects](https://github.com/marketplace/actions/add-to-github-projects) action to assign newly opened issues to the project. And then in the project UI simply [specify which column to use as the default](https://docs.github.com/en/issues/planning-and-tracking-with-projects/learning-about-projects/quickstart-for-projects#configure-built-in-automation)!

View File

@@ -13,7 +13,7 @@ describe('addToProject', () => {
beforeEach(() => { beforeEach(() => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token' 'github-token': 'gh_token',
}) })
outputs = mockSetOutput() outputs = mockSetOutput()
@@ -30,14 +30,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -46,21 +46,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -74,14 +74,14 @@ describe('addToProject', () => {
number: 2221, number: 2221,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/octokit/octokit.js/issues/2221' html_url: 'https://github.com/octokit/octokit.js/issues/2221',
}, },
repository: { repository: {
name: 'octokit.js', name: 'octokit.js',
owner: { owner: {
login: 'octokit' login: 'octokit',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -90,21 +90,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2DraftIssue/, test: /addProjectV2DraftIssue/,
return: { return: {
addProjectV2DraftIssue: { addProjectV2DraftIssue: {
projectItem: { projectItem: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -116,7 +116,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new' labeled: 'bug, new',
}) })
github.context.payload = { github.context.payload = {
@@ -124,14 +124,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -140,21 +140,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -166,7 +166,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new' labeled: 'bug, new',
}) })
github.context.payload = { github.context.payload = {
@@ -175,14 +175,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/pull/136' html_url: 'https://github.com/actions/add-to-project/pull/136',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -191,21 +191,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -217,7 +217,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug' labeled: 'bug',
}) })
github.context.payload = { github.context.payload = {
@@ -225,14 +225,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [], labels: [],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
@@ -247,7 +247,7 @@ describe('addToProject', () => {
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new', labeled: 'bug, new',
'label-operator': 'AND' 'label-operator': 'AND',
}) })
github.context.payload = { github.context.payload = {
@@ -255,14 +255,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}, {name: 'new'}], labels: [{name: 'bug'}, {name: 'new'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -271,21 +271,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -298,7 +298,7 @@ describe('addToProject', () => {
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new', labeled: 'bug, new',
'label-operator': 'AND' 'label-operator': 'AND',
}) })
github.context.payload = { github.context.payload = {
@@ -306,14 +306,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}, {name: 'other'}], labels: [{name: 'bug'}, {name: 'other'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
@@ -328,7 +328,7 @@ describe('addToProject', () => {
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new', labeled: 'bug, new',
'label-operator': 'NOT' 'label-operator': 'NOT',
}) })
github.context.payload = { github.context.payload = {
@@ -336,14 +336,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
@@ -358,7 +358,7 @@ describe('addToProject', () => {
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new', labeled: 'bug, new',
'label-operator': 'NOT' 'label-operator': 'NOT',
}) })
github.context.payload = { github.context.payload = {
@@ -366,14 +366,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'other'}], labels: [{name: 'other'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -382,21 +382,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-next-id' id: 'project-next-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-next-item-id' id: 'project-next-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -408,7 +408,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'accessibility,backend,bug' labeled: 'accessibility,backend,bug',
}) })
github.context.payload = { github.context.payload = {
@@ -416,14 +416,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'accessibility'}, {name: 'backend'}], labels: [{name: 'accessibility'}, {name: 'backend'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const gqlMock = mockGraphQL( const gqlMock = mockGraphQL(
@@ -432,21 +432,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
@@ -464,7 +464,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'accessibility, backend, bug' labeled: 'accessibility, backend, bug',
}) })
github.context.payload = { github.context.payload = {
@@ -472,21 +472,21 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'data'}, {name: 'frontend'}, {name: 'improvement'}], labels: [{name: 'data'}, {name: 'frontend'}, {name: 'improvement'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
const gqlMock = mockGraphQL() const gqlMock = mockGraphQL()
await addToProject() await addToProject()
expect(infoSpy).toHaveBeenCalledWith( expect(infoSpy).toHaveBeenCalledWith(
`Skipping issue 1 because it does not have one of the labels: accessibility, backend, bug` `Skipping issue 1 because it does not have one of the labels: accessibility, backend, bug`,
) )
expect(gqlMock).not.toHaveBeenCalled() expect(gqlMock).not.toHaveBeenCalled()
}) })
@@ -495,7 +495,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'accessibility , backend ,, . , bug' labeled: 'accessibility , backend ,, . , bug',
}) })
github.context.payload = { github.context.payload = {
@@ -504,14 +504,14 @@ describe('addToProject', () => {
labels: [{name: 'accessibility'}, {name: 'backend'}, {name: 'bug'}], labels: [{name: 'accessibility'}, {name: 'backend'}, {name: 'bug'}],
'label-operator': 'AND', 'label-operator': 'AND',
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const gqlMock = mockGraphQL( const gqlMock = mockGraphQL(
@@ -520,21 +520,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
@@ -551,7 +551,7 @@ describe('addToProject', () => {
test(`throws an error when url isn't a valid project url`, async () => { test(`throws an error when url isn't a valid project url`, async () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/github/repositories', 'project-url': 'https://github.com/orgs/github/repositories',
'github-token': 'gh_token' 'github-token': 'gh_token',
}) })
github.context.payload = { github.context.payload = {
@@ -559,20 +559,20 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [], labels: [],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
const gqlMock = mockGraphQL() const gqlMock = mockGraphQL()
await expect(addToProject()).rejects.toThrow( await expect(addToProject()).rejects.toThrow(
'https://github.com/orgs/github/repositories. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>' 'https://github.com/orgs/github/repositories. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>',
) )
expect(infoSpy).not.toHaveBeenCalled() expect(infoSpy).not.toHaveBeenCalled()
expect(gqlMock).not.toHaveBeenCalled() expect(gqlMock).not.toHaveBeenCalled()
@@ -581,7 +581,7 @@ describe('addToProject', () => {
test(`throws an error when url isn't under the github.com domain`, async () => { test(`throws an error when url isn't under the github.com domain`, async () => {
mockGetInput({ mockGetInput({
'project-url': 'https://notgithub.com/orgs/github/projects/1', 'project-url': 'https://notgithub.com/orgs/github/projects/1',
'github-token': 'gh_token' 'github-token': 'gh_token',
}) })
github.context.payload = { github.context.payload = {
@@ -589,20 +589,20 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [], labels: [],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const infoSpy = jest.spyOn(core, 'info') const infoSpy = jest.spyOn(core, 'info')
const gqlMock = mockGraphQL() const gqlMock = mockGraphQL()
await expect(addToProject()).rejects.toThrow( await expect(addToProject()).rejects.toThrow(
'https://notgithub.com/orgs/github/projects/1. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>' 'https://notgithub.com/orgs/github/projects/1. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>',
) )
expect(infoSpy).not.toHaveBeenCalled() expect(infoSpy).not.toHaveBeenCalled()
expect(gqlMock).not.toHaveBeenCalled() expect(gqlMock).not.toHaveBeenCalled()
@@ -612,7 +612,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new' labeled: 'bug, new',
}) })
github.context.payload = { github.context.payload = {
@@ -620,14 +620,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
const gqlMock = mockGraphQL( const gqlMock = mockGraphQL(
@@ -636,28 +636,28 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
expect(gqlMock).toHaveBeenNthCalledWith(1, expect.stringContaining('organization(login: $projectOwnerName)'), { expect(gqlMock).toHaveBeenNthCalledWith(1, expect.stringContaining('organization(login: $projectOwnerName)'), {
projectOwnerName: 'actions', projectOwnerName: 'actions',
projectNumber: 1 projectNumber: 1,
}) })
}) })
@@ -665,7 +665,7 @@ describe('addToProject', () => {
mockGetInput({ mockGetInput({
'project-url': 'https://github.com/users/monalisa/projects/1', 'project-url': 'https://github.com/users/monalisa/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'bug, new' labeled: 'bug, new',
}) })
github.context.payload = { github.context.payload = {
@@ -673,14 +673,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'bug'}], labels: [{name: 'bug'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/monalisa/add-to-project/issues/74' html_url: 'https://github.com/monalisa/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'monalisa' login: 'monalisa',
} },
} },
} }
const gqlMock = mockGraphQL( const gqlMock = mockGraphQL(
@@ -689,28 +689,28 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-id' id: 'project-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-item-id' id: 'project-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
expect(gqlMock).toHaveBeenNthCalledWith(1, expect.stringContaining('user(login: $projectOwnerName)'), { expect(gqlMock).toHaveBeenNthCalledWith(1, expect.stringContaining('user(login: $projectOwnerName)'), {
projectOwnerName: 'monalisa', projectOwnerName: 'monalisa',
projectNumber: 1 projectNumber: 1,
}) })
}) })
@@ -719,7 +719,7 @@ describe('addToProject', () => {
'project-url': 'https://github.com/orgs/actions/projects/1', 'project-url': 'https://github.com/orgs/actions/projects/1',
'github-token': 'gh_token', 'github-token': 'gh_token',
labeled: 'FOO, Bar, baz', labeled: 'FOO, Bar, baz',
'label-operator': 'AND' 'label-operator': 'AND',
}) })
github.context.payload = { github.context.payload = {
@@ -727,14 +727,14 @@ describe('addToProject', () => {
number: 1, number: 1,
labels: [{name: 'foo'}, {name: 'BAR'}, {name: 'baz'}], labels: [{name: 'foo'}, {name: 'BAR'}, {name: 'baz'}],
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
html_url: 'https://github.com/actions/add-to-project/issues/74' html_url: 'https://github.com/actions/add-to-project/issues/74',
}, },
repository: { repository: {
name: 'add-to-project', name: 'add-to-project',
owner: { owner: {
login: 'actions' login: 'actions',
} },
} },
} }
mockGraphQL( mockGraphQL(
@@ -743,21 +743,21 @@ describe('addToProject', () => {
return: { return: {
organization: { organization: {
projectV2: { projectV2: {
id: 'project-next-id' id: 'project-next-id',
} },
} },
} },
}, },
{ {
test: /addProjectV2ItemById/, test: /addProjectV2ItemById/,
return: { return: {
addProjectV2ItemById: { addProjectV2ItemById: {
item: { item: {
id: 'project-next-item-id' id: 'project-next-item-id',
} },
} },
} },
} },
) )
await addToProject() await addToProject()
@@ -810,7 +810,7 @@ function mockGraphQL(...mocks: {test: RegExp; return: unknown}[]): jest.Mock {
jest.spyOn(github, 'getOctokit').mockImplementation(() => { jest.spyOn(github, 'getOctokit').mockImplementation(() => {
return { return {
graphql: mock graphql: mock,
} as unknown as ReturnType<typeof github.getOctokit> } as unknown as ReturnType<typeof github.getOctokit>
}) })

8
dist/index.js generated vendored
View File

@@ -101,7 +101,7 @@ function addToProject() {
} }
}`, { }`, {
projectOwnerName, projectOwnerName,
projectNumber projectNumber,
}); });
const projectId = (_j = idResp[ownerTypeQuery]) === null || _j === void 0 ? void 0 : _j.projectV2.id; const projectId = (_j = idResp[ownerTypeQuery]) === null || _j === void 0 ? void 0 : _j.projectV2.id;
const contentId = issue === null || issue === void 0 ? void 0 : issue.node_id; const contentId = issue === null || issue === void 0 ? void 0 : issue.node_id;
@@ -121,8 +121,8 @@ function addToProject() {
}`, { }`, {
input: { input: {
projectId, projectId,
contentId contentId,
} },
}); });
core.setOutput('itemId', addResp.addProjectV2ItemById.item.id); core.setOutput('itemId', addResp.addProjectV2ItemById.item.id);
} }
@@ -139,7 +139,7 @@ function addToProject() {
} }
}`, { }`, {
projectId, projectId,
title: issue === null || issue === void 0 ? void 0 : issue.html_url title: issue === null || issue === void 0 ? void 0 : issue.html_url,
}); });
core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id); core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id);
} }

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@@ -3,7 +3,7 @@ module.exports = {
moduleFileExtensions: ['js', 'ts'], moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/*.test.ts'], testMatch: ['**/*.test.ts'],
transform: { transform: {
'^.+\\.ts$': 'ts-jest' '^.+\\.ts$': 'ts-jest',
}, },
verbose: true verbose: true,
} }

View File

@@ -79,7 +79,7 @@ export async function addToProject(): Promise<void> {
if (!urlMatch) { if (!urlMatch) {
throw new Error( throw new Error(
`Invalid project URL: ${projectUrl}. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>` `Invalid project URL: ${projectUrl}. Project URL should match the format https://github.com/<orgs-or-users>/<ownerName>/projects/<projectNumber>`,
) )
} }
@@ -103,8 +103,8 @@ export async function addToProject(): Promise<void> {
}`, }`,
{ {
projectOwnerName, projectOwnerName,
projectNumber projectNumber,
} },
) )
const projectId = idResp[ownerTypeQuery]?.projectV2.id const projectId = idResp[ownerTypeQuery]?.projectV2.id
@@ -130,9 +130,9 @@ export async function addToProject(): Promise<void> {
{ {
input: { input: {
projectId, projectId,
contentId contentId,
} },
} },
) )
core.setOutput('itemId', addResp.addProjectV2ItemById.item.id) core.setOutput('itemId', addResp.addProjectV2ItemById.item.id)
@@ -152,8 +152,8 @@ export async function addToProject(): Promise<void> {
}`, }`,
{ {
projectId, projectId,
title: issue?.html_url title: issue?.html_url,
} },
) )
core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id) core.setOutput('itemId', addResp.addProjectV2DraftIssue.projectItem.id)

View File

@@ -6,7 +6,8 @@
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
"strict": true /* Enable all strict type-checking options. */, "strict": true /* Enable all strict type-checking options. */,
"noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"noUncheckedIndexedAccess": true
}, },
"exclude": ["node_modules", "**/*.test.ts"] "exclude": ["node_modules", "**/*.test.ts"]
} }