Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- run: npm run test:integration-issues

testint:
runs-on: ubuntu-latest
Expand Down
57 changes: 57 additions & 0 deletions lib/agenda.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
'use strict'

/**
* get agenda issues and PRs from repositories
* @param {Object} client - GitHub client
* @param {Array} repos - array of objects with owner and repo properties
* @param {string} agendaLabel - label to filter issues and PRs by
* @returns {Promise<Array>} array of unique issues and PRs
*/
async function fetchAgendaItems (client, repos, agendaLabel) {
const agendaIssues = []

// deduplicate repos
const uniqueRepos = [...new Map(
repos.map(repo => [`${repo.owner}/${repo.repo}`, repo])
).values()]

for (const r of uniqueRepos) {
const _agendaIssues = await client.paginate('GET /repos/{owner}/{repo}/issues', {
owner: r.owner,
repo: r.repo,
state: 'open',
labels: agendaLabel,
per_page: 100
})

console.log(`Fetching issues for ${r.owner}/${r.repo}: Found ${_agendaIssues.length}`)

for (const i of _agendaIssues) {
console.log(`Adding Issue: ${i.url}`)
agendaIssues.push(i)
}

const _agendaPrs = (await client.paginate('GET /repos/{owner}/{repo}/pulls', {
owner: r.owner,
repo: r.repo,
state: 'open',
labels: agendaLabel,
per_page: 100
})).filter(pr => pr.labels.find(label => label.name === agendaLabel) &&
!(agendaIssues.find((i) => i.url === pr.url))) // workaround for flaky GH API/SDK behavior where sometimes the issue endpoint loads PRs

console.log(`Fetching PRs for ${r.owner}/${r.repo}: Found ${_agendaPrs.length}`)

for (const pr of _agendaPrs) {
console.log(`Adding PR: ${pr.url}`)
agendaIssues.push(pr)
}
}

console.log(`Found ${agendaIssues.length} total issues for agenda`)
return agendaIssues
}

module.exports = {
fetchAgendaItems
}
Loading
Loading