Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for retrospective #51

Merged
merged 7 commits into from
Nov 17, 2023
Merged
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
3 changes: 3 additions & 0 deletions .github/workflows/populate_feed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Collect Retrospective
run: npm run collect:retrospective

- name: RSS Build
run: npm run rss:build

Expand Down
4 changes: 4 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"reposPaginationLimit": 250,
"releasePaginationLimit": 10,
"commentsPaginationLimit": 100,
"retrospective": {
"lastDay": "2023-10-15",
"nextDay": "2023-10-22"
},
"breakDelimiter": "</image>",
"discussionsInScope": [
{
Expand Down
7 changes: 7 additions & 0 deletions feed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<url>https://pbs.twimg.com/profile_images/1262824892535373825/BiXDFDDp_400x400.jpg</url>
<link>https://github.com/nodejs/nodejs-news-feeder</link>
</image>
<item>
<title>Retrospective for nodejs from 2023-10-15 to 2023-10-22</title>
<description><![CDATA[<p>Reporting on 35 Issues from 29 authors, 65 Pull Requests from 33 authors, and 9 Discussions from 7 authors.</p>]]></description>
<pubDate>Sun, 22 Oct 2023 08:00:00 GMT</pubDate>
<link>https://github.com/cutenode/retro-weekly/blob/main/retros/2023-10-22.md</link>
<guid>https://github.com/cutenode/retro-weekly/blob/main/retros/2023-10-22.md</guid>
</item>
<item>
<title>Released nodejs/corepack v0.23.0</title>
<description><![CDATA[<p>Released nodejs/corepack v0.23.0 by github-actions[bot]. <a href="https://github.com/nodejs/corepack/releases/tag/v0.23.0">More details</a></p>
Expand Down
1 change: 0 additions & 1 deletion jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jest-environment-node',
transform: {},
transformIgnorePatterns: ['<rootDir>/node_modules/']
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"collect:releases": "node scripts/collect-releases.js",
"collect:issues": "node scripts/collect-issues.js",
"collect:discussions": "node scripts/collect-discussions.js",
"collect:retrospective": "node scripts/collect-retrospective.js",
"rss:validate": "node scripts/validate.js",
"rss:build": "node scripts/build.js",
"rss:format": "node scripts/format.js",
Expand Down
36 changes: 36 additions & 0 deletions scripts/collect-retrospective.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import got from 'got'
import { buildRFC822Date, overwriteConfig, composeFeedItem, getFeedContent, overwriteFeedContent, getConfig, generateRetroRequestUrl, parseRetrospectiveContent, generateRetroUIUrl } from '../utils/index.js'

// Collect new retrospective
const { retrospective: currentConfig, breakDelimiter } = getConfig()
const url = generateRetroRequestUrl(currentConfig.nextDay)

try {
const content = await got(url).text()
const data = parseRetrospectiveContent(content)
const retrospective = composeFeedItem({
title: data.title,
description: `<![CDATA[<p>${data.description}</p>]]>`,
pubDate: buildRFC822Date(data.lastDay),
link: generateRetroUIUrl(data.lastDay),
guid: generateRetroUIUrl(data.lastDay)
})
// Add the new item to the feed
const feedContent = getFeedContent()
const [before, after] = feedContent.split(breakDelimiter)
const updatedFeedContent = `${before}${breakDelimiter}${retrospective}${after}`
overwriteFeedContent(updatedFeedContent)

// Overwrite config with new dates
const config = getConfig()
overwriteConfig({
...config,
retrospective: {
lastDay: data.lastDay,
nextDay: data.nextDay
}
})
} catch (error) {
console.log("Retrospective not found or generated and error, so we're not updating the feed.")
console.log("Configuration for the retrospective won't be updated either.")
}
16 changes: 16 additions & 0 deletions utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { createHash } from 'crypto'
import * as remark from 'remark'
import remarkHtml from 'remark-html'

const dateRegex = /(\d*-\d*-\d*)/gm
const xmlFile = join(process.cwd(), 'feed.xml')
const configFile = join(process.cwd(), 'config.json')

Expand Down Expand Up @@ -74,3 +75,18 @@ export function buildRFC822Date (dateString) {
// Wed, 02 Oct 2002 13:00:00 GMT
return `${day}, ${dayNumber} ${month} ${year} ${time} ${timezone}`
}

export function generateRetroRequestUrl (dateString) {
return `https://raw.githubusercontent.com/cutenode/retro-weekly/main/retros/${dateString}.md`
}

export function generateRetroUIUrl (dateString) {
return `https://github.com/cutenode/retro-weekly/blob/main/retros/${dateString}.md`
}

export function parseRetrospectiveContent (data) {
const [rawTitle, , description] = data.split('\n')
const title = rawTitle.replace('# ', '').replaceAll('`', '').trim()
const dates = title.split(dateRegex)
return { title, description, lastDay: dates[1], nextDay: dates[3] }
}