mirror of
https://github.com/actions/labeler.git
synced 2025-12-15 06:27:13 +00:00
Apply suggestions for the beta vesrion and update the documentation
This commit is contained in:
@@ -17,9 +17,9 @@ describe('checkAllChangedFiles', () => {
|
||||
|
||||
describe('when all given glob pattern configs matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['foo.txt']},
|
||||
{AnyGlobToAllFiles: ['*.txt']},
|
||||
{AllGlobsToAllFiles: ['**']}
|
||||
{anyGlobToAnyFile: ['foo.txt']},
|
||||
{anyGlobToAllFiles: ['*.txt']},
|
||||
{allGlobsToAllFiles: ['**']}
|
||||
];
|
||||
|
||||
it('returns true', () => {
|
||||
@@ -34,9 +34,9 @@ describe('checkAllChangedFiles', () => {
|
||||
|
||||
describe(`when some given glob pattern config did not match`, () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['*.txt']},
|
||||
{AllGlobsToAllFiles: ['**']}
|
||||
{anyGlobToAnyFile: ['*.md']},
|
||||
{anyGlobToAllFiles: ['*.txt']},
|
||||
{allGlobsToAllFiles: ['**']}
|
||||
];
|
||||
|
||||
it('returns false', () => {
|
||||
@@ -55,8 +55,8 @@ describe('checkAnyChangedFiles', () => {
|
||||
|
||||
describe('when any given glob pattern config matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['*.txt']}
|
||||
{anyGlobToAnyFile: ['*.md']},
|
||||
{anyGlobToAllFiles: ['*.txt']}
|
||||
];
|
||||
|
||||
it('returns true', () => {
|
||||
@@ -71,8 +71,8 @@ describe('checkAnyChangedFiles', () => {
|
||||
|
||||
describe('when none of the given glob pattern configs matched', () => {
|
||||
const globPatternsConfigs = [
|
||||
{AnyGlobToAnyFile: ['*.md']},
|
||||
{AnyGlobToAllFiles: ['!*.txt']}
|
||||
{anyGlobToAnyFile: ['*.md']},
|
||||
{anyGlobToAllFiles: ['!*.txt']}
|
||||
];
|
||||
|
||||
it('returns false', () => {
|
||||
@@ -123,23 +123,25 @@ describe('toChangedFilesMatchConfig', () => {
|
||||
|
||||
describe('and the glob pattern config key is provided', () => {
|
||||
describe('and the value is an array of strings', () => {
|
||||
const config = {'changed-files': [{AnyGlobToAnyFile: ['testing']}]};
|
||||
const config = {
|
||||
'changed-files': [{'any-glob-to-any-file': ['testing']}]
|
||||
};
|
||||
|
||||
it('sets the value in the config object', () => {
|
||||
const result = toChangedFilesMatchConfig(config);
|
||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing']}]
|
||||
changedFiles: [{anyGlobToAnyFile: ['testing']}]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('and the value is a string', () => {
|
||||
const config = {'changed-files': [{AnyGlobToAnyFile: 'testing'}]};
|
||||
const config = {'changed-files': [{'any-glob-to-any-file': 'testing'}]};
|
||||
|
||||
it(`sets the string as an array in the config object`, () => {
|
||||
const result = toChangedFilesMatchConfig(config);
|
||||
expect(result).toEqual<ChangedFilesMatchConfig>({
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing']}]
|
||||
changedFiles: [{anyGlobToAnyFile: ['testing']}]
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
label1:
|
||||
- any:
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['glob']
|
||||
- any-glob-to-any-file: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
- all:
|
||||
- changed-files:
|
||||
- AllGlobsToAllFiles: ['glob']
|
||||
- all-globs-to-all-files: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
|
||||
label2:
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['glob']
|
||||
- any-glob-to-any-file: ['glob']
|
||||
- head-branch: ['regexp']
|
||||
- base-branch: ['regexp']
|
||||
|
||||
@@ -2,7 +2,7 @@ tests:
|
||||
- any:
|
||||
- head-branch: ['^tests/', '^test/']
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['tests/**/*']
|
||||
- any-glob-to-any-file: ['tests/**/*']
|
||||
- all:
|
||||
- changed-files:
|
||||
- AllGlobsToAllFiles: ['!tests/requirements.txt']
|
||||
- all-globs-to-all-files: ['!tests/requirements.txt']
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
touched-a-pdf-file:
|
||||
- changed-files:
|
||||
- AnyGlobToAnyFile: ['*.pdf']
|
||||
- any-glob-to-any-file: ['*.pdf']
|
||||
|
||||
@@ -29,14 +29,14 @@ describe('getLabelConfigMapFromObject', () => {
|
||||
expected.set('label1', [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['glob']}]},
|
||||
{changedFiles: [{anyGlobToAnyFile: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
},
|
||||
{
|
||||
all: [
|
||||
{changedFiles: [{AllGlobsToAllFiles: ['glob']}]},
|
||||
{changedFiles: [{allGlobsToAllFiles: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
@@ -45,7 +45,7 @@ describe('getLabelConfigMapFromObject', () => {
|
||||
expected.set('label2', [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['glob']}]},
|
||||
{changedFiles: [{anyGlobToAnyFile: ['glob']}]},
|
||||
{baseBranch: undefined, headBranch: ['regexp']},
|
||||
{baseBranch: ['regexp'], headBranch: undefined}
|
||||
]
|
||||
@@ -61,12 +61,12 @@ describe('getLabelConfigMapFromObject', () => {
|
||||
describe('toMatchConfig', () => {
|
||||
describe('when all expected config options are present', () => {
|
||||
const config = {
|
||||
'changed-files': [{AnyGlobToAnyFile: ['testing-files']}],
|
||||
'changed-files': [{'any-glob-to-any-file': ['testing-files']}],
|
||||
'head-branch': ['testing-head'],
|
||||
'base-branch': ['testing-base']
|
||||
};
|
||||
const expected: BaseMatchConfig = {
|
||||
changedFiles: [{AnyGlobToAnyFile: ['testing-files']}],
|
||||
changedFiles: [{anyGlobToAnyFile: ['testing-files']}],
|
||||
headBranch: ['testing-head'],
|
||||
baseBranch: ['testing-base']
|
||||
};
|
||||
@@ -90,7 +90,7 @@ describe('toMatchConfig', () => {
|
||||
describe('checkMatchConfigs', () => {
|
||||
describe('when a single match config is provided', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]}
|
||||
{any: [{changedFiles: [{anyGlobToAnyFile: ['*.txt']}]}]}
|
||||
];
|
||||
|
||||
it('returns true when our pattern does match changed files', () => {
|
||||
@@ -111,7 +111,7 @@ describe('checkMatchConfigs', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{
|
||||
any: [
|
||||
{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]},
|
||||
{changedFiles: [{anyGlobToAnyFile: ['*.txt']}]},
|
||||
{headBranch: ['some-branch']}
|
||||
]
|
||||
}
|
||||
@@ -139,7 +139,7 @@ describe('checkMatchConfigs', () => {
|
||||
|
||||
describe('when multiple MatchConfigs are supplied', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{changedFiles: [{anyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{headBranch: ['some-branch']}]}
|
||||
];
|
||||
const changedFiles = ['foo.txt', 'bar.md'];
|
||||
@@ -151,7 +151,7 @@ describe('checkMatchConfigs', () => {
|
||||
|
||||
it('returns true when only both config matches', () => {
|
||||
const matchConfig: MatchConfig[] = [
|
||||
{any: [{changedFiles: [{AnyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{changedFiles: [{anyGlobToAnyFile: ['*.txt']}]}]},
|
||||
{any: [{headBranch: ['head-branch']}]}
|
||||
];
|
||||
const result = checkMatchConfigs(changedFiles, matchConfig, false);
|
||||
|
||||
Reference in New Issue
Block a user