Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(labeler.yml)!: changes --emitLabeler to emit labeler@v5 format labeler.yml - BREAKING #163

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@
#

vco:
- "**"
- README.md
- changed-files:
- any-glob-to-any-file: "**"
- any-glob-to-any-file: README.md

vco-admins:
- .github/**
- tools/**
- changed-files:
- any-glob-to-any-file: .github/**
- any-glob-to-any-file: tools/**

tools:
- tools/**
- changed-files:
- any-glob-to-any-file: tools/**

admin:
- .github/**
- changed-files:
- any-glob-to-any-file: .github/**

documentation:
- README.md
- changed-files:
- any-glob-to-any-file: README.md

2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
sync-labels: true
dot: true
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,15 @@ npx virtual-code-owners --emitLabeler
If you have an alternate file location for the `labeler.yml` you can specify that
with virtual-code-owner's `--labelerLocation` parameter.

> [!NOTE]
> actions/labeler changed the labeler.yml format from v4 to v5.
>
> - virtual-code-owners < 8.0.0 generates labeler.yml v4 format,
> - virtual-code-owners >= 8.0.0 generates labeler.yml v5 format.
>
> see [actions/labeler#v5](https://github.com/actions/labeler/blob/8558fd74291d67161a8a78ce36a881fa63b766a9/README.md)
> for details on the v5 format.

### What validations does virtual-code-owners perform?

virtual-code-owners checks for basic CODEOWNERS format errors and invalid
Expand Down
9 changes: 7 additions & 2 deletions dist/labeler-yml/generate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 17 additions & 11 deletions src/labeler-yml/__fixtures__/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
ch/after-sales:
- libs/ubc-after-sales/**
- libs/ubc-refund/**
- changed-files:
- any-glob-to-any-file: libs/ubc-after-sales/**
- any-glob-to-any-file: libs/ubc-refund/**

ch/sales:
- libs/ubc-sales/**
- libs/ubc-refund/**
- changed-files:
- any-glob-to-any-file: libs/ubc-sales/**
- any-glob-to-any-file: libs/ubc-refund/**

ch/pre-sales:
- libs/ubc-pre-sales/**
- changed-files:
- any-glob-to-any-file: libs/ubc-pre-sales/**

ch/ux:
- apps/ux-portal/**
- libs/components/**
- changed-files:
- any-glob-to-any-file: apps/ux-portal/**
- any-glob-to-any-file: libs/components/**

ch/transversal:
- .github/**
- apps/framework/**
- apps/ux-portal/**
- changed-files:
- any-glob-to-any-file: .github/**
- any-glob-to-any-file: apps/framework/**
- any-glob-to-any-file: apps/ux-portal/**

ch/mannen-met-baarden:
- libs/ubc-baarden/**
- changed-files:
- any-glob-to-any-file: libs/ubc-baarden/**
12 changes: 8 additions & 4 deletions src/labeler-yml/generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe("generate-labeler-yml generates a labeler.yml", () => {
},
];
const lExpected = `the-a-team:
- knakkerdeknak/**
- changed-files:
- any-glob-to-any-file: knakkerdeknak/**

`;
equal(generateLabelerYml(lVirtualCodeOwners, TEAMS, ""), lExpected);
Expand All @@ -108,7 +109,8 @@ describe("generate-labeler-yml generates a labeler.yml", () => {
},
];
const lExpected = `baarden:
- "**"
- changed-files:
- any-glob-to-any-file: "**"

`;
equal(generateLabelerYml(lVirtualCodeOwners, TEAMS, ""), lExpected);
Expand All @@ -134,7 +136,8 @@ describe("generate-labeler-yml generates a labeler.yml", () => {
},
];
const lExpected = `baarden:
- "*/src/vlaai/*"
- changed-files:
- any-glob-to-any-file: "*/src/vlaai/*"

`;
equal(generateLabelerYml(lVirtualCodeOwners, TEAMS, ""), lExpected);
Expand All @@ -160,7 +163,8 @@ describe("generate-labeler-yml generates a labeler.yml", () => {
},
];
const lExpected = `# some header or other${EOL}baarden:
- src/vlaai/**
- changed-files:
- any-glob-to-any-file: src/vlaai/**

`;
equal(
Expand Down
9 changes: 7 additions & 2 deletions src/labeler-yml/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ export default function generateLabelerYml(
let lReturnValue = pGeneratedWarning;
for (const lTeamName in pTeamMap) {
const lPatternsForTeam = getPatternsForTeam(pCodeOwners, lTeamName)
.map((pPattern) => ` - ${transformForYamlAndMinimatch(pPattern)}${EOL}`)
.map(
(pPattern) =>
` - any-glob-to-any-file: ${transformForYamlAndMinimatch(
pPattern,
)}${EOL}`,
)
.join("");

if (lPatternsForTeam) {
lReturnValue += `${lTeamName}:${EOL}${lPatternsForTeam}${EOL}`;
lReturnValue += `${lTeamName}:${EOL} - changed-files:${EOL}${lPatternsForTeam}${EOL}`;
}
}
return lReturnValue;
Expand Down