chore(repo): fix ts compilation of issues-scraper (#30656)
## Current Behavior Issues reporter is not running ## Expected Behavior Issues reporter is running ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This commit is contained in:
parent
3ad8082a39
commit
7c22d2d969
2
.github/workflows/issue-notifier.yml
vendored
2
.github/workflows/issue-notifier.yml
vendored
@ -50,7 +50,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Collect Issue Data
|
- name: Collect Issue Data
|
||||||
id: collect
|
id: collect
|
||||||
run: npx ts-node ./scripts/issues-scraper/index.ts
|
run: npx tsx ./scripts/issues-scraper/index.ts
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ import { table } from 'markdown-factory';
|
|||||||
|
|
||||||
export function getSlackMessageJson(body: string) {
|
export function getSlackMessageJson(body: string) {
|
||||||
return {
|
return {
|
||||||
text: 'Some Text',
|
|
||||||
blocks: [
|
blocks: [
|
||||||
{
|
{
|
||||||
type: 'section',
|
type: 'section',
|
||||||
@ -19,8 +18,7 @@ export function getSlackMessageJson(body: string) {
|
|||||||
export function formatGhReport(
|
export function formatGhReport(
|
||||||
currentData: ReportData,
|
currentData: ReportData,
|
||||||
trendData: TrendData,
|
trendData: TrendData,
|
||||||
prevData: ReportData,
|
prevData: ReportData
|
||||||
unlabeledIssuesUrl: string
|
|
||||||
): string {
|
): string {
|
||||||
const issueDelta = trendData.totalIssueCount;
|
const issueDelta = trendData.totalIssueCount;
|
||||||
const formattedIssueDelta = formatDelta(issueDelta);
|
const formattedIssueDelta = formatDelta(issueDelta);
|
||||||
@ -28,7 +26,7 @@ export function formatGhReport(
|
|||||||
const bugDelta = trendData.totalBugCount;
|
const bugDelta = trendData.totalBugCount;
|
||||||
const formattedBugDelta = formatDelta(bugDelta);
|
const formattedBugDelta = formatDelta(bugDelta);
|
||||||
|
|
||||||
const header = `Issue Report for ${currentData.collectedDate} <${unlabeledIssuesUrl}|[view unlabeled]>
|
const header = `Issue Report for ${currentData.collectedDate}
|
||||||
\`\`\`
|
\`\`\`
|
||||||
Totals, Issues: ${currentData.totalIssueCount} ${formattedIssueDelta} Bugs: ${currentData.totalBugCount} ${formattedBugDelta}\n\n`;
|
Totals, Issues: ${currentData.totalIssueCount} ${formattedIssueDelta} Bugs: ${currentData.totalBugCount} ${formattedBugDelta}\n\n`;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,10 @@
|
|||||||
import { ensureDirSync, readJsonSync, writeJsonSync } from 'fs-extra';
|
import { ensureDirSync, readJsonSync, writeJsonSync } from 'fs-extra';
|
||||||
import { dirname, join } from 'path';
|
import { dirname, join } from 'path';
|
||||||
import { ReportData, ScopeData, TrendData } from './model';
|
import { ReportData, ScopeData, TrendData } from './model';
|
||||||
import { getScopeLabels, scrapeIssues } from './scrape-issues';
|
import { scrapeIssues } from './scrape-issues';
|
||||||
import { formatGhReport, getSlackMessageJson } from './format-slack-message';
|
import { formatGhReport, getSlackMessageJson } from './format-slack-message';
|
||||||
import { setOutput } from '@actions/core';
|
import { setOutput } from '@actions/core';
|
||||||
import isCI from 'is-ci';
|
import isCI from 'is-ci';
|
||||||
import { readdirSync } from 'fs';
|
|
||||||
|
|
||||||
const CACHE_FILE = join(__dirname, 'cached', 'data.json');
|
const CACHE_FILE = join(__dirname, 'cached', 'data.json');
|
||||||
|
|
||||||
@ -15,12 +14,7 @@ async function main() {
|
|||||||
oldData.collectedDate ? new Date(oldData.collectedDate) : undefined
|
oldData.collectedDate ? new Date(oldData.collectedDate) : undefined
|
||||||
);
|
);
|
||||||
const trendData = getTrendData(currentData, oldData);
|
const trendData = getTrendData(currentData, oldData);
|
||||||
const formatted = formatGhReport(
|
const formatted = formatGhReport(currentData, trendData, oldData);
|
||||||
currentData,
|
|
||||||
trendData,
|
|
||||||
oldData,
|
|
||||||
getUnlabeledIssuesUrl(await getScopeLabels())
|
|
||||||
);
|
|
||||||
setOutput('SLACK_MESSAGE', getSlackMessageJson(formatted));
|
setOutput('SLACK_MESSAGE', getSlackMessageJson(formatted));
|
||||||
console.log(formatted.replace(/\<(.*)\|(.*)\>/g, '[$1]($0)'));
|
console.log(formatted.replace(/\<(.*)\|(.*)\>/g, '[$1]($0)'));
|
||||||
saveCacheData(currentData);
|
saveCacheData(currentData);
|
||||||
@ -47,7 +41,7 @@ function getTrendData(newData: ReportData, oldData: ReportData): TrendData {
|
|||||||
scopes: scopeTrends as Record<string, ScopeData>,
|
scopes: scopeTrends as Record<string, ScopeData>,
|
||||||
totalBugCount: newData.totalBugCount - oldData.totalBugCount,
|
totalBugCount: newData.totalBugCount - oldData.totalBugCount,
|
||||||
totalIssueCount: newData.totalIssueCount - oldData.totalIssueCount,
|
totalIssueCount: newData.totalIssueCount - oldData.totalIssueCount,
|
||||||
totalClosed: newData.totalClosed - oldData.totalClosed ?? 0,
|
totalClosed: newData.totalClosed - oldData.totalClosed,
|
||||||
untriagedIssueCount:
|
untriagedIssueCount:
|
||||||
newData.untriagedIssueCount - oldData.untriagedIssueCount,
|
newData.untriagedIssueCount - oldData.untriagedIssueCount,
|
||||||
};
|
};
|
||||||
@ -62,10 +56,8 @@ function saveCacheData(report: ReportData) {
|
|||||||
|
|
||||||
function getOldData(): ReportData {
|
function getOldData(): ReportData {
|
||||||
try {
|
try {
|
||||||
console.log('DIR CONTENTS:', readdirSync(dirname(CACHE_FILE)));
|
|
||||||
return readJsonSync(CACHE_FILE);
|
return readJsonSync(CACHE_FILE);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
|
||||||
return {
|
return {
|
||||||
scopes: {},
|
scopes: {},
|
||||||
totalBugCount: 0,
|
totalBugCount: 0,
|
||||||
@ -75,10 +67,3 @@ function getOldData(): ReportData {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUnlabeledIssuesUrl(scopeLabels: string[]) {
|
|
||||||
const labelFilters = scopeLabels.map((s) => `-label:"${s}"`);
|
|
||||||
return `https://github.com/nrwl/nx/issues/?q=is%3Aopen+is%3Aissue+sort%3Aupdated-desc+${encodeURIComponent(
|
|
||||||
labelFilters.join(' ')
|
|
||||||
)}`;
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user