-
-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add ability to constrain scopes (#66)
* feat: Constrain scopes * Adapt action config * Fix NPE * Add logging * Change env param name * Remove logging * Optional scope * Remove config
- Loading branch information
Showing
8 changed files
with
153 additions
and
15 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -10,6 +10,7 @@ Examples for valid PR titles: | |
- fix: Correct typo. | ||
- feat: Add support for Node 12. | ||
- refactor!: Drop support for Node 6. | ||
- feat(ui): Add `Button` component. | ||
|
||
Note that since PR titles only have a single line, you have to use the `!` syntax for breaking changes. | ||
|
||
|
@@ -40,10 +41,19 @@ jobs: | |
- uses: amannn/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
# Optionally you can configure which types are allowed. | ||
# Default: https://github.com/commitizen/conventional-commit-types | ||
# Optionally, you can provide options for further constraints. | ||
with: | ||
types: fix, feat | ||
# Configure which types are allowed. | ||
# Default: https://github.com/commitizen/conventional-commit-types | ||
types: | | ||
fix | ||
feat | ||
# Configure which scopes are allowed. | ||
scopes: | | ||
core | ||
ui | ||
# Configure that a scope must always be provided. | ||
requireScope: true | ||
``` | ||
## Event triggers | ||
|
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
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,14 @@ | ||
const ENUM_SPLIT_REGEX = /[,\s]\s*/; | ||
|
||
module.exports = { | ||
parseEnum(input) { | ||
return input | ||
.split(ENUM_SPLIT_REGEX) | ||
.map((part) => part.trim()) | ||
.filter((part) => part.length > 0); | ||
}, | ||
|
||
parseBoolean(input) { | ||
return JSON.parse(input.trim()); | ||
} | ||
}; |
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,21 @@ | ||
const ConfigParser = require('./ConfigParser'); | ||
|
||
describe('parseEnum', () => { | ||
it('parses commas', () => { | ||
expect(ConfigParser.parseEnum('one, two,three, \nfour ')).toEqual([ | ||
'one', | ||
'two', | ||
'three', | ||
'four' | ||
]); | ||
}); | ||
|
||
it('parses white space', () => { | ||
expect(ConfigParser.parseEnum('one two\nthree \n\rfour')).toEqual([ | ||
'one', | ||
'two', | ||
'three', | ||
'four' | ||
]); | ||
}); | ||
}); |
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
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,20 @@ | ||
const ConfigParser = require('./ConfigParser'); | ||
|
||
module.exports = function parseConfig() { | ||
let types; | ||
if (process.env.INPUT_TYPES) { | ||
types = ConfigParser.parseEnum(process.env.INPUT_TYPES); | ||
} | ||
|
||
let scopes; | ||
if (process.env.INPUT_SCOPES) { | ||
scopes = ConfigParser.parseEnum(process.env.INPUT_SCOPES); | ||
} | ||
|
||
let requireScope; | ||
if (process.env.INPUT_REQUIRESCOPE) { | ||
requireScope = ConfigParser.parseBoolean(process.env.INPUT_REQUIRESCOPE); | ||
} | ||
|
||
return {types, scopes, requireScope}; | ||
}; |
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
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