Skip to content

Commit

Permalink
Releases/v2.1 (#88)
Browse files Browse the repository at this point in the history
* 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](mishoo/UglifyJS@v3.13.0...v3.13.2)

Signed-off-by: dependabot[bot] <[email protected]>

* 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 <[email protected]>
Co-authored-by: Dan Goslen <[email protected]>

* 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](eslint/eslint@v7.21.0...v7.23.0)

Signed-off-by: dependabot[bot] <[email protected]>

* 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 <[email protected]>
Co-authored-by: Dan Goslen <[email protected]>

* 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 <[email protected]>
  • Loading branch information
3 people authored Mar 30, 2021
1 parent ffe7ab3 commit 62066c8
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 85 deletions.
4 changes: 3 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ updates:
open-pull-requests-limit: 3
schedule:
interval: "daily"
target-branch: "releases/v2.1"
- package-ecosystem: "github-actions"
directory: "/"
labels:
Expand All @@ -18,4 +19,5 @@ updates:
- Skip-Changelog
open-pull-requests-limit: 3
schedule:
interval: "daily"
interval: "daily"
target-branch: "releases/v2.2"
27 changes: 21 additions & 6 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
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:
Expand All @@ -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

Expand All @@ -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 }}
Expand Down
39 changes: 17 additions & 22 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,63 +29,53 @@ 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.

## [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/[email protected]` to `@actions/[email protected]`

### 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`

Expand All @@ -92,33 +87,33 @@ 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
- `[email protected]` to `[email protected]`

## [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
63 changes: 56 additions & 7 deletions __tests__/changelog-enforcer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {

Expand All @@ -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 })
})

Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
})
})
})
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
Loading

0 comments on commit 62066c8

Please sign in to comment.