pixie icon indicating copy to clipboard operation
pixie copied to clipboard

Automate amqp code generation and add test to catch drift

Open ddelnano opened this issue 1 year ago • 6 comments

Summary: Automate amqp code generation and add test to catch drift

This is a work in progress change to implement what was described here.

Relevant Issues: https://github.com/pixie-io/pixie/pull/1820#issuecomment-1905273586

Type of change: /kind cleanup

Test Plan: diff_file rules fail until linting issues are resolved

screen

ddelnano avatar Jan 24 '24 02:01 ddelnano

I think it's okay to skip linting for autogenerated files. Might be worth adding them to the exclusion list and calling this done.

vihangm avatar Jan 24 '24 04:01 vihangm

I think if you reduce the tab/spaces in the returns for gen_method_enum_select_case, gen_method_enum_declr etc to the expected output, the generated code is probably mostly formatted as expected.

There's a lot of them though, so unsure if it's worth the trouble.

vihangm avatar Jan 24 '24 07:01 vihangm

I was expecting the diff 'as is' to be pretty nasty, which is why I tried to keep the code formatting intact initially. I'll see how difficult it is to get the code generation to output relatively formatted code.

ddelnano avatar Jan 24 '24 07:01 ddelnano

@vihangm my latest approach gets the files formatted with minor whitespace differences. It required quite a few changes to the amqp code generation file. The changes to amqp_code_gen.py could be cleaner, but I wanted to get a feel for how many lines needed to be touched to make the diff reasonable. It required enough whitespace changes that my preference would be to stick with the initial approach that formatted the output files according to our clang-format config.

Let me know what you think. I'm holding off on fixing the amqp_code_gen_test.py tests until we have consensus on this PR's direction.

ddelnano avatar Jan 25 '24 06:01 ddelnano

Given that you have spent a bunch of time here, I trust your judgement. If you think running clang-format as part of the generation isn't too much trouble, that approach seems fine too. I was worried that running the linter would be more painful and hence suggested skipping lint/updating the code generation. :)

vihangm avatar Jan 25 '24 17:01 vihangm

Sounds good :+1:. I've updated the branch based on the initial approach and it's ready for review now.

ddelnano avatar Jan 26 '24 06:01 ddelnano