Skip to content

Commit

Permalink
Merge pull request #141 from GaloisInc/sc/telemetry-ocaml-4.14.1
Browse files Browse the repository at this point in the history
telemetry: build with OCaml 4.14.1
  • Loading branch information
samcowger authored Jan 8, 2025
2 parents 796868f + cafd2a5 commit cda048f
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 15 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/telemetry-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
build:
strategy:
matrix:
ocaml-version: [5.1.1]
ocaml-version: [4.14.1, 5.1.1]
os: [ubuntu-22.04]

runs-on: ${{ matrix.os }}
Expand All @@ -31,6 +31,9 @@ jobs:
with:
ocaml-compiler: ${{ matrix.ocaml-version }}

- name: Link lockfile
run: ln -s telemetry.opam.locked-${{ matrix.ocaml-version }} telemetry.opam.locked

- name: Install telemetry dependencies
run: opam install ./telemetry.opam --deps-only --locked -y

Expand Down
4 changes: 2 additions & 2 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@
(< 4.0.0)))
(ppx_hash
(and
(>= v0.16.3)
(>= v0.16.0)
(< v0.18)))
(ppx_sexp_conv
(and
(>= v0.16.3)
(>= v0.16.0)
(< v0.18)))
(yojson
(and
Expand Down
4 changes: 2 additions & 2 deletions telemetry.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ depends: [
"alcotest" {>= "1.6.0" & < "2.0.0"}
"base" {>= "v0.16.3" & < "v0.18"}
"ppx_deriving_yojson" {>= "3.0.0" & < "4.0.0"}
"ppx_hash" {>= "v0.16.3" & < "v0.18"}
"ppx_sexp_conv" {>= "v0.16.3" & < "v0.18"}
"ppx_hash" {>= "v0.16.0" & < "v0.18"}
"ppx_sexp_conv" {>= "v0.16.0" & < "v0.18"}
"yojson" {>= "2.0.0" & < "3.0.0"}
"odoc" {with-doc}
]
Expand Down
57 changes: 57 additions & 0 deletions telemetry.opam.locked-4.14.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
opam-version: "2.0"
name: "telemetry"
version: "0.0.1"
synopsis: "Telemetry collection"
maintainer: "Sam Cowger"
authors: "Sam Cowger"
depends: [
"alcotest" {= "1.8.0"}
"astring" {= "0.8.5"}
"base" {= "v0.16.3"}
"base-bigarray" {= "base"}
"base-threads" {= "base"}
"base-unix" {= "base"}
"cmdliner" {= "1.3.0"}
"conf-bash" {= "1"}
"cppo" {= "1.7.0"}
"csexp" {= "1.5.2"}
"dune" {= "3.16.1"}
"dune-configurator" {= "3.16.1"}
"fmt" {= "0.9.0"}
"ocaml" {= "4.14.1"}
"ocaml-base-compiler" {= "4.14.1"}
"ocaml-compiler-libs" {= "v0.12.4"}
"ocaml-config" {= "2"}
"ocaml-options-vanilla" {= "1"}
"ocaml-syntax-shims" {= "1.0.0"}
"ocamlbuild" {= "0.15.0"}
"ocamlfind" {= "1.9.6"}
"ppx_compare" {= "v0.16.0"}
"ppx_derivers" {= "1.2.1"}
"ppx_deriving" {= "6.0.3"}
"ppx_deriving_yojson" {= "3.9.0"}
"ppx_hash" {= "v0.16.0"}
"ppx_sexp_conv" {= "v0.16.0"}
"ppxlib" {= "0.33.0"}
"re" {= "1.12.0"}
"seq" {= "base"}
"sexplib0" {= "v0.16.0"}
"stdlib-shims" {= "0.3.0"}
"topkg" {= "1.0.7"}
"uutf" {= "1.0.3"}
"yojson" {= "2.2.2"}
]
build: [
["dune" "subst"] {dev}
[
"dune"
"build"
"-p"
name
"-j"
jobs
"@install"
"@runtest" {with-test}
"@doc" {with-doc}
]
]
File renamed without changes.
17 changes: 8 additions & 9 deletions telemetry/lib/disk.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,18 @@ module Session = struct

(** Attempt to decode a filename as a session. *)
let of_filename (path : string) : t option =
match
Stdlib.Scanf.sscanf_opt
try
Stdlib.Scanf.sscanf
(Stdlib.Filename.basename path)
"session-%i-%i-%i"
(fun y m d -> y, m, d)
(fun year month day -> Some (Day { year; month; day }))
with
| Some (year, month, day) -> Some (Day { year; month; day })
| None ->
(match
Stdlib.Scanf.sscanf_opt (Stdlib.Filename.basename path) "session-%Li" Fn.id
| Stdlib.Scanf.Scan_failure _ ->
(try
Stdlib.Scanf.sscanf (Stdlib.Filename.basename path) "session-%Li" (fun id ->
Some (Custom { id }))
with
| Some i -> Some (Custom { id = i })
| None -> None)
| Stdlib.Scanf.Scan_failure _ -> None)
;;
end

Expand Down
22 changes: 21 additions & 1 deletion telemetry/test/disk.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,28 @@ module Storage = Telemetry.Disk.M (SampleEvent) (SampleProfile)

let ok (r : ('ok, _) Result.t) : 'ok = Option.value_exn (Result.ok r)

(* A rough copy of [Filename.temp_dir] to allow building with OCaml versions
prior to 5.1 *)
let make_temp_dir (prefix : string) (suffix : string) : string =
let temp_dir = Filename.get_temp_dir_name () in
let temp_file_name prefix suffix =
let rnd = Stdlib.Random.bits () land 0xFFFFFF in
Filename.concat temp_dir (Printf.sprintf "%s%06x%s" prefix rnd suffix)
in
let rec try_make tries =
let name = temp_file_name prefix suffix in
let perms = 0o700 in
try
Stdlib.Sys.mkdir name perms;
name
with
| Sys_error _ as e -> if tries >= 20 then raise e else try_make (tries + 1)
in
try_make 0
;;

let storage =
let tmpdir = Filename.temp_dir "telemetry-test" "" in
let tmpdir = make_temp_dir "telemetry-test" "" in
ok Storage.(create { root_dir = tmpdir })
;;

Expand Down

0 comments on commit cda048f

Please sign in to comment.