Skip to content
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

chore: update to ocaml 5 #31

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,27 @@ jobs:
- windows-latest
- macOS-latest
ocaml-compiler:
- 4.14.x
- 5.0.x
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use OCaml ${{ matrix.ocaml-compiler }}
- if: ${{ matrix.os != 'windows-latest' }}
name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}

- if: ${{ matrix.os == 'windows-latest' }}
name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: ocaml.5.0.0,ocaml-option-mingw
opam-repositories: |
dra27: https://github.com/dra27/opam-repository.git#windows-5.0
default: https://github.com/fdopen/opam-repository-mingw.git#opam2

- name: Install dependencies
run: opam install . --locked --deps-only --with-test --yes

Expand Down
10 changes: 5 additions & 5 deletions bin/Main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ let default_cmd =
(fun () ->
OSnap.run t
|> Lwt_result.map_error (fun e ->
let () = OSnap.teardown t in
e))
let () = OSnap.teardown t in
e))
(function
| exn ->
let () = OSnap.teardown t in
Lwt_result.fail (`OSnap_Unknown_Error exn))
| exn ->
let () = OSnap.teardown t in
Lwt_result.fail (`OSnap_Unknown_Error exn))
in
Lwt_main.run run |> handle_response
in
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN ./configure --prefix=/usr --libdir=/lib --static && \
make install pkgconfigdir="/usr/lib/pkgconfig"


FROM ocaml/opam:alpine-ocaml-4.14-flambda
FROM ocaml/opam:alpine-ocaml-5.0-flambda

RUN sudo apk add --no-cache --update \
bash make cmake curl perl-utils git patch gcc g++ \
Expand Down
12 changes: 6 additions & 6 deletions docker/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM debian:bullseye

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=108.0.5359.94-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=108.0.5359.94-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=108.0.5359.94-1~deb11u1 && \
mkdir -p ~/osnap_chromium_1056772/chrome-linux && \
mv /usr/lib/chromium/* ~/osnap_chromium_1056772/chrome-linux && \
mv ~/osnap_chromium_1056772/chrome-linux/chromium ~/osnap_chromium_1056772/chrome-linux/chrome && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=117.0.5938.62-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=117.0.5938.62-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=117.0.5938.62-1~deb11u1 && \
mkdir -p ~/osnap_chromium_1180118/chrome-linux && \
mv /usr/lib/chromium/* ~/osnap_chromium_1180118/chrome-linux && \
mv ~/osnap_chromium_1180118/chrome-linux/chromium ~/osnap_chromium_1180118/chrome-linux/chrome && \
rm -f /usr/bin/chromium

COPY _release /usr/local
Expand Down
12 changes: 6 additions & 6 deletions docker/Dockerfile.node-lts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:lts-bullseye

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=108.0.5359.94-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=108.0.5359.94-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=108.0.5359.94-1~deb11u1 && \
mkdir -p ~/osnap_chromium_1056772/chrome-linux && \
mv /usr/lib/chromium/* ~/osnap_chromium_1056772/chrome-linux && \
mv ~/osnap_chromium_1056772/chrome-linux/chromium ~/osnap_chromium_1056772/chrome-linux/chrome && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-sandbox=117.0.5938.62-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium-common=117.0.5938.62-1~deb11u1 && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq chromium=117.0.5938.62-1~deb11u1 && \
mkdir -p ~/osnap_chromium_1180118/chrome-linux && \
mv /usr/lib/chromium/* ~/osnap_chromium_1180118/chrome-linux && \
mv ~/osnap_chromium_1180118/chrome-linux/chromium ~/osnap_chromium_1180118/chrome-linux/chrome && \
rm -f /usr/bin/chromium

COPY _release /usr/local
Expand Down
100 changes: 49 additions & 51 deletions lib/OSnap.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,37 +25,35 @@ let setup ~noCreate ~noOnly ~noSkip ~parallelism ~config_path =
let*? only_tests, tests =
all_tests
|> Lwt_list.map_p_until_exception (fun test ->
test.sizes
|> Lwt_list.map_p_until_exception (fun size ->
let { name = _size_name; width; height } = size in
let filename = Test.get_filename test.name width height in
let current_image_path = snapshot_dir ^ filename in
let exists = Sys.file_exists current_image_path in
if noCreate && not exists
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf
"Flag --no-create is set. Cannot create new images for %s."
test.name))
else if noSkip && test.skip
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf
"Flag --no-skip is set. Cannot skip test %s."
test.name))
else if noOnly && test.only
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf
"Flag --no-only is set but the following test still has only set \
to true %s."
test.name))
else if test.only
then Lwt_result.return (Either.left (test, size, exists))
else Lwt_result.return (Either.right (test, size, exists))))
test.sizes
|> Lwt_list.map_p_until_exception (fun size ->
let { name = _size_name; width; height } = size in
let filename = Test.get_filename test.name width height in
let current_image_path = snapshot_dir ^ filename in
let exists = Sys.file_exists current_image_path in
if noCreate && not exists
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf
"Flag --no-create is set. Cannot create new images for %s."
test.name))
else if noSkip && test.skip
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf "Flag --no-skip is set. Cannot skip test %s." test.name))
else if noOnly && test.only
then
Lwt_result.fail
(`OSnap_Invalid_Run
(Printf.sprintf
"Flag --no-only is set but the following test still has only set to \
true %s."
test.name))
else if test.only
then Lwt_result.return (Either.left (test, size, exists))
else Lwt_result.return (Either.right (test, size, exists))))
|> Lwt_result.map List.flatten
|> Lwt_result.map (List.partition_map Fun.id)
in
Expand All @@ -67,7 +65,7 @@ let setup ~noCreate ~noOnly ~noSkip ~parallelism ~config_path =
let tests_to_run =
tests_to_run
|> List.fast_sort (fun (_test, _size, exists1) (_test, _size, exists2) ->
Bool.compare exists1 exists2)
Bool.compare exists1 exists2)
in
let*? browser = Browser.Launcher.make () in
Lwt_result.return { config; tests_to_run; start_time; browser }
Expand All @@ -88,25 +86,25 @@ let run t =
let*? test_results =
tests_to_run
|> Lwt_list.map_p_until_exception (fun test ->
Lwt_pool.use pool (fun target ->
let test, { name = size_name; width; height }, exists = test in
let test =
Test.Types.
{ exists
; size_name
; width
; height
; skip = test.OSnap_Config.Types.skip
; url = test.OSnap_Config.Types.url
; name = test.OSnap_Config.Types.name
; actions = test.OSnap_Config.Types.actions
; ignore_regions = test.OSnap_Config.Types.ignore
; threshold = test.OSnap_Config.Types.threshold
; warnings = []
; result = None
}
in
Test.run config (Result.get_ok target) test))
Lwt_pool.use pool (fun target ->
let test, { name = size_name; width; height }, exists = test in
let test =
Test.Types.
{ exists
; size_name
; width
; height
; skip = test.OSnap_Config.Types.skip
; url = test.OSnap_Config.Types.url
; name = test.OSnap_Config.Types.name
; actions = test.OSnap_Config.Types.actions
; ignore_regions = test.OSnap_Config.Types.ignore
; threshold = test.OSnap_Config.Types.threshold
; warnings = []
; result = None
}
in
Test.run config (Result.get_ok target) test))
in
let end_time = Unix.gettimeofday () in
let seconds = end_time -. start_time in
Expand Down
58 changes: 29 additions & 29 deletions lib/OSnap.mli
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@ val setup
-> parallelism:int option
-> config_path:string
-> ( t
, [> `OSnap_Chromium_Download_Failed
| `OSnap_CDP_Connection_Failed
| `OSnap_CDP_Protocol_Error of string
| `OSnap_Config_Duplicate_Size_Names of string list
| `OSnap_Config_Duplicate_Tests of string list
| `OSnap_Config_Global_Invalid of string
| `OSnap_Config_Global_Not_Found
| `OSnap_Config_Undefined_Function of string * string
| `OSnap_Config_Invalid of string * string
| `OSnap_Config_Parse_Error of string * string
| `OSnap_Config_Unsupported_Format of string
| `OSnap_Invalid_Run of string
] )
Lwt_result.t
, [> `OSnap_Chromium_Download_Failed
| `OSnap_CDP_Connection_Failed
| `OSnap_CDP_Protocol_Error of string
| `OSnap_Config_Duplicate_Size_Names of string list
| `OSnap_Config_Duplicate_Tests of string list
| `OSnap_Config_Global_Invalid of string
| `OSnap_Config_Global_Not_Found
| `OSnap_Config_Undefined_Function of string * string
| `OSnap_Config_Invalid of string * string
| `OSnap_Config_Parse_Error of string * string
| `OSnap_Config_Unsupported_Format of string
| `OSnap_Invalid_Run of string
] )
Lwt_result.t

val teardown : t -> unit

val run
: t
-> ( unit
, [> `OSnap_CDP_Protocol_Error of string
| `OSnap_FS_Error of string
| `OSnap_Test_Failure
] )
Lwt_result.t
, [> `OSnap_CDP_Protocol_Error of string
| `OSnap_FS_Error of string
| `OSnap_Test_Failure
] )
Lwt_result.t

val cleanup
: config_path:string
-> ( unit
, [> `OSnap_Config_Duplicate_Size_Names of string list
| `OSnap_Config_Duplicate_Tests of string list
| `OSnap_Config_Global_Invalid of string
| `OSnap_Config_Global_Not_Found
| `OSnap_Config_Invalid of string * string
| `OSnap_Config_Parse_Error of string * string
| `OSnap_Config_Undefined_Function of string * string
| `OSnap_Config_Unsupported_Format of string
] )
Lwt_result.t
, [> `OSnap_Config_Duplicate_Size_Names of string list
| `OSnap_Config_Duplicate_Tests of string list
| `OSnap_Config_Global_Invalid of string
| `OSnap_Config_Global_Not_Found
| `OSnap_Config_Invalid of string * string
| `OSnap_Config_Parse_Error of string * string
| `OSnap_Config_Undefined_Function of string * string
| `OSnap_Config_Unsupported_Format of string
] )
Lwt_result.t
Loading
Loading