Skip to content

Commit 924f214

Browse files
committed
chore: Try to build on gh actions
1 parent ba1bf66 commit 924f214

16 files changed

+205
-160
lines changed

.github/workflows/build.yml

+17-57
Original file line numberDiff line numberDiff line change
@@ -9,71 +9,31 @@ jobs:
99
matrix:
1010
os: [ubuntu-20.04, macos-latest]
1111
steps:
12-
- uses: actions/setup-node@v2
13-
with:
14-
node-version: '18'
15-
- uses: actions/[email protected]
16-
17-
- name: Install esy
18-
run: npm install -g esy
12+
- uses: actions/[email protected]
1913

20-
- name: Try to restore install cache
21-
uses: actions/[email protected]
14+
- uses: actions/setup-node@v4
2215
with:
23-
path: ~/.esy/source
24-
key: source-${{ hashFiles('**/index.json') }}
16+
node-version: "20"
2517

26-
- name: Install
27-
run: esy install
28-
29-
- name: Print esy cache
30-
uses: actions/[email protected]
31-
id: print_esy_cache
18+
- uses: lukka/get-cmake@latest
19+
- name: Setup anew (or from cache) vcpkg (and does not build any package)
20+
uses: lukka/run-vcpkg@v11
3221
with:
33-
script: |
34-
const path = require('path')
35-
const scriptPath = path.resolve('.github/workflows/print_esy_cache.js')
36-
require(scriptPath)(core)
22+
runVcpkgInstall: true
3723

38-
- name: Try to restore build cache
39-
id: deps-cache
40-
uses: actions/[email protected]
24+
- name: Set-up OCaml
25+
uses: ocaml/setup-ocaml@v3
4126
with:
42-
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
43-
key: build-odiff-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
44-
restore-keys: build-odiff-${{ matrix.os }}
45-
46-
# Here we use a low-level command. In real situation you don't have to
47-
# but it is useful in CI as it split the log in GitHub UI.
48-
# You can see at a glance if it is your project or your deps that break.
49-
#
50-
# We also use --release flag to build less.
51-
# This allow us to spot syntax/type error more quickly.
52-
- name: Build release dependencies
53-
54-
if: steps.deps-cache.outputs.cache-hit != 'true'
55-
run: esy build-dependencies --release
56-
57-
- name: Build project in release
58-
run: esy build --release
59-
60-
# Now that our core project build let builds others deps
61-
- name: Build dependencies
62-
if: steps.deps-cache.outputs.cache-hit != 'true'
63-
run: esy build-dependencies
64-
65-
- name: Build project
66-
run: esy build
27+
ocaml-compiler: 4.14.0
28+
dune-cache: true
6729

68-
- name: Ensure readme is up-to-date
69-
run: node scripts/process-readme.js verify
30+
- name: Set pkg-config path
31+
run: |
32+
ls "$VCPKG_ROOT/installed/$VCPKG_DEFAULT_TRIPLET/lib/pkgconfig"
33+
echo "PKG_CONFIG_PATH=$VCPKG_ROOT/installed/$VCPKG_DEFAULT_TRIPLET/lib/pkgconfig" >> $GITHUB_ENV
7034
71-
# Here we cleanup if we have a cache fail because we use restore-keys.
72-
# restore-keys take the old store even on cache fail.
73-
# So, we have deps we don't care anymore. We prune them.
74-
- name: Clean global store
75-
if: steps.deps-cache.outputs.cache-hit != 'true'
76-
run: esy cleanup .
35+
- run: opam install . --with-test
36+
- run: opam exec -- dune build
7737

7838
- name: Test
7939
run: esy test

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ _release
88
*.install
99
images/diff.png
1010
test/test-images/_*.png
11-
11+
vcpkg_installed/*
12+
_opam/

bin/ODiffBin.ml

+16-12
Original file line numberDiff line numberDiff line change
@@ -74,22 +74,26 @@ let ignoreRegions =
7474
\"x1:y1-x2:y2\". Multiple regions are separated with a ','."
7575

7676
let cmd =
77+
const Main.main $ base $ comp $ diffPath $ threshold $ diffMask $ failOnLayout
78+
$ diffColor $ parsableOutput $ antialiasing $ ignoreRegions $ diffLines
79+
$ disableGcOptimizations
80+
81+
let info =
7782
let man =
7883
[
7984
`S Manpage.s_description;
8085
`P "$(tname) is the fastest pixel-by-pixel image comparison tool.";
81-
`P "Supported image types: .png, .jpg, .jpeg, .bitmap";
86+
`P "Supported image types: .png, .jpg, .jpeg, .tiff";
8287
]
8388
in
84-
( const Main.main $ base $ comp $ diffPath $ threshold $ diffMask
85-
$ failOnLayout $ diffColor $ parsableOutput $ antialiasing $ ignoreRegions
86-
$ diffLines $ disableGcOptimizations,
87-
Term.info "odiff" ~version:"3.0.1" ~doc:"Find difference between 2 images."
88-
~exits:
89-
(Term.exit_info 0 ~doc:"on image match"
90-
:: Term.exit_info 21 ~doc:"on layout diff when --fail-on-layout"
91-
:: Term.exit_info 22 ~doc:"on image pixel difference"
92-
:: Term.default_error_exits)
93-
~man )
89+
Cmd.info "odiff" ~version:"3.0.1" ~doc:"Find difference between 2 images."
90+
~exits:
91+
[
92+
Cmd.Exit.info 0 ~doc:"on image match";
93+
Cmd.Exit.info 21 ~doc:"on layout diff when --fail-on-layout";
94+
Cmd.Exit.info 22 ~doc:"on image pixel difference";
95+
]
96+
~man
9497

95-
let () = Term.eval cmd |> Term.exit
98+
let cmd = Cmd.v info cmd
99+
let () = Cmd.eval cmd |> Stdlib.exit

bin/Print.ml

+50-50
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
open Odiff.Diff
1+
(* open Odiff.Diff *)
22

33
let printDiffResult makeParsableOutput result =
4-
(match (result, makeParsableOutput) with
5-
| Layout, true -> ""
6-
| Layout, false ->
7-
Pastel.createElement
8-
~children:
9-
[
10-
(Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ]
11-
() [@JSX]);
12-
" Images have different layout.\n";
13-
]
14-
() [@JSX]
15-
| Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 ->
16-
""
17-
| Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0
18-
->
19-
Pastel.createElement
20-
~children:
21-
[
22-
(Pastel.createElement ~color:Green ~bold:true
23-
~children:[ "Success!" ] () [@JSX]);
24-
" Images are equal.\n";
25-
(Pastel.createElement ~dim:true
26-
~children:[ "No diff output created." ]
27-
() [@JSX]);
28-
]
29-
() [@JSX]
30-
| Pixel (_output, diffCount, diffPercentage, stack), true
31-
when not (Stack.is_empty stack) ->
32-
Int.to_string diffCount ^ ";"
33-
^ Float.to_string diffPercentage
34-
^ ";"
35-
^ (stack
36-
|> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "")
37-
| Pixel (_output, diffCount, diffPercentage, _), true ->
38-
Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage
39-
| Pixel (_output, diffCount, diffPercentage, _lines), false ->
40-
Pastel.createElement
41-
~children:
42-
[
43-
(Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ]
44-
() [@JSX]);
45-
" Images are different.\n";
46-
"Different pixels: ";
47-
(Pastel.createElement ~color:Red ~bold:true
48-
~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ]
49-
() [@JSX]);
50-
]
51-
() [@JSX])
52-
|> Console.log;
4+
(* (match (result, makeParsableOutput) with *)
5+
(* | Layout, true -> "" *)
6+
(* | Layout, false -> *)
7+
(* Pastel.createElement *)
8+
(* ~children: *)
9+
(* [ *)
10+
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *)
11+
(* () [@JSX]); *)
12+
(* " Images have different layout.\n"; *)
13+
(* ] *)
14+
(* () [@JSX] *)
15+
(* | Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 -> *)
16+
(* "" *)
17+
(* | Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 *)
18+
(* -> *)
19+
(* Pastel.createElement *)
20+
(* ~children: *)
21+
(* [ *)
22+
(* (Pastel.createElement ~color:Green ~bold:true *)
23+
(* ~children:[ "Success!" ] () [@JSX]); *)
24+
(* " Images are equal.\n"; *)
25+
(* (Pastel.createElement ~dim:true *)
26+
(* ~children:[ "No diff output created." ] *)
27+
(* () [@JSX]); *)
28+
(* ] *)
29+
(* () [@JSX] *)
30+
(* | Pixel (_output, diffCount, diffPercentage, stack), true *)
31+
(* when not (Stack.is_empty stack) -> *)
32+
(* Int.to_string diffCount ^ ";" *)
33+
(* ^ Float.to_string diffPercentage *)
34+
(* ^ ";" *)
35+
(* ^ (stack *)
36+
(* |> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") *)
37+
(* | Pixel (_output, diffCount, diffPercentage, _), true -> *)
38+
(* Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage *)
39+
(* | Pixel (_output, diffCount, diffPercentage, _lines), false -> *)
40+
(* Pastel.createElement *)
41+
(* ~children: *)
42+
(* [ *)
43+
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *)
44+
(* () [@JSX]); *)
45+
(* " Images are different.\n"; *)
46+
(* "Different pixels: "; *)
47+
(* (Pastel.createElement ~color:Red ~bold:true *)
48+
(* ~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ] *)
49+
(* () [@JSX]); *)
50+
(* ] *)
51+
(* () [@JSX]) *)
52+
(* |> Console.log; *)
5353
result

bin/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
(package odiff)
55
(flags
66
(:standard -w -27))
7-
(libraries console.lib pastel.lib odiff-core odiff-io cmdliner))
7+
(libraries odiff-core odiff-io cmdliner))

dune-project

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(lang dune 2.8)
2+
(name odiff)
23

34
; Warning: The flag set for these foreign sources overrides the `:standard` set
45
; of flags. However the flags in this standard set are still added to the
@@ -18,9 +19,11 @@
1819

1920
(package
2021
(name odiff)
22+
(synopsis "CLI for comparing images pixel-by-pixel")
2123
(depends
2224
odiff-core
2325
odiff-io
26+
(cmdliner (= 1.3.0))
2427
)
2528
)
2629

@@ -29,8 +32,7 @@
2932
(synopsis "Pixel-by-pixel image difference algorithm")
3033
(depends
3134
dune
32-
(reason (and (>= 3.6.0) (< 4.0.0)))
33-
(ocaml (and (>= 4.10.0) (< 5.0.0)))
35+
(ocaml (= 4.14.0))
3436
)
3537
)
3638

@@ -39,9 +41,8 @@
3941
(synopsis "Ready to use io for odiff-core")
4042
(depends
4143
dune
42-
conf-libpng
4344
odiff-core
44-
(reason (and (>= 3.6.0) (< 4.0.0)))
45-
(ocaml (and (>= 4.10.0) (< 4.11.0)))
45+
(ocaml (= 4.14.0))
46+
(dune-configurator (>= 2.8))
4647
)
4748
)

images/out.png

2.83 MB
Loading

0 commit comments

Comments
 (0)