CI: Run inference tests only conditionally#147
CI: Run inference tests only conditionally#147BenjaminBossan wants to merge 15 commits intoskops-dev:mainfrom
Conversation
As discussed, only run the slow inference API tests on main or when the PR title contains the word "inference". As always, these things are hard to test.
For better differentiation from normal pytest.
Maybe we should change that...
|
To test the changes, I first created a PR containing the word "inference" and indeed all tests ran: After that, I renamed the title to use "infe-rence" instead. Rerunning the CI didn't change anything (presumably the checks are not performed), so I had to push an empty commit. After that, indeed the inference tests were skipped: This shows that we can now indeed skip the inference tests conditional on the PR title. I chose the PR title instead of commit message because the latter is harder to change after being pushed. What I cannot test for obvious reasons is if the inference tests run indeed on the main branch, for this we would have to merge this PR. Ready for review @skops-dev/maintainers |
|
I would go with commit message rather than PR title. For some commits we might want to test and for some we might skip. If we forget the tag in a commit, we can add an empty commit with the tag. But generally, I think this alternate solution might be better:
We can even pin those repos to make sure they're always up and running for tests to run quite fast. WDYT? |
Honestly, I don't think this comes up very often? And you can still change the PR title for that specific commit? This seems to be more flexible to me.
Not sure if I understand 100%. Those repos would presumably be created based on the main branch? If so, if there is a skops change in the PR that breaks stuff already at the repo creation stage (say, a change in the metainfo), the CI wouldn't catch that on the PR. Or do I misunderstand? Regardless of that, for the time being, we could still go with this PR and then remove the inference GH action once we have added said script.
I didn't know about that possibility. |
|
Ok, so what about this:
This would also fix our codecov issue. I prefer commit message tags since they are more of a norm than PR title triggers, and I think it's more intuitive to have CI triggers on commits and their messages rather than on commits + whatever's on the PR title. At least in sklearn we have quite a few of those CI triggers. |
|
Okay, then let's proceed like this. What is the "right" way to get the commit message? I found |
|
in sklearn we don't do these in gh actions, instead we do them in shell, and there we use I'm impartial to whether doing it through GH action stuff or in shell. |
- Check commit message instead of PR title - Have one job to run inference tests only for one matrix set - Have one job to run inference tests for full matrix if commit message contains "inference"
| @@ -0,0 +1,48 @@ | |||
| # Tests hitting the inference API are slow and prone to hanging, resulting in | |||
| # timeouts. Therefore, we only run inference tests on the full test matrix if | |||
| # the head commit message contains the word "inference". See #118 | |||
There was a problem hiding this comment.
maybe something like [CI inference] instead?
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| conditional-inference-pytest: |
There was a problem hiding this comment.
maybe inference-pytest-full and inference-pytest-partial for the other one?
| - pull_request | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
There was a problem hiding this comment.
we can also disable this when [CI inference] is in the commit message, since the other job does this as well.
- skip partial test if full test runs - wording: use "full" and "partial" instead of "conditional" and "unconditional"
|
@adrinjalali So it seems not to work correctly. First try, Second try, after an empty commit containing "[CI inference]", |
|
Your two new workflows have the same name @BenjaminBossan , I wouldn't be surprised if that's the root of the issue. Maybe try two different names? |
Good catch, I tried to have different names everywhere but missed the top level name :/ Unfortunately, this still doesn't work. First, without the name match, everything looks as expected: But with the name match, For reference, I used the logic described here to check the commit message (but also confirmed in other sources). |
| inference-pytest-partial: | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
| if: "(github.repository == 'skops-dev/skops') && (!contains(github.event.head_commit.message, '[CI inference]'))" |
There was a problem hiding this comment.
shouldn't this be
| if: "(github.repository == 'skops-dev/skops') && (!contains(github.event.head_commit.message, '[CI inference]'))" | |
| if: ${{ (github.repository == 'skops-dev/skops') && (!contains(github.event.head_commit.message, '[CI inference]')) }} |
There was a problem hiding this comment.
I'll try that, fingers crossed. If this is really the correct syntax, does this line work correctly:
skops/.github/workflows/build-test.yml
Line 15 in 95a718a
?
|
@adrinjalali Still the same issue, "full" never runs and "partial" always runs. So nothing changed, which is not too surprising, as
|
|
At this point I'd suggest creating a new repo on GH and testing things there maybe? Just in case other things are interacting in a weird way with one another. |
I did a bunch of testing. I could make "full" run by not matching on However, I could not figure out how not to make partial run. For reference, here is the original conditional expression:
Things I tried:
None of these helped, it was always triggered. The only way to skip it was to do I found a blog post that uses an expression with |
|
I tried in a new repo, and things seem to work as expected: https://github.com/adrinjalali/gh-action-test/tree/main The last two commits show how it'd work. Also, could this be of some help? |
I invited you to my repo. It still doesn't work there, even though I copy-pasted your expression (with just the repo name changed): BenjaminBossan/mops#2 The whole setup is a bit closer than your example to what we have in skops, but those differences should theoretically not affect this expression. |
|
Maybe merge the two workflows under the same one, just two different jobs? Also, you could start with a minimal setup like the one I have in that repo, and see at what point things break maybe? |
I copied your exact workflow (only changed repo name) and still the exact same issue: (latest 2 commits). Any global repo settings that you changed? Otherwise, I'm ready to throw in the towel. |
|
No, just created a repo, and created a workflow in it, nothing special. This is really odd! |
|
Okay, so where do we go from here? To recap, none of the suggested methods seem to work for getting the commit message for "pull_request" triggers. |
|
potential related solution: adrinjalali/gh-action-test#1 |
Only if the commit message contains "[CI inference]" will those tests be run. Second attempt after skops-dev#147 failed, look there for more context.
|
Fixed in #212 |






As discussed here, only run the slow inference API tests on main or when the PR title contains the word "inference".
Addresses (though not really solves) #118.
As always, these things are hard to test.