-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: ability to cancel a running build from dashboard #8850
Changes from all commits
c0a951a
a3078ee
41be17d
6117504
6c97976
6307bd2
58b4db3
1e5fe87
00de85f
4eb5595
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.11 on 2022-01-26 20:10 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('builds', '0040_remove_old_jsonfields'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='build', | ||
name='task_id', | ||
field=models.CharField(blank=True, max_length=36, null=True, verbose_name='Celery task id'), | ||
), | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -229,7 +229,18 @@ def trigger_build(project, version=None, commit=None): | |
# Build was skipped | ||
return (None, None) | ||
|
||
return (update_docs_task.apply_async(), build) | ||
task = update_docs_task.apply_async() | ||
|
||
# FIXME: I'm using `isinstance` here because I wasn't able to mock this | ||
# properly when running tests and it fails when trying to save a | ||
# `mock.Mock` object in the database. | ||
# | ||
# Store the task_id in the build object to be able to cancel it later. | ||
if isinstance(task.id, (str, int)): | ||
build.task_id = task.id | ||
build.save() | ||
Comment on lines
+234
to
+241
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @stsewd do you have an idea how we can mock this? At this point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Which test is running this code? Something like maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Most of the tests from The solution that you suggested is what I've tried and I wasn't able to mock them properly 😞 I'd appreciate it if you find out the way to mock it. Otherwise, I think I will commit the code with this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All tests from that file pass for me. But some tests from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK! I'm merging it for now because I want to deploy this change today. I'll come back to this in the following days. If you have the diff required at hand, can you open a PR with the changes? |
||
|
||
return task, build | ||
|
||
|
||
def send_email( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a helper
cancel_build
that we could use from other places as well.