diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 4d5830ed8e..a9c5713a73 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -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 diff --git a/.github/workflows/check-pr-changelog.yml b/.github/workflows/check-pr-changelog.yml index 8edcf155b3..ebf628086e 100644 --- a/.github/workflows/check-pr-changelog.yml +++ b/.github/workflows/check-pr-changelog.yml @@ -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, @@ -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) + 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() === '') { console.error('PR changelog description has not been updated!') @@ -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); }