Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/npm-development-3bf7…
Browse files Browse the repository at this point in the history
…eacf52
  • Loading branch information
karpikpl authored Aug 25, 2024
2 parents 31ce604 + 19beba1 commit 8794de4
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
DEFAULT_BRANCH: main
FILTER_REGEX_EXCLUDE: dist/**/*
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_TYPESCRIPT_STANDARD: false
VALIDATE_ALL_CODEBASE: true
VALIDATE_JAVASCRIPT_STANDARD: false
VALIDATE_JSCPD: false
26 changes: 14 additions & 12 deletions __tests__/azdo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ describe('Azure DevOps API tests', () => {
jest.clearAllMocks()

// mock fetch
global.fetch = jest.fn(async () =>
Promise.resolve({
json: async () => Promise.resolve(JSON.parse(adoResponse)),
status: 200
})
global.fetch = jest.fn(
async () =>
await Promise.resolve({
json: async () => await Promise.resolve(JSON.parse(adoResponse)),
status: 200
})
) as jest.Mock
})

Expand All @@ -31,7 +32,7 @@ describe('Azure DevOps API tests', () => {
)

expect(fetch).toHaveBeenCalledWith(
`https://dev.azure.com/my-org/my-project/_apis/wit/workitemsbatch?api-version=7.1-preview.1`,
'https://dev.azure.com/my-org/my-project/_apis/wit/workitemsbatch?api-version=7.1-preview.1',
expect.objectContaining({
headers: expect.objectContaining({
Authorization: `Basic ${expectedAuth}`
Expand All @@ -46,10 +47,11 @@ describe('Azure DevOps API tests', () => {
})

it('returns undefined on error', async () => {
global.fetch = jest.fn(async () =>
Promise.resolve({
status: 500
})
global.fetch = jest.fn(
async () =>
await Promise.resolve({
status: 500
})
) as jest.Mock

const workItems = await getWorkItemsBatch(
Expand All @@ -63,8 +65,8 @@ describe('Azure DevOps API tests', () => {
})

it('returns undefined on catch error', async () => {
global.fetch = jest.fn(async () =>
Promise.reject(new Error('error'))
global.fetch = jest.fn(
async () => await Promise.reject(new Error('error'))
) as jest.Mock

const workItems = await getWorkItemsBatch(
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/azdo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,5 @@ export async function getWorkItemsBatch(
return workItems
} catch (error) {
core.error(`\u001b[48;2;255;0;0mError getting work items: ${error}`)
return
}
}
4 changes: 2 additions & 2 deletions src/azdoTypes.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** Response type for AzDO work item batch query.
* see: https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/work-items/get-work-items-batch?view=azure-devops-rest-7.1&tabs=HTTP
*/
export type WorkItemsBatchResponse = {
export interface WorkItemsBatchResponse {
count: number
value: WorkItem[]
}

/** Work item type */
export type WorkItem = {
export interface WorkItem {
id: number
url: string
fields: {
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export async function run(): Promise<void> {
core.info(`\u001b[35mWork item ids: ${workItemIds}`)

if (workItemIds.length === 0) {
core.info(`\u001b[48;2;255;0;0mNo work items found in the release notes`)
core.info('\u001b[48;2;255;0;0mNo work items found in the release notes')
core.setOutput('workItems', '')
return
}

const workItems: WorkItemsBatchResponse | undefined =
await getWorkItemsBatch(adoPat, adoOrg, adoProject, workItemIds)

if (!workItems) {
if (workItems == null) {
core.setFailed('Failed to get work item details')
return
}
Expand All @@ -73,7 +73,7 @@ export async function run(): Promise<void> {
for (const id of workItemIds) {
const workItem = workItems.value.find(wi => wi.id === id)

if (workItem) {
if (workItem != null) {
core.info(
`\u001b[35mWork item ${id}: ${workItem.fields['System.WorkItemType']} ${workItem.fields['System.Title']} (${workItem.fields['System.State']})`
)
Expand Down

0 comments on commit 8794de4

Please sign in to comment.