Skip to content

Commit

Permalink
src/actionItems: recursively evaluate all meetings
Browse files Browse the repository at this point in the history
With the latest change, we had to introduce a very fragile concept.
Where we looked 7 days prior to capture the last weeks meeting.
Instead remove this, and iterate through each folder to capture the
last meeting. More work but should reduce fragileness.

Additonally action items were not being correctly matched. Update
regex for actionItems.

fixes: coreos#50
  • Loading branch information
prestist committed Feb 6, 2024
1 parent b70df7f commit 67ef1e6
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 75 deletions.
72 changes: 45 additions & 27 deletions dist/index.js

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

18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"octokit": "^3.1.1"
},
"devDependencies": {
"@types/jest": "^29.5.5",
"@types/jest": "^29.5.12",
"@types/node": "^20.6.5",
"@typescript-eslint/eslint-plugin": "^6.7.2",
"@typescript-eslint/parser": "^6.7.2",
Expand All @@ -88,7 +88,7 @@
"make-coverage-badge": "^1.2.0",
"prettier": "^3.0.3",
"prettier-eslint": "^15.0.1",
"ts-jest": "^29.1.1",
"ts-jest": "^29.1.2",
"typescript": "^5.2.2"
}
}
Empty file added src/actionItems.test.ts
Empty file.
103 changes: 66 additions & 37 deletions src/actionItems.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,85 @@
import * as core from '@actions/core'
import { match } from 'assert'

Check failure on line 2 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

'match' is defined but never used
import axios from 'axios'

const actionItemsRegEx = new RegExp(
`Action items\n[-]+\n([\s\S]*?)\nPeople Present`,

Check failure on line 6 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \s

Check failure on line 6 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \S
'm'
)
const meetingListRegEx = new RegExp(
`(?<=>fedora-coreos-meeting.)(.*?)=?txt`,
`g`
)
const folderRegex = new RegExp(
`/<img src="\/icons\/folder.gif" alt="\[DIR\]"> <a href="([^"]+)\/">/`,

Check failure on line 14 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \/

Check failure on line 14 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \/

Check failure on line 14 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \[

Check failure on line 14 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \]

Check failure on line 14 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Unnecessary escape character: \/
`g`
)
const meetingNotesRootURL = core.getInput('rootURLMeetingLogs')

export async function GetActionItems(): Promise<string> {
try {
console.log(`GetActionItems started`)
// Set constants
const actionItemsRegEx = new RegExp(
`(?<=Action Items\n------------\n)((.|\n)*)(?=Action Items,)`
)
const meetingListRegEx = new RegExp(
`(?<=>fedora-coreos-meeting.)(.*?)=?txt`,
`g`
)
const allMeetingNotes = core.getInput('rootURLMeetingLogs')
const sevenDaysAgo: string = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
.toISOString()
.split('T')[0]
const meetingNotesURL = allMeetingNotes + sevenDaysAgo + `/`
const listOfMeetings = await fetchData(meetingNotesURL)
const matches = listOfMeetings.match(meetingListRegEx)

if (matches != null) {
const lastMeeting = matches[matches.length - 1]
// This should be the latest meeting`s date in with the format of YYYY-MM-DD-HH.MM.txt
const lastMeetingNotesUrl =
meetingNotesURL + 'fedora-coreos-meeting.' + lastMeeting
console.debug(`last meeting notes url ${lastMeetingNotesUrl}`)
const lastMeetingNotes = await fetchData(lastMeetingNotesUrl)
const actionItemMatches = actionItemsRegEx.exec(lastMeetingNotes)

if (actionItemMatches) {
console.debug(`action item matches${actionItemMatches[0]}`)
// if the match is just new lines, then there were no action items
if (actionItemMatches[0].match(/^\s*$/)) {
return `!topic there are no action items from the last meeting.`
console.log('GetActionItems started')
const listOfAllDateFolders = getAllDateFolders()
console.log('List of all available dates ', listOfAllDateFolders)
for (let i = 0; i < listOfAllDateFolders.length; i++) {

Check warning on line 24 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a `for-of` loop instead of a `for` loop with this simple iteration
const folder = listOfAllDateFolders[i]
console.log('Checking folder: ', folder)
let meetingMatches = await getFCOSMeetingMatches(folder)

Check failure on line 27 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

'meetingMatches' is never reassigned. Use 'const' instead
if (meetingMatches != null) {
console.log('Found FCOS meeting in folder: ', folder)
// We want the last match, which is just the txt file
const lastMatch = meetingMatches[meetingMatches.length - 1]
let meetingTxt = fetchData(`${folder}${lastMatch}`)
let actionItems = (await meetingTxt).match(actionItemsRegEx)
if (actionItems != null) {
console.log('Found action items in meeting notes: ', actionItems[1])
// return the the captured group
return actionItems[1]
}
return actionItemMatches[0]
}
}
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) core.setFailed(error.message)
}

return `Failed: to get action items, check the last meeting notes.`
return 'Failed: to get action items, check the last meeting notes.'
}

async function fetchData(url: string): Promise<string> {
const options = {
method: `GET`,
method: 'GET',
url
}
return await (
await axios(options)
).data
return (await axios(options)).data
}

function getAllDateFolders(): string[] {
const urls: string[] = []
let match = folderRegex.exec(meetingNotesRootURL)
if (match == null) {
throw new Error(
'No meetings found in the meeting notes root URL. Check rootURL, or the regex for matching links.'
)
}

for (let i = 0; i < match.length; i++) {

Check warning on line 66 in src/actionItems.ts

View workflow job for this annotation

GitHub Actions / Lint Code Base

Expected a `for-of` loop instead of a `for` loop with this simple iteration
const folderUrl = match[i]
const fullUrl = `${meetingNotesRootURL}${folderUrl}/`
urls.unshift(fullUrl)
}

return urls
}

async function getFCOSMeetingMatches(
html: string
): Promise<RegExpMatchArray | null> {
const rawHtml = await fetchData(html)
const matches = rawHtml.match(meetingListRegEx)

if (matches != null) {
return matches
}
return null
}

0 comments on commit 67ef1e6

Please sign in to comment.