Run Extra Tests with only a label#2907
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #2907 +/- ##
============================================
+ Coverage 72.28% 72.46% +0.17%
============================================
Files 129 129
Lines 70540 70540
============================================
+ Hits 50993 51116 +123
+ Misses 19547 19424 -123 🚀 New features to boost your workflow:
|
a596723 to
1e8d1e1
Compare
1e8d1e1 to
286ef89
Compare
286ef89 to
e0e232f
Compare
a8b9401 to
21f45c8
Compare
21f45c8 to
b229f5a
Compare
72a6192 to
b12be95
Compare
71526c6 to
19e1fa4
Compare
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
91e998e to
82623b0
Compare
Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
82623b0 to
6b3985d
Compare
roshkhatri
left a comment
There was a problem hiding this comment.
LGTM, just added a thought/suggestion if we would like to add.
zuiderkwast
left a comment
There was a problem hiding this comment.
Let's merge this and test it on real PRs.
Change the behaviour of the CI job triggered by the run-extra-tests label. Run the tests immediately when applying the run-extra-tests label to a PR, without requiring an extra commit to be pushed to trigger the test run. When the extra tests have run, the job removes the label. --------- Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
The patch fixes the error by adding `pull‑requests: write` to the permissions block of `weekly.yml`. Github rejects if the reusable workflow's (here daily.yml) permissions are not provided. We recently changed the permissions in `daily.yml` where we gave write permissions in #2907 With this change, we bring parity to the permissions since `weekly.yml` uses calls `daily.yml` workflow call method. Fixes: https://github.com/valkey-io/valkey/actions/runs/20890545320 Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
I don't like this change. Now we have to keep re-adding the run-extra tests label. |
…table (#3092) Thanks madolson for pointing out the issue with #2907. Whenever we were using the label, it was picking up the head of the unstable instead of the PR. The reason was that we changed the target to `pull_request_target`. We had to do that since we wanted to remove the label after the run is completed. With this change, it correctly picks up the commit hash of the PR and checks it out. To test this, I merged the changes in my forked repository's [unstable](unstable...sarthakaggarwal97:valkey:unstable), created a dummy [PR](sarthakaggarwal97#61), and was able to verify that the commit of the PR is being checked out in the [action](https://github.com/sarthakaggarwal97/valkey/actions/runs/21229598167/job/61084986422?pr=61#step:3:81). Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
…table (valkey-io#3092) Thanks madolson for pointing out the issue with valkey-io#2907. Whenever we were using the label, it was picking up the head of the unstable instead of the PR. The reason was that we changed the target to `pull_request_target`. We had to do that since we wanted to remove the label after the run is completed. With this change, it correctly picks up the commit hash of the PR and checks it out. To test this, I merged the changes in my forked repository's [unstable](valkey-io/valkey@unstable...sarthakaggarwal97:valkey:unstable), created a dummy [PR](sarthakaggarwal97#61), and was able to verify that the commit of the PR is being checked out in the [action](https://github.com/sarthakaggarwal97/valkey/actions/runs/21229598167/job/61084986422?pr=61#step:3:81). Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com> Signed-off-by: arshidkv12 <arshidkv12@gmail.com>
@madolson Yeah, this is not perfect. The good thing is that we don't have to push a fake commit to make it run the first time. If the workflow doesn't delete the label, it will run again whenever we do some small change to the PR such as adding another label (release-notes, needs-doc-pr, etc.). If we can make it run only when there is a code change, and not when a label is added/removed (except the run-extra-tests label), that would be better. @sarthakaggarwal97 Do you want to experiment with this more? |
|
@zuiderkwast I can take a stab at it next week. To understand it clearly, we want to run the extra tests when
Is that correct? |
|
@sarthakaggarwal97 yes that'd be ideal |
|
If we do like this, we don't have to remove the label after running. on:
pull_request:
types: [ labeled, ... ]
jobs:
test:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'run-extra-test' }}
...Idea from https://stackoverflow.com/a/62331521 We'd also not need to use pull_request_target. We can use pull_request instead which is more practical because we can modify/test the actual job in the same PR. |
| (github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'unstable') || | ||
| (github.event_name == 'pull_request_target' && github.event.label.name == 'run-extra-tests')) && |
There was a problem hiding this comment.
| (github.event_name == 'pull_request' && github.event.pull_request.base.ref != 'unstable') || | |
| (github.event_name == 'pull_request_target' && github.event.label.name == 'run-extra-tests')) && | |
| (github.event_name == 'pull_request' && | |
| (github.event.pull_request.base.ref != 'unstable') || | |
| (github.event.action == 'labeled' && github.event.label.name == 'run-extra-tests') || | |
| (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, 'run-extra-tests'))) && |
Like this?
- The event is 'labeled' and the label is 'run-extra-tests', or
- The event is something else (e.g. push a commit) and the PR already has the label
There was a problem hiding this comment.
I think it makes sense. This could solve our problem. I will try this out soon. It's a little harder to test (few steps to test in forked repo) but I can come up with a change next week.
There was a problem hiding this comment.
It's easier to test when we don't use pull_request_target anymore. It doesn't need to be merged for testing it.
We can test it using another label name, temporarily, to prevent the pull_request_target job in unstable from picking it up.
There was a problem hiding this comment.
It's easier to test when we don't use pull_request_target anymore.
Ah that's true yes.
The patch fixes the error by adding `pull‑requests: write` to the permissions block of `weekly.yml`. Github rejects if the reusable workflow's (here daily.yml) permissions are not provided. We recently changed the permissions in `daily.yml` where we gave write permissions in valkey-io#2907 With this change, we bring parity to the permissions since `weekly.yml` uses calls `daily.yml` workflow call method. Fixes: https://github.com/valkey-io/valkey/actions/runs/20890545320 Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
…table (valkey-io#3092) Thanks madolson for pointing out the issue with valkey-io#2907. Whenever we were using the label, it was picking up the head of the unstable instead of the PR. The reason was that we changed the target to `pull_request_target`. We had to do that since we wanted to remove the label after the run is completed. With this change, it correctly picks up the commit hash of the PR and checks it out. To test this, I merged the changes in my forked repository's [unstable](valkey-io/valkey@unstable...sarthakaggarwal97:valkey:unstable), created a dummy [PR](sarthakaggarwal97#61), and was able to verify that the commit of the PR is being checked out in the [action](https://github.com/sarthakaggarwal97/valkey/actions/runs/21229598167/job/61084986422?pr=61#step:3:81). Signed-off-by: Sarthak Aggarwal <sarthagg@amazon.com>
Change the behaviour of the CI job triggered by the run-extra-tests label.
Run the tests immediately when applying the run-extra-tests label to a PR, without requiring an extra commit to be pushed to trigger the test run.
When the extra tests have run, the job removes the label.