forked from yarnpkg/berry
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add script to generate e2e status list (yarnpkg#6434)
**What's the problem this PR addresses?** The e2e status table in our README.md needs to be kept up to date manually whenever we add or remove an e2e test and there is no automated check to ensure that it's correct. **How did you fix it?** Add a script to generate an e2e status list and add a CI check for it. **Checklist** - [x] I have read the [Contributing Guide](https://yarnpkg.com/advanced/contributing). - [x] I have set the packages that need to be released for my changes to be effective. - [x] I will check that all automated PR checks pass before the PR gets reviewed.
- Loading branch information
Showing
3 changed files
with
71 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import fs from 'node:fs'; | ||
|
||
const listContent = fs | ||
.readdirSync(new URL(`../.github/workflows`, import.meta.url)) | ||
.filter(name => name.startsWith(`e2e-`)) | ||
.sort() | ||
.map( | ||
name => | ||
`- [![](https://github.com/yarnpkg/berry/actions/workflows/${name}/badge.svg?event=schedule)](https://github.com/yarnpkg/berry/actions/workflows/${name})`, | ||
) | ||
.join(`\n`); | ||
|
||
const START_MARKER = `<!-- start generated list -->`; | ||
const END_MARKER = `<!-- end generated list -->`; | ||
|
||
const currentReadme = fs.readFileSync(new URL(`../README.md`, import.meta.url), `utf8`); | ||
|
||
const startIndex = currentReadme.indexOf(START_MARKER); | ||
if (startIndex === -1) throw new Error(`Could not find start marker in README.md`); | ||
|
||
const endIndex = currentReadme.indexOf(END_MARKER); | ||
if (endIndex === -1) throw new Error(`Could not find end marker in README.md`); | ||
|
||
const updatedReadme = `${currentReadme.slice( | ||
0, | ||
startIndex + START_MARKER.length, | ||
)}\n${listContent}\n${currentReadme.slice(endIndex)}`; | ||
|
||
if (currentReadme !== updatedReadme) { | ||
fs.writeFileSync(new URL(`../README.md`, import.meta.url), updatedReadme); | ||
console.log(`Updated README.md`); | ||
} else { | ||
console.log(`README.md is already up to date`); | ||
} |