Skip to content

Commit

Permalink
[FIX] runbot: dont duplicate export
Browse files Browse the repository at this point in the history
Even if it isn't really problematic, avoiding to duplicate exports
will make the table slighly smaller, especially when considering running
builds.
  • Loading branch information
Xavier-Do committed Mar 16, 2022
1 parent 3985332 commit 7a91ba5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions runbot/models/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ def write(self, values):
build_by_old_values = defaultdict(lambda: self.env['runbot.build'])
for record in self:
build_by_old_values[record.local_state] += record
if values['local_state'] == 'done':
self.env['runbot.commit.export'].search([('build_id', 'in', self.ids)]).unlink()
local_result = values.get('local_result')
for build in self:
if local_result and local_result != self._get_worst_result([build.local_result, local_result]): # dont write ok on a warn/error build
Expand Down Expand Up @@ -727,10 +729,9 @@ def _schedule(self):
build.local_result = 'ok'
build._logger("No result set, setting ok by default")
build._github_status()

build._run_job()

if build.local_state == 'done':
self.env['runbot.commit.export'].search([('build_id', '=', build.id)]).unlink()

def _run_job(self):
# run job
Expand All @@ -740,6 +741,7 @@ def _run_job(self):
os.makedirs(build._path('logs'), exist_ok=True)
os.makedirs(build._path('datadir'), exist_ok=True)
try:
# cleanup export before running next step
build.active_step._run(build) # run should be on build?
except Exception as e:
if isinstance(e, RunbotException):
Expand Down
3 changes: 2 additions & 1 deletion runbot/models/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def export(self, build):
"""Export a git repo into a sources"""
# TODO add automated tests
self.ensure_one()
self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id})
if not self.env['runbot.commit.export'].search([('build_id', '=', build.id), ('commit_id', '=', self.id)]):
self.env['runbot.commit.export'].create({'commit_id': self.id, 'build_id': build.id})
export_path = self._source_path()

if os.path.isdir(export_path):
Expand Down

0 comments on commit 7a91ba5

Please sign in to comment.