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

Add path based rules and pester tests #3182

Closed
wants to merge 5 commits into from

Conversation

hallipr
Copy link
Member

@hallipr hallipr commented Apr 16, 2024

fixes #3181

eng/common/pipelines/ci.yml Show resolved Hide resolved
foreach ($rule in $pathBasedRules.Keys) {
foreach ($rulePath in $pathBasedRules[$rule]) {
if ($runAll -or $root.PathExists($rulePath)) {
$variables += $rule
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if you have 2 paths for the same variable? Would we set that variable twice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The break; below pops us out of the "path" forEach back into the "rule" forEach. So we should only add a rule name once after we find the first matching path for the rule

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rule name is the variable name, so we wouldn't have 2 rules with the same variable name

@bterlson bterlson added the eng label May 10, 2024
@hallipr hallipr force-pushed the users/pahallis/use-pester branch from 98e7399 to 01efb1c Compare May 16, 2024 18:26
Copy link
Member

@m-nash m-nash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I don't think this change is an improvement in readability / debugability. Reading a bunch of regex's is not exactly intuitive and unless we have perfect unit tests we will miss quite a few things.

$this.RunVariable = $runVariable
$this.RunValue = $runValue
}
$runAll = @('^eng/common/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is more to run all than this, there was a recent pr which added some.

# exclude paths start with '!'
$pathBasedRules = @{
'RunEng' = @('^eng/common/scripts/')
'RunCSharp' = $runAll, '^packages/http-client-csharp', '^\.editorconfig$'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should editorconfig trigger all emitters?

'RunJava' = $runAll, '^packages/http-client-java/'
'RunTypeScript' = $runAll, '^packages/http-client-typescript/'
'RunPython' = $runAll, '^packages/http-client-python/'
'RunCore' = @(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is more than should be excluded here around eng/emitter stuff

Copy link
Member

@timotheeguerin timotheeguerin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this PR does a similar thing how I was gonna rewrite that in TS to reuse the same label config. Difference is I am just using standard gitignore wildcard pattern which I think is easier to maintain than regex for paths.

import { AreaPaths } from "./areas.js";

/**
 * Path that should trigger every CI build.
 */
const all = ["eng/common/", "vitest.config.ts"];

export const CITriggers = {
  "http-client-csharp": [...AreaPaths["emitter:client:csharp"], ...all],
  core: [
    "**/*",
    "!.prettierignore",
    "!.prettierrc.json",
    "!cspell.yaml",
    "!esling.config.json",
    ...ignore(AreaPaths["emitter:client:csharp"]),
  ],
};

Add vi.config.ts to runAll
@hallipr
Copy link
Member Author

hallipr commented May 24, 2024

Oh this PR does a similar thing how I was gonna rewrite that in TS

I like the look of the minimatch patterns more that the regex. I'll close this PR

@hallipr hallipr closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add execution of unit tests if they get changed
4 participants