From 09255277cb23fb67a86dd6ece5811d126fdaa61d Mon Sep 17 00:00:00 2001 From: Tim McGilchrist Date: Sat, 27 Mar 2021 11:43:21 +1100 Subject: [PATCH] Add changelog entry for AWS Lambda. --- CHANGES.md | 13 ++-- libraries/lambda/lib_test/aws_lambda_test.ml | 62 +++++++++++++------- libraries/lambda/lib_test/test_async.ml | 13 ++-- libraries/lambda/lib_test/test_lwt.ml | 13 ++-- 4 files changed, 55 insertions(+), 46 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4898873dc..b8141595c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,13 +1,12 @@ -Unreleased +1.2.1 ---------- + - Add KMS support (#118 @zbaylin) - Drop dependency on ocaml-migrate-parsetree and use ocaml-compiler-libs (#126 @Nymphium) - -1.2.1 ----------- -- Increase lower bound on OCaml to 4.08. https://github.com/inhabitedtype/ocaml-aws/pull/104 -- Migrate CI to github actions https://github.com/inhabitedtype/ocaml-aws/pull/104 -- Add STS `assume_role` token support https://github.com/inhabitedtype/ocaml-aws/pull/117 +- Increase lower bound on OCaml to 4.08. (#104 @tmcgilchrist) +- Migrate CI to github actions (#104 @tmcgilchrist) +- Add STS `assume_role` token support (#117 @zbaylin @UnrealAkama @bleepbloopsify) +- Initial AWS Lambda support (#108 @tmcgilchrist) 1.2: (24-01-2020) ---------- diff --git a/libraries/lambda/lib_test/aws_lambda_test.ml b/libraries/lambda/lib_test/aws_lambda_test.ml index dde635cd4..1ce5dbe93 100644 --- a/libraries/lambda/lib_test/aws_lambda_test.ml +++ b/libraries/lambda/lib_test/aws_lambda_test.ml @@ -1,14 +1,26 @@ -open OUnit +open OUnit2 open Aws_lambda +type config = + { access_key : string + ; secret_key : string + ; region : string + } + +let ( @? ) = assert_bool + module type Runtime = sig type 'a m val run_request : - (module Aws.Call - with type input = 'input - and type output = 'output - and type error = 'error) + region:string + -> access_key:string + -> secret_key:string + -> ?token:string + -> (module Aws.Call + with type input = 'input + and type output = 'output + and type error = 'error) -> 'input -> [ `Ok of 'output | `Error of 'error Aws.Error.t ] m @@ -17,23 +29,31 @@ end module TestSuite = functor - (Runtime : Runtime) + (Runtime : Runtime) -> struct - let test_cases = [] + let noop_test config _ = + "Noop lambda test succeeds" + @?false - let rec was_successful = function - | [] -> true - | RSuccess _ :: t | RSkip _ :: t -> was_successful t - | RFailure _ :: _ | RError _ :: _ | RTodo _ :: _ -> false + let suite config = + "Test Lambda" >::: [ "Lambda noop" >:: noop_test config ] - let _ = - let suite = "Tests" >::: test_cases in - let verbose = ref false in - let set_verbose _ = verbose := true in - Arg.parse - [ "-verbose", Arg.Unit set_verbose, "Run the test in verbose mode." ] - (fun x -> raise (Arg.Bad ("Bad argument : " ^ x))) - ("Usage: " ^ Sys.argv.(0) ^ " [-verbose]"); - if not (was_successful (run_test_tt ~verbose:!verbose suite)) then exit 1 - end + let () = + let access_key = + try Some (Unix.getenv "AWS_ACCESS_KEY_ID") with Not_found -> None + in + let secret_key = + try Some (Unix.getenv "AWS_SECRET_ACCESS_KEY") with Not_found -> None + in + let region = try Some (Unix.getenv "AWS_DEFAULT_REGION") with Not_found -> None in + + match access_key, secret_key, region with + | Some access_key, Some secret_key, Some region -> + run_test_tt_main (suite { access_key; secret_key; region }) + | _, _, _ -> + Printf.eprintf + "Skipping running tests. Environment variables AWS_ACCESS_KEY_ID, \ + AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION not available. "; + exit 0 +end \ No newline at end of file diff --git a/libraries/lambda/lib_test/test_async.ml b/libraries/lambda/lib_test/test_async.ml index e8d43bedd..30eab0534 100644 --- a/libraries/lambda/lib_test/test_async.ml +++ b/libraries/lambda/lib_test/test_async.ml @@ -1,12 +1,7 @@ open Aws_lambda_test module T = TestSuite(struct - type 'a m = 'a Async.Deferred.t - - let access_key = Unix.getenv "AWS_ACCESS_KEY" - let secret_key = Unix.getenv "AWS_SECRET_KEY" - let region = Unix.getenv "AWS_DEFAULT_REGION" - - let run_request x = Aws_async.Runtime.run_request ~region ~access_key ~secret_key x - let un_m v = Async.Thread_safe.block_on_async_exn (fun () -> v) - end) + type 'a m = 'a Async.Deferred.t + let run_request = Aws_async.Runtime.run_request + let un_m v = Async.Thread_safe.block_on_async_exn (fun () -> v) + end) \ No newline at end of file diff --git a/libraries/lambda/lib_test/test_lwt.ml b/libraries/lambda/lib_test/test_lwt.ml index b751191d6..1d7b99dfa 100644 --- a/libraries/lambda/lib_test/test_lwt.ml +++ b/libraries/lambda/lib_test/test_lwt.ml @@ -1,12 +1,7 @@ open Aws_lambda_test module T = TestSuite(struct - type 'a m = 'a Lwt.t - - let access_key = Unix.getenv "AWS_ACCESS_KEY" - let secret_key = Unix.getenv "AWS_SECRET_KEY" - let region = Unix.getenv "AWS_DEFAULT_REGION" - - let run_request x = Aws_lwt.Runtime.run_request ~region ~access_key ~secret_key x - let un_m = Lwt_main.run - end) + type 'a m = 'a Lwt.t + let run_request = Aws_lwt.Runtime.run_request + let un_m = Lwt_main.run + end) \ No newline at end of file