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

build: codegen to call clean and do so on a per package basis #2736

Closed
petermetz opened this issue Oct 3, 2023 · 2 comments · Fixed by #2818
Closed

build: codegen to call clean and do so on a per package basis #2736

petermetz opened this issue Oct 3, 2023 · 2 comments · Fixed by #2818
Assignees
Labels
bug Something isn't working dependencies Pull requests that update a dependency file Developer_Experience good-first-issue-400-expert Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. Nice-to-Have P4 Priority 4: Low
Milestone

Comments

@petermetz
Copy link
Contributor

Description

This is a follow-up with a longer term solution to the short term fix that we applied in #2730 for the same problem that the referenced issue is about (which could and will prop up again in the future in a different form for sure)

For the future: The current solution is kind-of lackluster, we have this giant npm script cleaning out a long list of directories and it is separate from the codegen script so the contributors are responsible for running both. A better long term solution would be to make sure that the codegen script calls the clean automatically before it starts generating the new code so that this situation we were in just now is impossible to happen (otherwise it will keep happening for sure)

Historically I've shied away from doing the above because we have some packages that have code generation that is not fully automated (the rust crates need a lot of customization that is manual IIRC) but if we do it right, it could be done right for most of the packages.

Acceptance Criteria

  1. The codegen script works and it does NOT create any changes in the diff after repeated runs on the same code (assuming you've committed the changes after the first run).
  2. The clean script is refactored so that it calls the package's own codegen:clean script which is responsible for the package's generated code to be cleaned out and also for excluding files that do not need to be cleaned out such as the openapi-generator-ignore files
  3. openapi-generator-ignore files are not deleted

cc: @jagpreetsinghsasan

@petermetz petermetz added bug Something isn't working Nice-to-Have dependencies Pull requests that update a dependency file Developer_Experience Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. good-first-issue-400-expert P4 Priority 4: Low labels Oct 3, 2023
@petermetz petermetz added this to the v3.0.0 milestone Oct 3, 2023
@jagpreetsinghsasan jagpreetsinghsasan self-assigned this Oct 9, 2023
@jagpreetsinghsasan
Copy link
Contributor

jagpreetsinghsasan commented Oct 9, 2023

@petermetz for the openapi-generator-ignore files, we can have this as an alternate (will have to see if we can use some advanced regex so that we can have language specific client code ignore like gradle for java/kotlin, or inline arguments to openapi-generator to facilitate this)
image

Like in case of java codegen, I used this inline argument to prevent timestamp comments (to prevent git diff pollution everytime codegen is run): --additional-properties hideGenerationTimestamp=true

@petermetz
Copy link
Contributor Author

@jagpreetsinghsasan Niceee, this could be a good alternative later to match/replace the clean script ignoring the ignore files.

@jagpreetsinghsasan jagpreetsinghsasan moved this from Todo to In Progress in Cacti_Scrum_Project_v2_Release Oct 11, 2023
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Oct 17, 2023
    Primary Changes
    ---------------
    1. Updated codegen scripts of all affected packages to include a global
       openapi-generator-ignore file
    2. Created script to clean openapi folders generated by codegen for
       typescript-axios and kotlin

    Secondary Changes
    -----------------
    1. Removed duplicated code generated previously when codegen clear wasn't
       enabled
    2. Created openapi-generator-ignore file at project root for global ignore
       rules
    3. Updated package.json of all affected packages, extensions and examples

Fixes hyperledger-cacti#2736

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
@jagpreetsinghsasan jagpreetsinghsasan moved this from In Progress to In review in Cacti_Scrum_Project_v2_Release Oct 20, 2023
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Oct 27, 2023
    Primary Changes
    ---------------
    1. Updated codegen scripts of all affected packages to include a global
       openapi-generator-ignore file
    2. Created script to clean openapi folders generated by codegen for
       typescript-axios and kotlin

    Secondary Changes
    -----------------
    1. Removed duplicated code generated previously when codegen clear wasn't
       enabled
    2. Created openapi-generator-ignore file at project root for global ignore
       rules
    3. Updated package.json of all affected packages, extensions and examples

Fixes hyperledger-cacti#2736

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Oct 27, 2023
    Primary Changes
    ---------------
    1. Updated codegen scripts of all affected packages to include a global
       openapi-generator-ignore file
    2. Created script to clean openapi folders generated by codegen for
       typescript-axios and kotlin

    Secondary Changes
    -----------------
    1. Removed duplicated code generated previously when codegen clear wasn't
       enabled
    2. Created openapi-generator-ignore file at project root for global ignore
       rules
    3. Updated package.json of all affected packages, extensions and examples

Fixes hyperledger-cacti#2736

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Oct 27, 2023
    Primary Changes
    ---------------
    1. Updated codegen scripts of all affected packages to include a global
       openapi-generator-ignore file
    2. Created script to clean openapi folders generated by codegen for
       typescript-axios and kotlin

    Secondary Changes
    -----------------
    1. Removed duplicated code generated previously when codegen clear wasn't
       enabled
    2. Created openapi-generator-ignore file at project root for global ignore
       rules
    3. Updated package.json of all affected packages, extensions and examples

Fixes hyperledger-cacti#2736

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
jagpreetsinghsasan added a commit to jagpreetsinghsasan/cactus that referenced this issue Nov 8, 2023
    Primary Changes
    ---------------
    1. Updated codegen scripts of all affected packages to include a global
       openapi-generator-ignore file
    2. Created script to clean openapi folders generated by codegen for
       typescript-axios and kotlin

    Secondary Changes
    -----------------
    1. Removed duplicated code generated previously when codegen clear wasn't
       enabled
    2. Created openapi-generator-ignore file at project root for global ignore
       rules
    3. Updated package.json of all affected packages, extensions and examples

Fixes hyperledger-cacti#2736

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
petermetz pushed a commit to jagpreetsinghsasan/cactus that referenced this issue Dec 6, 2023
Primary Changes
---------------
1. Updated codegen scripts of all affected packages to include a global
   openapi-generator-ignore file
2. Created script to clean openapi folders generated by codegen for
   typescript-axios and kotlin

Secondary Changes
-----------------
1. Removed duplicated code generated previously when codegen clear wasn't
   enabled
2. Created openapi-generator-ignore file at project root for global ignore
   rules
3. Updated package.json of all affected packages, extensions and examples

Peter's Additional Changes
--------------------------
1. The sawtooth connector's package.json's codegen script had to also be
updated so that it uses the central ignore file from the root
2. yarn.lock update (because it's out of date on the main branch)

Fixes hyperledger-cacti#2736

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz pushed a commit to jagpreetsinghsasan/cactus that referenced this issue Dec 7, 2023
Primary Changes
---------------
1. Updated codegen scripts of all affected packages to include a global
   openapi-generator-ignore file
2. Created script to clean openapi folders generated by codegen for
   typescript-axios and kotlin

Secondary Changes
-----------------
1. Removed duplicated code generated previously when codegen clear wasn't
   enabled
2. Created openapi-generator-ignore file at project root for global ignore
   rules
3. Updated package.json of all affected packages, extensions and examples

Peter's Additional Changes
--------------------------
1. The sawtooth connector's package.json's codegen script had to also be
updated so that it uses the central ignore file from the root
2. yarn.lock update (because it's out of date on the main branch)

Fixes hyperledger-cacti#2736

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
petermetz pushed a commit that referenced this issue Dec 7, 2023
Primary Changes
---------------
1. Updated codegen scripts of all affected packages to include a global
   openapi-generator-ignore file
2. Created script to clean openapi folders generated by codegen for
   typescript-axios and kotlin

Secondary Changes
-----------------
1. Removed duplicated code generated previously when codegen clear wasn't
   enabled
2. Created openapi-generator-ignore file at project root for global ignore
   rules
3. Updated package.json of all affected packages, extensions and examples

Peter's Additional Changes
--------------------------
1. The sawtooth connector's package.json's codegen script had to also be
updated so that it uses the central ignore file from the root
2. yarn.lock update (because it's out of date on the main branch)

Fixes #2736

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
@github-project-automation github-project-automation bot moved this from In review to Done in Cacti_Scrum_Project_v2_Release Dec 7, 2023
sandeepnRES pushed a commit to sandeepnRES/cacti that referenced this issue Dec 21, 2023
Primary Changes
---------------
1. Updated codegen scripts of all affected packages to include a global
   openapi-generator-ignore file
2. Created script to clean openapi folders generated by codegen for
   typescript-axios and kotlin

Secondary Changes
-----------------
1. Removed duplicated code generated previously when codegen clear wasn't
   enabled
2. Created openapi-generator-ignore file at project root for global ignore
   rules
3. Updated package.json of all affected packages, extensions and examples

Peter's Additional Changes
--------------------------
1. The sawtooth connector's package.json's codegen script had to also be
updated so that it uses the central ignore file from the root
2. yarn.lock update (because it's out of date on the main branch)

Fixes hyperledger-cacti#2736

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: jagpreetsinghsasan <jagpreet.singh.sasan@accenture.com>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file Developer_Experience good-first-issue-400-expert Hacktoberfest Hacktoberfest participants are welcome to take a stab at issues marked with this label. Nice-to-Have P4 Priority 4: Low
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants