Skip to content

Commit 67ef1e6

Browse files
committed
src/actionItems: recursively evaluate all meetings
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
1 parent b70df7f commit 67ef1e6

File tree

5 files changed

+122
-75
lines changed

5 files changed

+122
-75
lines changed

dist/index.js

Lines changed: 45 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"octokit": "^3.1.1"
7474
},
7575
"devDependencies": {
76-
"@types/jest": "^29.5.5",
76+
"@types/jest": "^29.5.12",
7777
"@types/node": "^20.6.5",
7878
"@typescript-eslint/eslint-plugin": "^6.7.2",
7979
"@typescript-eslint/parser": "^6.7.2",
@@ -88,7 +88,7 @@
8888
"make-coverage-badge": "^1.2.0",
8989
"prettier": "^3.0.3",
9090
"prettier-eslint": "^15.0.1",
91-
"ts-jest": "^29.1.1",
91+
"ts-jest": "^29.1.2",
9292
"typescript": "^5.2.2"
9393
}
9494
}

src/actionItems.test.ts

Whitespace-only changes.

src/actionItems.ts

Lines changed: 66 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,85 @@
11
import * as core from '@actions/core'
2+
import { match } from 'assert'
23
import axios from 'axios'
4+
5+
const actionItemsRegEx = new RegExp(
6+
`Action items\n[-]+\n([\s\S]*?)\nPeople Present`,
7+
'm'
8+
)
9+
const meetingListRegEx = new RegExp(
10+
`(?<=>fedora-coreos-meeting.)(.*?)=?txt`,
11+
`g`
12+
)
13+
const folderRegex = new RegExp(
14+
`/<img src="\/icons\/folder.gif" alt="\[DIR\]"> <a href="([^"]+)\/">/`,
15+
`g`
16+
)
17+
const meetingNotesRootURL = core.getInput('rootURLMeetingLogs')
18+
319
export async function GetActionItems(): Promise<string> {
420
try {
5-
console.log(`GetActionItems started`)
6-
// Set constants
7-
const actionItemsRegEx = new RegExp(
8-
`(?<=Action Items\n------------\n)((.|\n)*)(?=Action Items,)`
9-
)
10-
const meetingListRegEx = new RegExp(
11-
`(?<=>fedora-coreos-meeting.)(.*?)=?txt`,
12-
`g`
13-
)
14-
const allMeetingNotes = core.getInput('rootURLMeetingLogs')
15-
const sevenDaysAgo: string = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000)
16-
.toISOString()
17-
.split('T')[0]
18-
const meetingNotesURL = allMeetingNotes + sevenDaysAgo + `/`
19-
const listOfMeetings = await fetchData(meetingNotesURL)
20-
const matches = listOfMeetings.match(meetingListRegEx)
21-
22-
if (matches != null) {
23-
const lastMeeting = matches[matches.length - 1]
24-
// This should be the latest meeting`s date in with the format of YYYY-MM-DD-HH.MM.txt
25-
const lastMeetingNotesUrl =
26-
meetingNotesURL + 'fedora-coreos-meeting.' + lastMeeting
27-
console.debug(`last meeting notes url ${lastMeetingNotesUrl}`)
28-
const lastMeetingNotes = await fetchData(lastMeetingNotesUrl)
29-
const actionItemMatches = actionItemsRegEx.exec(lastMeetingNotes)
30-
31-
if (actionItemMatches) {
32-
console.debug(`action item matches${actionItemMatches[0]}`)
33-
// if the match is just new lines, then there were no action items
34-
if (actionItemMatches[0].match(/^\s*$/)) {
35-
return `!topic there are no action items from the last meeting.`
21+
console.log('GetActionItems started')
22+
const listOfAllDateFolders = getAllDateFolders()
23+
console.log('List of all available dates ', listOfAllDateFolders)
24+
for (let i = 0; i < listOfAllDateFolders.length; i++) {
25+
const folder = listOfAllDateFolders[i]
26+
console.log('Checking folder: ', folder)
27+
let meetingMatches = await getFCOSMeetingMatches(folder)
28+
if (meetingMatches != null) {
29+
console.log('Found FCOS meeting in folder: ', folder)
30+
// We want the last match, which is just the txt file
31+
const lastMatch = meetingMatches[meetingMatches.length - 1]
32+
let meetingTxt = fetchData(`${folder}${lastMatch}`)
33+
let actionItems = (await meetingTxt).match(actionItemsRegEx)
34+
if (actionItems != null) {
35+
console.log('Found action items in meeting notes: ', actionItems[1])
36+
// return the the captured group
37+
return actionItems[1]
3638
}
37-
return actionItemMatches[0]
3839
}
3940
}
4041
} catch (error) {
4142
// Fail the workflow run if an error occurs
4243
if (error instanceof Error) core.setFailed(error.message)
4344
}
4445

45-
return `Failed: to get action items, check the last meeting notes.`
46+
return 'Failed: to get action items, check the last meeting notes.'
4647
}
4748

4849
async function fetchData(url: string): Promise<string> {
4950
const options = {
50-
method: `GET`,
51+
method: 'GET',
5152
url
5253
}
53-
return await (
54-
await axios(options)
55-
).data
54+
return (await axios(options)).data
55+
}
56+
57+
function getAllDateFolders(): string[] {
58+
const urls: string[] = []
59+
let match = folderRegex.exec(meetingNotesRootURL)
60+
if (match == null) {
61+
throw new Error(
62+
'No meetings found in the meeting notes root URL. Check rootURL, or the regex for matching links.'
63+
)
64+
}
65+
66+
for (let i = 0; i < match.length; i++) {
67+
const folderUrl = match[i]
68+
const fullUrl = `${meetingNotesRootURL}${folderUrl}/`
69+
urls.unshift(fullUrl)
70+
}
71+
72+
return urls
73+
}
74+
75+
async function getFCOSMeetingMatches(
76+
html: string
77+
): Promise<RegExpMatchArray | null> {
78+
const rawHtml = await fetchData(html)
79+
const matches = rawHtml.match(meetingListRegEx)
80+
81+
if (matches != null) {
82+
return matches
83+
}
84+
return null
5685
}

0 commit comments

Comments
 (0)