Skip to content

Commit

Permalink
chore: Update changelog script to allow for .txt output (#7396)
Browse files Browse the repository at this point in the history
#### Details

This PR enables the changelog script to output a .txt file with a list
of commits to validate instead of a .csv.

This can be triggered by adding a flag onto the end of the script for
the desired kind of file:

`node ./tools/get-change-log-for-release.js --from web@PREVIOUS_RELEASE
--to web@NEW_RELEASE --kind txt`
or
`yarn run change-log --from web@PREVIOUS_RELEASE --to web@NEW_RELEASE -k
txt`

Example Output:

This is the result for running `yarn run change-log -f [email protected] -t
[email protected] -k txt`

```
[tester]
        dev: Chirag Sharma
        pr: #7378
        group: fix
        change: fix: adding code to format nextline character (\r\n) (#7378)
[tester]
        dev: rohittarpara
        pr: #7377
        group: fix
        change: fix: <hx role="none"> is reported as heading. (#7377)
[tester]
        dev: rohittarpara
        pr: #7374
        group: chore
        change: chore: update @fluentui/react from 8.96.1 to 8.118.1 (#7374)
[tester]
        dev: rohittarpara
        pr: #7369
        group: feat(axe-core 4.9.1)
        change: feat(axe-core 4.9.1): Axe core version upgrade for Web (#7369)
[tester]
        dev: Chirag Sharma
        pr: #7370
        group: chore
        change: chore : Update package version for accessibility insights report and accessibility insights ui (#7370)
```

The release driver would just need to paste this into OneNote, remove
any commits that are non-user-facing, and format like a list to add
bullets and the indents are already there!

##### Motivation

Our changelog script generates a csv of the commits to main between two
commits (usually the previous release and HEAD). During release
validation, our team filters down that CSV in excel and then pastes the
generated table into our validation template so we can check that those
commits have successfully made it into the new release. To make our
release validation process more accessible, we are moving away from
using tables in our validation templates.

##### Context

The text version of the changelog automatically excludes `dependabot`
and `chore(deps-dev)` commits, as it is more cumbersome to filter the
text list than the csv and these updates aren't included in validation
anyhow.

#### Pull request checklist
<!-- If a checklist item is not applicable to this change, write "n/a"
in the checkbox -->
- [n/a] Addresses an existing issue: #0000
- [x] Ran `yarn fastpass`
- [n/a] Added/updated relevant unit test(s) (and ran `yarn test`)
- [n/a] Verified code coverage for the changes made. Check coverage
report at: `<rootDir>/test-results/unit/coverage`
- [x] PR title *AND* final merge commit title both start with a semantic
tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See
`CONTRIBUTING.md`.
- [n/a] (UI changes only) Added screenshots/GIFs to description above
- [n/a] (UI changes only) Verified usability with NVDA/JAWS
  • Loading branch information
madalynrose authored Jul 23, 2024
1 parent ab49a8f commit 2195bff
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions tools/get-change-log-for-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ const main = async () => {
validateCommandLineArguments(params);

const gitLogs = await getGitLogs(params.from, params.to);

const outputContent = generateOutputContent(gitLogs, params.to);

const outputContent =
params.kind === 'csv'
? generateCSVContent(gitLogs, params.to)
: generateTextContent(gitLogs);
ensureOutputFileExist(params.output);

fs.writeFileSync(params.output, outputContent);
Expand Down Expand Up @@ -62,14 +63,45 @@ const makePrLink = pr => {
return pr;
}

return `=HYPERLINK("https://github.com/microsoft/accessibility-insights-web/pull/${pr}", "#${pr}")`;
return `=HYPERLINK("${makePrURL(pr)}", "#${pr}")`;
};

const makePrURL = pr => {
return `https://github.com/microsoft/accessibility-insights-web/pull/${pr}`;
};

const makeCommitLink = commit => {
return `=HYPERLINK("https://github.com/microsoft/accessibility-insights-web/commit/${commit}", "${commit}")`;
return `=HYPERLINK("${makeCommitURL(commit)}", "${commit}")`;
};

const makeCommitURL = commit => {
return `https://github.com/microsoft/accessibility-insights-web/commit/${commit}`;
};

const generateOutputContent = (gitLogs, version) => {
const generateTextContent = gitLogs => {
let outputText = '';
gitLogs.all
.map(log => {
return {
dev: log.author_name,
pr: makePrURL(extractPrNumber(log.message)),
change: log.message,
group: getCommitType(log.message),
};
})
.filter(log => {
return (
!['chore(deps-dev)'].includes(log.group) && !['dependabot[bot]'].includes(log.dev)
);
})
.sort((a, b) => a.group - b.group)
.forEach(log => {
outputText += `[tester]\n\tdev: ${log.dev}\n\tpr: ${log.pr}\n\tgroup: ${log.group}\n\tchange: ${log.change}\n`;
});
return outputText;
};

const generateCSVContent = (gitLogs, version) => {
const csvLogs = gitLogs.all
.map(log => {
return {
Expand Down Expand Up @@ -107,14 +139,18 @@ const parseCommandLineArguments = () => {
'-o, --output <output_path>',
'Path to the output file. Default: change-log.<from>-<to>.csv',
)
.option(
'-k, --kind <csv or txt>',
'Type of desired output, csv or txt. Default: csv',
'csv',
)
.parse(process.argv);

return program.opts();
};

const validateCommandLineArguments = program => {
const errors = [];

if (!program.from) {
errors.push('Missing param: from');
}
Expand All @@ -123,8 +159,12 @@ const validateCommandLineArguments = program => {
errors.push('Missing param: to');
}

if (!program.kind) {
program.kind = 'csv';
}

if (!program.output) {
program.output = `change-log.${program.from}-${program.to}.csv`;
program.output = `change-log.${program.from}-${program.to}.${program.kind}`;
}

if (errors.length !== 0) {
Expand Down

0 comments on commit 2195bff

Please sign in to comment.