Merge pull request 'regard a successful build only these with a main_artifact present' (#168) from fix-85 into main

Reviewed-on: #168
This commit is contained in:
Reynir Björnsson 2023-09-11 11:34:38 +00:00
commit 8152bc0d14
3 changed files with 35 additions and 8 deletions

View file

@ -179,6 +179,7 @@ let () =
[ f20210910 ]; [ f20210910 ];
actions (module M20211105); actions (module M20211105);
actions (module M20220509); actions (module M20220509);
actions (module M20230911);
]) ])
|> Cmd.eval |> Cmd.eval
|> exit |> exit

View file

@ -0,0 +1,26 @@
let new_version = 17L and old_version = 16L
and identifier = "2023-09-11"
and migrate_doc = "index failed builds on main binary is null"
and rollback_doc = "index failed builds on exit code"
open Grej.Syntax
let migrate _datadir (module Db : Caqti_blocking.CONNECTION) =
let* () = Grej.check_version ~user_version:old_version (module Db) in
let* () =
Db.exec (Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) \
WHERE main_binary IS NULL")
()
in
Db.exec (Grej.set_version new_version) ()
let rollback _datadir (module Db : Caqti_blocking.CONNECTION) =
let* () = Grej.check_version ~user_version:new_version (module Db) in
let* () =
Db.exec (Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) \
WHERE result_code <> 0")
()
in
Db.exec (Grej.set_version old_version) ()

View file

@ -5,7 +5,7 @@ open Caqti_request.Infix
let application_id = 1234839235l let application_id = 1234839235l
(* Please update this when making changes! *) (* Please update this when making changes! *)
let current_version = 16L let current_version = 17L
type 'a id = 'a Rep.id type 'a id = 'a Rep.id
@ -283,7 +283,7 @@ module Build = struct
b.main_binary, b.input_id, b.user, b.job b.main_binary, b.input_id, b.user, b.job
FROM build b FROM build b
INNER JOIN job ON job.id = b.job INNER JOIN job ON job.id = b.job
WHERE b.result_code <> 0 AND ($3 IS NULL OR b.platform = $3) WHERE b.main_binary IS NULL AND ($3 IS NULL OR b.platform = $3)
ORDER BY start_d DESC, start_ps DESC ORDER BY start_d DESC, start_ps DESC
LIMIT $2 LIMIT $2
OFFSET $1 OFFSET $1
@ -304,7 +304,8 @@ module Build = struct
result_code, result_msg, console, script, result_code, result_msg, console, script,
platform, main_binary, input_id, user, job platform, main_binary, input_id, user, job
FROM build FROM build
WHERE job = $1 AND result_code <> 0 WHERE job = $1
AND main_binary IS NULL
AND ($2 IS NULL OR platform = $2) AND ($2 IS NULL OR platform = $2)
ORDER BY start_d DESC, start_ps DESC ORDER BY start_d DESC, start_ps DESC
|} |}
@ -319,7 +320,7 @@ module Build = struct
FROM build b FROM build b
LEFT JOIN build_artifact a ON LEFT JOIN build_artifact a ON
b.main_binary = a.id b.main_binary = a.id
WHERE b.job = $1 AND b.platform = $2 AND b.result_code = 0 WHERE b.job = $1 AND b.platform = $2
ORDER BY b.start_d DESC, b.start_ps DESC ORDER BY b.start_d DESC, b.start_ps DESC
LIMIT 1 LIMIT 1
|} |}
@ -331,8 +332,9 @@ module Build = struct
b.result_code, b.result_msg, b.console, b.script, b.result_code, b.result_msg, b.console, b.script,
b.platform, b.main_binary, b.input_id, b.user, b.job b.platform, b.main_binary, b.input_id, b.user, b.job
FROM build b FROM build b
WHERE b.job = $1 AND b.result_code = 0 WHERE b.job = $1
AND ($2 IS NULL OR b.platform = $2) AND ($2 IS NULL OR b.platform = $2)
AND b.main_binary IS NOT NULL
ORDER BY b.start_d DESC, b.start_ps DESC ORDER BY b.start_d DESC, b.start_ps DESC
LIMIT 1 LIMIT 1
|} |}
@ -346,7 +348,6 @@ module Build = struct
FROM build b, build b0, build_artifact a, build_artifact a0 FROM build b, build b0, build_artifact a, build_artifact a0
WHERE b0.id = ? AND b0.job = b.job AND WHERE b0.id = ? AND b0.job = b.job AND
b.platform = b0.platform AND b.platform = b0.platform AND
b.result_code = 0 AND
a.id = b.main_binary AND a0.id = b0.main_binary AND a.id = b.main_binary AND a0.id = b0.main_binary AND
a.sha256 <> a0.sha256 AND a.sha256 <> a0.sha256 AND
(b0.start_d > b.start_d OR b0.start_d = b.start_d AND b0.start_ps > b.start_ps) (b0.start_d > b.start_d OR b0.start_d = b.start_d AND b0.start_ps > b.start_ps)
@ -363,7 +364,6 @@ module Build = struct
FROM build b, build b0, build_artifact a, build_artifact a0 FROM build b, build b0, build_artifact a, build_artifact a0
WHERE b0.id = ? AND b0.job = b.job AND WHERE b0.id = ? AND b0.job = b.job AND
b.platform = b0.platform AND b.platform = b0.platform AND
b.result_code = 0 AND
a.id = b.main_binary AND a0.id = b0.main_binary AND a.id = b.main_binary AND a0.id = b0.main_binary AND
a.sha256 <> a0.sha256 AND a.sha256 <> a0.sha256 AND
(b0.start_d < b.start_d OR b0.start_d = b.start_d AND b0.start_ps < b.start_ps) (b0.start_d < b.start_d OR b0.start_d = b.start_d AND b0.start_ps < b.start_ps)
@ -585,7 +585,7 @@ let migrate = [
Caqti_type.unit ->. Caqti_type.unit @@ Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_job_start ON build(job, start_d DESC, start_ps DESC)"; "CREATE INDEX idx_build_job_start ON build(job, start_d DESC, start_ps DESC)";
Caqti_type.unit ->. Caqti_type.unit @@ Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) WHERE result_code <> 0"; "CREATE INDEX idx_build_failed ON build(job, start_d DESC, start_ps DESC) WHERE main_binary IS NULL";
Caqti_type.unit ->. Caqti_type.unit @@ Caqti_type.unit ->. Caqti_type.unit @@
"CREATE INDEX idx_build_input_id ON build(input_id)"; "CREATE INDEX idx_build_input_id ON build(input_id)";
Caqti_type.unit ->. Caqti_type.unit @@ Caqti_type.unit ->. Caqti_type.unit @@