Skip to content

Conversation

bmuskalla
Copy link
Contributor

Takes the model generator and any framework model we have on main and regenerates the model using the latest and greatest model generator. This enables us to update and evolve the models without manual intervention.

@bmuskalla bmuskalla added the Java label Jan 27, 2022
@bmuskalla bmuskalla requested a review from a team as a code owner January 27, 2022 10:17
@bmuskalla bmuskalla added the no-change-note-required This PR does not need a change note label Jan 27, 2022
Comment on lines +32 to +40
- name: Build database
env:
SLUG: ${{ matrix.slug }}
REF: ${{ matrix.ref }}
run: |
mkdir dbs
cd repos/${REF}
SHORTNAME=${SLUG//[^a-zA-Z0-9_]/}
codeql database create --language=java ../../dbs/${SHORTNAME}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could consider using actions/cache for this

@bmuskalla
Copy link
Contributor Author

@tamasvajk In case you have some time, I'd appreciate if someone could look at this action. Happy to pair if anything is unclear

michaelnebel
michaelnebel previously approved these changes Feb 4, 2022
Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

This is really good work!

I have added a couple of suggestions, but these could also just be follow ups - so not anything blocking.

import sys


lgtmSlugToModelFile = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we consider introducing an invariant instead of an explicit mapping?
The root path could be java/ql/lib/semmle/code/java/frameworks/ and the slug can then be used to decide subfolder an file name.
eg. slug = "apache/commons-beanutils" -> apache/CommonsBeanutilsGenerated.qll.

This would solve the minor code cohesion issue that we otherwise need to remember to update both the workflow (slug, ref) pair and add an entry into lgtmSlugToModelFile.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used to do that but quickly realized that we have different locations for our models. And yes, we could try and move/rename them all into the same spot but hold back on that. I'm happy either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you thinking about models that has been auto generated and then don't follow this pattern on location or hand written models?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, mostly because of not having a good naming pattern (apache/commons-io -> apache/IO.qll vs apachecommonsio.qll vs apache/commonsio.qll). E.g. when we have multiple models from an organization, we keep them in folders whereas others, we split one framework into multiple parts (still to be discussed when it comes to the generator). Generally, I agree we can extract the root path though

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright. Thank you for the context. If this is undecided, then just leave it as it is :-)

print("============================================================")
print("Generating models for " + lgtmSlug)
print("============================================================")
modelFile = lgtmSlugToModelFile[lgtmSlug]
Copy link
Contributor

@michaelnebel michaelnebel Feb 4, 2022

Choose a reason for hiding this comment

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

Maybe add some exception handling as we might have forgotten to update the lgtmSlugToModelFile, when adding entries to the strategy matrix in the workflow (if not removing the lookup)?

@bmuskalla
Copy link
Contributor Author

@michaelnebel Good points overall on the lgtmSlugToModelFile - one major consideration I had (and I'm still torn) is whether we even need the python script at all. We could simplify the whole PR by moving everything into the action. The only downside would be that we loose the ability to locally regenerate those (but that case is already a lot harder than initially as I had to move the database building into the action. Thinking about it right now, I feel like moving this into the action makes the most sense. Locally, you can always run GenerateFlowModel.py manually and point it to the right database. Thoughts?

@michaelnebel
Copy link
Contributor

@michaelnebel Good points overall on the lgtmSlugToModelFile - one major consideration I had (and I'm still torn) is whether we even need the python script at all. We could simplify the whole PR by moving everything into the action. The only downside would be that we loose the ability to locally regenerate those (but that case is already a lot harder than initially as I had to move the database building into the action. Thinking about it right now, I feel like moving this into the action makes the most sense. Locally, you can always run GenerateFlowModel.py manually and point it to the right database. Thoughts?

Without any experience, it is hard for me to say, but my immediate response would be to keep it as a python script, just to ease potential debugging/extensions/rewriting of the script.

Copy link
Contributor

@tamasvajk tamasvajk left a comment

Choose a reason for hiding this comment

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

Looks plausible to me.

BTW, where did you test this workflow? I used to push my workflow changes first to dsp-testing to see them in action (pun intended).

Comment on lines +13 to +20
slug: ["placeholder"]
ref: ["placeholder"]
include:
- slug: "apache/commons-io"
ref: "8985de8fe74f6622a419b37a6eed0dbc484dc128"
exclude:
- slug: "placeholder"
ref: "placeholder"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need the placeholders here (, which are excluded)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to create a paramterized job without the combinatoric nature of a matrix build (and all axis are required to have at least one value)

@bmuskalla
Copy link
Contributor Author

Without any experience, it is hard for me to say, but my immediate response would be to keep it as a python script, just to ease potential debugging/extensions/rewriting of the script

Fair enough, keeping it for now

BTW, where did you test this workflow?
Used to test it on a branch. But will actually make it so it runs on a PR that changes the workflow itself

Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@bmuskalla bmuskalla merged commit eee03eb into github:main Feb 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Java no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants