From 62066c8fa92a74994b33e39aaedd7ae68a40136d Mon Sep 17 00:00:00 2001 From: Dan Goslen Date: Mon, 29 Mar 2021 20:45:54 -0400 Subject: [PATCH] Releases/v2.1 (#88) * Adds in the changelog helper for dependabot * Bump eslint from 7.21.0 to 7.22.0 (#83) * Bump uglify-js from 3.13.0 to 3.13.1 (#82) * Fixes changelog paths that start with the current directory * Bump uglify-js from 3.13.0 to 3.13.2 (#86) * Bump uglify-js from 3.13.0 to 3.13.2 Bumps [uglify-js](https://github.com/mishoo/UglifyJS) from 3.13.0 to 3.13.2. - [Release notes](https://github.com/mishoo/UglifyJS/releases) - [Commits](https://github.com/mishoo/UglifyJS/compare/v3.13.0...v3.13.2) Signed-off-by: dependabot[bot] * Auto commit packaged action * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Update changelog * Fix changelog * Fixes changelog * Fix changelog again Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dangoslen Co-authored-by: Dan Goslen * Updates depenabot changelog helper * Bump eslint from 7.21.0 to 7.23.0 (#87) * Bump eslint from 7.21.0 to 7.23.0 Bumps [eslint](https://github.com/eslint/eslint) from 7.21.0 to 7.23.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v7.21.0...v7.23.0) Signed-off-by: dependabot[bot] * Auto commit packaged action * Update changelog * Make preview wait on changelog enforcer Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dangoslen Co-authored-by: Dan Goslen * Adding deprecated message to action.yml * Update the changelog * Bumps version * Simplifying expression Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dangoslen --- .github/dependabot.yml | 4 +- .github/workflows/pull_request.yml | 27 +++-- CHANGELOG.md | 39 +++---- __tests__/changelog-enforcer.test.js | 63 +++++++++-- action.yml | 3 + dist/index.js | 7 +- package-lock.json | 153 ++++++++++++++++++++------- package.json | 9 +- src/changelog-enforcer.js | 7 +- 9 files changed, 227 insertions(+), 85 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 25da02d3..d96c9e7a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,6 +10,7 @@ updates: open-pull-requests-limit: 3 schedule: interval: "daily" + target-branch: "releases/v2.1" - package-ecosystem: "github-actions" directory: "/" labels: @@ -18,4 +19,5 @@ updates: - Skip-Changelog open-pull-requests-limit: 3 schedule: - interval: "daily" \ No newline at end of file + interval: "daily" + target-branch: "releases/v2.2" \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 492983ed..12424ce5 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -18,19 +18,33 @@ jobs: with: commit_message: "Auto commit packaged action" - # test action works running from the graph - back compat + # test action works running from the graph enforce-changelog: needs: unit-tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 + with: + token: ${{ secrets.ACTION_TOKEN }} + - id: read-version run: | echo "::set-output name=version::$(jq -r ".version" package.json)" + + - uses: dangoslen/dependabot-changelog-helper@v0.3.2 + with: + activationLabel: 'dependabot' + newVersionLineNumber: 4 + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "Update changelog" + - id: changelog-enforcer uses: ./ with: expectedLatestVersion: "v${{ steps.read-version.outputs.version }}" + - if: failure() uses: unsplash/comment-on-pr@master env: @@ -44,16 +58,17 @@ jobs: ${{ steps.changelog-enforcer.outputs.errorMessage }} ``` - # test action works running from the graph - enforce-changelog-v2: + # test action works running from the graph - back compat + enforce-changelog-v1: needs: unit-tests runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: ./ preview-release: runs-on: ubuntu-latest + needs: [enforce-changelog] steps: - uses: actions/checkout@v2 @@ -78,7 +93,7 @@ jobs: echo ::set-output name=missing::$MISSING - name: Preview Changelog - if: ${{ steps.check_release.outputs.missing == 'true' }} + if: ${{ steps.check_release.outputs.missing }} uses: unsplash/comment-on-pr@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 59eb4672..02568a22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,12 +1,17 @@ # CHANGELOG - Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [v2.1.0] +### Deprecated +- The input `versionPattern` is now deprecated. Starting in `v3.0.0` the Changelog Enforcer will only work with [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) for verifying the latest expected version. +### Dependencies +- Bumps `eslint` from 7.21.0 to 7.23.0 +- Bumps `uglify-js` from 3.13.0 3.13.2 + ## [v2.0.2] ### Changed - Minor changes to workflows to use `package.json` version - Minor changes to tests and names - ### Dependencies - Bumps `uglify-js` from 3.12.1 to 3.13.0 - Bumps `eslint` from 7.20.0 to 7.21.0 @@ -24,12 +29,11 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Feature request from #62 - Adds a new property `missingUpdateErrorMessage` for passing a custom error message when no update is found to the changelog. See the [Inputs / Properties](https://github.com/dangoslen/changelog-enforcer#inputs--properties) section in the `README.md` for more information. - Adds a new output `errorMessage` that states why the Changelog Enforcer failed. Added to allow users to use the error message within the rest of the action workflow. - ### Dependencies - Bumps `@vercel/ncc` from `0.25.1` to `0.26.1` (#63) - Bumps `eslint` from `7.15.0` to `7.17.0` (#64, #70) - Bumps `node-notifier` from `8.0.0` to `8.0.1` (#65) - + ## [v1.6.1] ### Fixed - Fixes #58 by properly accounting for whitespace characters in label names. @@ -37,50 +41,41 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [v1.6.0] ### Added - New `skipLabels` input variable to supply a list of labels to skip enforcement for. See the [Inputs / Properties](https://github.com/dangoslen/changelog-enforcer#inputs--properties) section in the `README.md` for more information. - ### Changed - Deprecates the `skipLabel` input variable in favor of the `skipLabels` input variable - ### Dependencies - `eslint` from `7.14.0` to `7.15.0` - `uglify-js` from `2.6.0` to `3.12.1` - `jest` from `24.9.0` to `26.6.3` - ## [v1.5.1] ### Added - Improved GitHub actions workflow for testing and packaging - Preview of release notes for a new version - ### Dependencies - `@actions/exec` from `1.0.3` to `1.0.4` - `@actions/github` from `2.1.1` to `4.0.0` - `eslint` from `6.3.0` to `7.14.0` - `changelog-reader-action` from `v1` to `v2` - ## [v1.5.0] ### Added - New input parameter `expectedLatestVersion`. - When supplied, the Changelog Enforcer validates that this is the latest version in the changelog or the latest version after an "Unreleased" version if one exists. - New input parameter `versionPattern`. - Used in conjunction with `expectedLatestVersion`. This is a javascript string that is converted to a regular expression that is used to extract the versions in the changelog identified by the `changeLogPath` input. By default is uses a regular expression for the [KeepAChangelog.org format](https://keepachangelog.com/en/1.0.0/). - ### Changed - Updates to `README` and `CHANGELOG` for new features ## [v1.4.1] ### Security - `@actions/core@1.1.1` to `@actions/core@1.2.6` - ### Adds - Badge for workflows using this action ## [v1.4.0] ### Summary Please upgrade to use with `actions/checkout@v2`! - ### Fixes - Now works with both `actions/checkout@v1` and `actions/checkout@v2` - ### Adds - Code coverage checks via `jest` and coverage badge via `make-coverage-badge` @@ -92,10 +87,10 @@ Please upgrade to use with `actions/checkout@v2`! ## [v1.2.0] ### Added - Automatically builds the distribution on pull requests if all tests and enforcement pass - + ### Updated - Small `README` updates - + ## [v1.1.2] ### Security - `lodash@4.17.15` to `lodash@4.17.19` @@ -103,22 +98,22 @@ Please upgrade to use with `actions/checkout@v2`! ## [v1.1.1] ### Fixes - Referencing proper step id in workflow for creating releases - + ## [v1.1.0] ### Added - Using [Changelog Reader](https://github.com/marketplace/actions/changelog-reader) to automate creating GitHub Releases from this `CHANGELOG.md` - + ## [v1.0.2] -### Security +### Security - Update uglify-js to 2.6.0 per [CVE-2015-8857](https://github.com/advisories/GHSA-34r7-q49f-h37c) - + ## [v1.0.1] ### Fixed - Fixes spelling of `skipLabel` property in `README.md` - + ## [v1.0.0] ### Added - Adds updates to the `README.md` and `action.yaml` to prepare to the GitHub marketplace - + ## [v0.1.0] -- Initial `Changelog Enforcer` functionality, including the use of a label to skip +- Initial `Changelog Enforcer` functionality, including the use of a label to skip \ No newline at end of file diff --git a/__tests__/changelog-enforcer.test.js b/__tests__/changelog-enforcer.test.js index 2339d20b..a9cb499a 100644 --- a/__tests__/changelog-enforcer.test.js +++ b/__tests__/changelog-enforcer.test.js @@ -13,9 +13,9 @@ let inputs = {} // Mocks via Jest let infoSpy let failureSpy -let warnSpy -let outputSpy let execSpy +let outputSpy +let warnSpy describe('the changelog-enforcer', () => { @@ -40,7 +40,6 @@ describe('the changelog-enforcer', () => { warnSpy = jest.spyOn(core, 'warning').mockImplementation(jest.fn()) failureSpy = jest.spyOn(core, 'setFailed').mockImplementation(jest.fn()) outputSpy = jest.spyOn(core, 'setOutput').mockImplementation(jest.fn()) - execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { return 0 }) }) @@ -106,7 +105,7 @@ A an_added_changed_file.js` inputs['skipLabels'] = 'A different label' inputs['expectedLatestVersion'] = 'v1.10' - const execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { + execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { let stdout = '' if (args[0] == 'diff') { stdout = @@ -153,7 +152,7 @@ A an_added_changed_file.js` it('should enforce when label is not present; changelog is not changed; branch checked out', (done) => { inputs['skipLabels'] = 'A different label' - const execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { + execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { let stdout = '' if (args[0] == 'diff') { stdout = @@ -196,7 +195,7 @@ A an_added_changed_file.js` inputs['skipLabels'] = 'A different label' inputs['missingUpdateErrorMessage'] = customErrorMessage - const execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { + execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { let stdout = '' if (args[0] == 'diff') { stdout = @@ -237,7 +236,7 @@ A an_added_changed_file.js` it('should enforce when label is not present; changelog is changed; branch not checked out', (done) => { inputs['skipLabels'] = 'A different label' - const execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { + execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { if (args[2] == 'fetch') { return 0 } @@ -282,4 +281,54 @@ M CHANGELOG.md` done() }) }) + + it('should enforce when label is not present; changelog is changed; branch not checked out; custom path', (done) => { + inputs['skipLabels'] = 'A different label' + inputs['changeLogPath'] = './path/to/CHANGELOG.md' + + execSpy = jest.spyOn(exec, 'exec').mockImplementation((command, args, options) => { + if (args[2] == 'fetch') { + return 0 + } + + let stdout = '' + if (args[0] == 'diff') { + stdout = +`M .env.js +M path/to/CHANGELOG.md` + } + if (args[0] == 'branch') { + stdout = +` * (HEAD detached at pull/27/merge) 6a67f6e Merge + pull/27/merge 6a67f6f` + } + options.listeners.stdout(stdout) + return 0 + }) + + changelogEnforcer.enforce() + .then(() => { + expect(infoSpy.mock.calls.length).toBe(5) + expect(execSpy.mock.calls.length).toBe(3) + expect(failureSpy).not.toHaveBeenCalled() + expect(outputSpy).not.toHaveBeenCalled() + + const command_branch = execSpy.mock.calls[0][0] + const command_branch_args = execSpy.mock.calls[0][1].join(' ') + expect(command_branch).toBe('git') + expect(command_branch_args).toBe('branch --verbose --all') + + const command_fetch = execSpy.mock.calls[1][0] + const command_fetch_args = execSpy.mock.calls[1][1].join(' ') + expect(command_fetch).toBe('git') + expect(command_fetch_args).toBe('-c protocol.version=2 fetch --depth=1 origin master') + + const command_diff = execSpy.mock.calls[2][0] + const command_diff_args = execSpy.mock.calls[2][1].join(' ') + expect(command_diff).toBe('git') + expect(command_diff_args).toBe('diff origin/master --name-status --diff-filter=AM') + + done() + }) + }) }) \ No newline at end of file diff --git a/action.yml b/action.yml index e1894cc8..85f568af 100644 --- a/action.yml +++ b/action.yml @@ -34,6 +34,9 @@ inputs: is passed as a String, you will need to escape a backslash \ character via \\" required: true default: "^## \\[((v|V)?\\d*\\.\\d*\\.\\d*-?\\w*|unreleased|Unreleased|UNRELEASED)\\]" + deprecatedMessage: | + "This input has been deprecated as of `v2.1.0`. In a future release - likely `v3.0.0`, the ChangeLog Enforcer will only support KeepAChangelog.com format + for finding the latst expected version" missingUpdateErrorMessage: description: "The error message logged and returned in the 'errorMessage' output when no update to the changelog has been found." required: false diff --git a/dist/index.js b/dist/index.js index 2fd4a958..494e1c84 100644 --- a/dist/index.js +++ b/dist/index.js @@ -7113,9 +7113,12 @@ async function checkChangeLog(baseRef, changeLogPath, missingUpdateErrorMessage) const fileName = change.replace(/(^[A-Z])(\s*)(.*)(\n)?$/g, '$3') fileNames.push(fileName) }) - - if (!fileNames.includes(changeLogPath)) { + let normalizedChangeLogPath = changeLogPath + if (normalizedChangeLogPath.startsWith('./')) { + normalizedChangeLogPath = normalizedChangeLogPath.substring(2) + } + if (!fileNames.includes(normalizedChangeLogPath)) { throw new Error(missingUpdateErrorMessage) } } diff --git a/package-lock.json b/package-lock.json index 05eb4a57..3a4b542a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "changelog-enforcer", - "version": "2.0.2", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1644,6 +1644,16 @@ "unset-value": "^1.0.0" } }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -2124,9 +2134,9 @@ } }, "eslint": { - "version": "7.21.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.21.0.tgz", - "integrity": "sha512-W2aJbXpMNofUp0ztQaF40fveSsJBjlSCSWpy//gzfTvwC+USs/nceBrKmlJOiM8r1bLwP2EuYkCqArn/6QTIgg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.23.0.tgz", + "integrity": "sha512-kqvNVbdkjzpFy0XOszNwjkKzZ+6TcwCQ/h+ozlcIWwaimBBuhlQ4nN6kbiM2L+OjDcznkTJxzYfRFH92sx4a0Q==", "dev": true, "requires": { "@babel/code-frame": "7.12.11", @@ -2146,7 +2156,7 @@ "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", - "globals": "^12.1.0", + "globals": "^13.6.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", @@ -2154,7 +2164,7 @@ "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", - "lodash": "^4.17.20", + "lodash": "^4.17.21", "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", @@ -2184,9 +2194,9 @@ "dev": true }, "@babel/highlight": { - "version": "7.13.8", - "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.13.8.tgz", - "integrity": "sha512-4vrIhfJyfNf+lCtXC2ck1rKSzDwciqF7IWFhXXrSOUC2O5DrVp+w4c6ed4AllTxhTkUP5x2tYj41VaxdVMMRDw==", + "version": "7.13.10", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.13.10.tgz", + "integrity": "sha512-5aPpe5XQPzflQrFwL1/QoeHkP2MsA4JCntcXHRhEsdsfPVkvPi2w7Qix4iV7t5S/oC9OodGrggd8aco1g3SZFg==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.12.11", @@ -2264,12 +2274,12 @@ } }, "globals": { - "version": "12.4.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", - "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", + "version": "13.7.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.7.0.tgz", + "integrity": "sha512-Aipsz6ZKRxa/xQkZhNg0qIWXT6x6rD46f6x/PCnBomlttdIyAPak4YD9jTmKpZ72uROSMU87qJtcgpgHaVchiA==", "dev": true, "requires": { - "type-fest": "^0.8.1" + "type-fest": "^0.20.2" } }, "has-flag": { @@ -2321,9 +2331,9 @@ "dev": true }, "semver": { - "version": "7.3.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw==", + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { "lru-cache": "^6.0.0" @@ -2353,6 +2363,12 @@ "prelude-ls": "^1.2.1" } }, + "type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true + }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -2828,6 +2844,17 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, "get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -2873,9 +2900,9 @@ } }, "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "requires": { "is-glob": "^4.0.1" @@ -2931,6 +2958,12 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -3118,6 +3151,15 @@ "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true }, + "is-boolean-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz", + "integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==", + "dev": true, + "requires": { + "call-bind": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.6", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", @@ -3227,6 +3269,12 @@ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, + "is-number-object": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", + "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==", + "dev": true + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3248,6 +3296,12 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -4783,12 +4837,30 @@ "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, + "lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", + "dev": true + }, "lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=", "dev": true }, + "lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -6253,21 +6325,26 @@ "dev": true }, "table": { - "version": "6.0.7", - "resolved": "https://registry.npmjs.org/table/-/table-6.0.7.tgz", - "integrity": "sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==", - "dev": true, - "requires": { - "ajv": "^7.0.2", - "lodash": "^4.17.20", + "version": "6.0.8", + "resolved": "https://registry.npmjs.org/table/-/table-6.0.8.tgz", + "integrity": "sha512-OBAdezyozae8IvjHGXBDHByVkLCcsmffXUSj8LXkNb0SluRd4ug3GFCjk6JynZONIPhOkyr0Nnvbq1rlIspXyQ==", + "dev": true, + "requires": { + "ajv": "^8.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "lodash.clonedeep": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", "string-width": "^4.2.0" }, "dependencies": { "ajv": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-7.1.1.tgz", - "integrity": "sha512-ga/aqDYnUy/o7vbsRTFhhTsNeXiYb5JWDIcRIeZfwRNCefwjNTVYCGdGSUrEmiu3yDK3vFvNbgJxvrQW4JXrYQ==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.0.1.tgz", + "integrity": "sha512-46ZA4TalFcLLqX1dEU3dhdY38wAtDydJ4e7QQTVekLUTzXkb1LfqU6VOBXC/a9wiv4T094WURqJH6ZitF92Kqw==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", @@ -6281,12 +6358,6 @@ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true - }, - "lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true } } }, @@ -6447,9 +6518,9 @@ } }, "uglify-js": { - "version": "3.13.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.0.tgz", - "integrity": "sha512-TWYSWa9T2pPN4DIJYbU9oAjQx+5qdV5RUDxwARg8fmJZrD/V27Zj0JngW5xg1DFz42G0uDYl2XhzF6alSzD62w==" + "version": "3.13.2", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.2.tgz", + "integrity": "sha512-SbMu4D2Vo95LMC/MetNaso1194M1htEA+JrqE9Hk+G2DhI+itfS9TRu9ZKeCahLDNa/J3n4MqUJ/fOHMzQpRWw==" }, "union-value": { "version": "1.0.1", @@ -6537,9 +6608,9 @@ "optional": true }, "v8-compile-cache": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.2.0.tgz", - "integrity": "sha512-gTpR5XQNKFwOd4clxfnhaqvfqMpqEwr4tOtCyz4MtYZX2JYhfr1JvBFKdS+7K/9rfpZR3VLX+YWBbKoxCgS43Q==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, "v8-to-istanbul": { diff --git a/package.json b/package.json index 4ba7e450..b90597dd 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "changelog-enforcer", - "version": "2.0.2", + "version": "2.1.0", "description": "Enforces that a changelog is kept up-to-date", "main": "index.js", "scripts": { "lint": "eslint index.js", "package": "ncc build index.js -o dist", "test": "eslint index.js && jest --coverage", - "test:badges": "npm test && make-coverage-badge" + "test:badges": "npm test && make-coverage-badge", + "all": "npm run test:badges && npm run package" }, "repository": { "type": "git", @@ -34,11 +35,11 @@ "@actions/github": "^4.0.0", "dist": "^0.1.2", "make-coverage-badge": "^1.2.0", - "uglify-js": "^3.13.0" + "uglify-js": "^3.13.2" }, "devDependencies": { "@vercel/ncc": "^0.27.0", - "eslint": "^7.21.0", + "eslint": "^7.23.0", "jest": "^26.6.3" } } diff --git a/src/changelog-enforcer.js b/src/changelog-enforcer.js index 642a2d28..89c1c88b 100644 --- a/src/changelog-enforcer.js +++ b/src/changelog-enforcer.js @@ -100,9 +100,12 @@ async function checkChangeLog(baseRef, changeLogPath, missingUpdateErrorMessage) const fileName = change.replace(/(^[A-Z])(\s*)(.*)(\n)?$/g, '$3') fileNames.push(fileName) }) - - if (!fileNames.includes(changeLogPath)) { + let normalizedChangeLogPath = changeLogPath + if (normalizedChangeLogPath.startsWith('./')) { + normalizedChangeLogPath = normalizedChangeLogPath.substring(2) + } + if (!fileNames.includes(normalizedChangeLogPath)) { throw new Error(missingUpdateErrorMessage) } }