@@ -41,39 +41,37 @@ let process_gh_payload ~(secrets : Config_t.secrets) ~config (kind, path, state_
41
41
let ctx = Context. make () in
42
42
ctx.secrets < - Some secrets;
43
43
let (_ : State_t.repo_state ) = State. find_or_add_repo ctx.state repo.url in
44
- match state_path with
45
- | None ->
46
- Context. set_repo_config ctx repo.url config;
47
- Lwt. return ctx
48
- | Some state_path ->
49
- match Common. get_local_file state_path with
50
- | Error e ->
51
- log#error " failed to read %s: %s" state_path e;
52
- Lwt. return ctx
53
- | Ok file ->
54
- let repo_state = State_j. repo_state_of_string file in
55
- State. set_repo_state ctx.state repo.url repo_state;
56
- Context. set_repo_config ctx repo.url config;
57
- Lwt. return ctx
44
+ let () =
45
+ match state_path with
46
+ | None -> Context. set_repo_config ctx repo.url config
47
+ | Some state_path ->
48
+ match State_j. repo_state_of_string (Std. input_file state_path) with
49
+ | repo_state ->
50
+ State. set_repo_state ctx.state repo.url repo_state;
51
+ Context. set_repo_config ctx repo.url config
52
+ | exception exn -> log#error ~exn " failed to load state from file %s" state_path
53
+ in
54
+ ctx
58
55
in
59
56
Printf. printf " ===== file %s =====\n " path;
60
57
let headers = [ " x-github-event" , kind ] in
61
- match Common. get_local_file path with
62
- | Error e -> Lwt. return @@ log#error " failed to read %s: %s" path e
63
- | Ok event ->
64
- let % lwt ctx = make_test_context event in
65
- let % lwt _ctx = Action_local. process_github_notification ctx headers event in
58
+ match Std. input_file path with
59
+ | event ->
60
+ let ctx = make_test_context event in
61
+ Action_local. process_github_notification ctx headers event
62
+ | exception exn ->
63
+ log#error ~exn " failed to read file %s" path;
66
64
Lwt. return_unit
67
65
68
66
let process_slack_event ~(secrets : Config_t.secrets ) path =
69
67
let ctx = Context. make () in
70
68
ctx.secrets < - Some secrets;
71
69
State. set_bot_user_id ctx.state " bot_user" ;
72
70
Printf. printf " ===== file %s =====\n " path;
73
- match Common. get_local_file path with
74
- | Error e -> Lwt. return @@ log#error " failed to read %s: %s " path e
75
- | Ok body ->
76
- match Slack_j. event_notification_of_string body with
71
+ match Slack_j. event_notification_of_string ( Std. input_file path) with
72
+ | exception exn ->
73
+ log#error ~exn " failed to read event notification from file %s " path;
74
+ Lwt. return_unit
77
75
| Url_verification _ -> Lwt. return ()
78
76
| Event_callback notification ->
79
77
match notification.event with
0 commit comments