-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,928 additions
and
311 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
import { prHasChangeset, prHasLabel, getPr } from './pr.mjs' | ||
|
||
async function checkChangesets() { | ||
const hasChangesetsOkLabel = prHasLabel('changesets-ok') | ||
if (hasChangesetsOkLabel) { | ||
console.log('Skipping check because of the "changesets-ok" label') | ||
return | ||
} | ||
|
||
if (await prHasChangeset()) { | ||
// Empty space here and in subsequent console logs for formatting. | ||
console.log( | ||
[ | ||
'', | ||
"Added a changeset", | ||
].join('\n') | ||
) | ||
return | ||
} | ||
|
||
const pr = getPr() | ||
console.log( | ||
[ | ||
'', | ||
'📝 Consider adding a changeset', | ||
'==============================', | ||
'', | ||
'If this is a user-facing PR (a feature or a fix), it should probably have a changeset.', | ||
`Run \`yarn changesets ${pr.number}\` to create a changeset for this PR.`, | ||
"If it doesn't need one (it's a chore), you can add the 'changesets-ok' label.", | ||
].join('\n') | ||
) | ||
|
||
process.exitCode = 1 | ||
} | ||
|
||
await checkChangesets() |
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,12 @@ | ||
{ | ||
"name": "redwood-ci-scripts", | ||
"private": true, | ||
"dependencies": { | ||
"@actions/github": "6.0.0", | ||
"zx": "7.2.3" | ||
}, | ||
"packageManager": "yarn@4.1.1", | ||
"devDependencies": { | ||
"tsx": "^4.7.1" | ||
} | ||
} |
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,31 @@ | ||
import { context as ghContext } from '@actions/github' | ||
import { $ } from 'zx' | ||
import { getLines } from './zxHelpers.mjs' | ||
|
||
type Label = { | ||
name: string | ||
} | ||
|
||
function getPrLabels(): Label[] { | ||
return [] | ||
} | ||
|
||
export function prHasLabel(label) { | ||
const labels = getPrLabels() | ||
return labels.some((l) => l.name === label) | ||
} | ||
|
||
async function getPrChangedFiles() { | ||
await $`git fetch origin main`.quiet() | ||
const changedFiles = getLines(await $`git diff origin/main --name-only`.quiet()) | ||
return changedFiles | ||
} | ||
|
||
export async function prHasChangeset() { | ||
const changedFiles = await getPrChangedFiles() | ||
return changedFiles.some((file) => file.startsWith('.changesets/')) | ||
} | ||
|
||
export function getPr() { | ||
return ghContext.payload.pull_request | ||
} |
Oops, something went wrong.