Skip to content
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
6 changes: 6 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
# - maintenance # not directly related to the code
# - release # related to a new release preparation
# - documentation # change in code docs, haddocks...
# uncomment at least one main project this PR is associated with
projects:
# - cardano-api
# - cardano-api-gen
# - cardano-rpc
# - cardano-wasm
```

# Context
Expand Down
15 changes: 14 additions & 1 deletion .github/workflows/check-pr-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
script: |
const yaml = require('js-yaml');
const fs = require('fs');
const execSync = require('child_process').execSync;

const prDescription = await github.rest.pulls.get({
owner: context.repo.owner,
Expand Down Expand Up @@ -72,6 +73,18 @@ jobs:
console.error(`PR changelog has invalid type: ${changelog.type}\nExpected one, or more of: ${validTypeValues}`)
}

let isProjectsValid = false;
// .filter(Boolean) is a trick that removes empty values from the array (see https://michaeluloth.com/javascript-filter-boolean/)
const validProjectsValues = execSync("ls */CHANGELOG* | cut -d/ -f1").toString().split('\n').filter(Boolean)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to read it from cabal.project.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it is better because, even though all projects are Haskell right now, we don't know that will always be the case, but they do need to have a CHANGELOG.md, for this to be useful. Also, properly parsing a .project file is pretty tricky from outside Haskell, it can be done in a hacky way, but it is not easy at all

if (Array.isArray(changelog.projects) && !!changelog.projects) {
isProjectsValid = changelog.projects.every(value => validProjectsValues.includes(value));
} else {
isProjectsValid = validProjectsValue.includes(changelog.projects);
}
if (!isProjectsValid) {
console.error(`PR changelog has invalid project: ${changelog.projects}\nExpected one, or more of: ${validProjectsValues}`)
}

let isDescriptionValid = true;
if (changelog.description.trim() === '<insert-changelog-description-here>') {
console.error('PR changelog description has not been updated!')
Expand All @@ -81,7 +94,7 @@ jobs:
isDescriptionValid = false;
}

if (!isCompatibilityValid || !isTypeValid || !isDescriptionValid) {
if (!isCompatibilityValid || !isTypeValid || !isProjectsValid || !isDescriptionValid) {
console.error('Failed PR changelog checks!');
process.exit(1);
}
Expand Down
Loading