-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba1bf66
commit 4005fb7
Showing
16 changed files
with
221 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,73 +7,47 @@ jobs: | |
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-20.04, macos-latest] | ||
os: [windows-latest] | ||
steps: | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: '18' | ||
- uses: actions/[email protected] | ||
|
||
- name: Install esy | ||
run: npm install -g esy | ||
- uses: actions/[email protected] | ||
|
||
- name: Try to restore install cache | ||
uses: actions/[email protected] | ||
- uses: actions/setup-node@v4 | ||
with: | ||
path: ~/.esy/source | ||
key: source-${{ hashFiles('**/index.json') }} | ||
node-version: "20" | ||
|
||
- name: Install | ||
run: esy install | ||
|
||
- name: Print esy cache | ||
uses: actions/[email protected] | ||
id: print_esy_cache | ||
- uses: lukka/get-cmake@latest | ||
- name: Setup anew (or from cache) vcpkg (and does not build any package) | ||
uses: lukka/run-vcpkg@v11 | ||
with: | ||
script: | | ||
const path = require('path') | ||
const scriptPath = path.resolve('.github/workflows/print_esy_cache.js') | ||
require(scriptPath)(core) | ||
- name: Try to restore build cache | ||
id: deps-cache | ||
uses: actions/[email protected] | ||
runVcpkgInstall: true | ||
runVcpkgFormatString: '["install", "--recurse", "--clean-after-build"]' | ||
|
||
- name: Set pkg-config path on Unix | ||
if: runner.os != 'Windows' | ||
run: | | ||
ls "${GITHUB_WORKSPACE}/vcpkg_installed/${VCPKG_DEFAULT_TRIPLET}/lib/pkgconfig" | ||
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/vcpkg_installed/${VCPKG_DEFAULT_TRIPLET}/lib/pkgconfig" >> $GITHUB_ENV | ||
- name: Set pkg-config path on Unix | ||
if: runner.os == 'Windows' | ||
shell: bash | ||
run: | | ||
echo "PKG_CONFIG_PATH=${GITHUB_WORKSPACE}\vcpkg_installed\\${VCPKG_DEFAULT_TRIPLET}\lib\pkgconfig" >> $GITHUB_ENV | ||
- shell: bash | ||
run: tree ${PKG_CONFIG_PATH} | ||
- run: pkg-config --libs --cflags libspng_static | ||
|
||
- name: Set-up OCaml | ||
uses: ocaml/setup-ocaml@v3 | ||
with: | ||
path: ${{ steps.print_esy_cache.outputs.esy_cache }} | ||
key: build-odiff-${{ matrix.os }}-${{ hashFiles('**/index.json') }} | ||
restore-keys: build-odiff-${{ matrix.os }} | ||
|
||
# Here we use a low-level command. In real situation you don't have to | ||
# but it is useful in CI as it split the log in GitHub UI. | ||
# You can see at a glance if it is your project or your deps that break. | ||
# | ||
# We also use --release flag to build less. | ||
# This allow us to spot syntax/type error more quickly. | ||
- name: Build release dependencies | ||
|
||
if: steps.deps-cache.outputs.cache-hit != 'true' | ||
run: esy build-dependencies --release | ||
|
||
- name: Build project in release | ||
run: esy build --release | ||
|
||
# Now that our core project build let builds others deps | ||
- name: Build dependencies | ||
if: steps.deps-cache.outputs.cache-hit != 'true' | ||
run: esy build-dependencies | ||
|
||
- name: Build project | ||
run: esy build | ||
ocaml-compiler: 4.14.0 | ||
dune-cache: true | ||
|
||
- name: Ensure readme is up-to-date | ||
run: node scripts/process-readme.js verify | ||
- name: Install deps & build | ||
run: opam install . --with-test | ||
|
||
# Here we cleanup if we have a cache fail because we use restore-keys. | ||
# restore-keys take the old store even on cache fail. | ||
# So, we have deps we don't care anymore. We prune them. | ||
- name: Clean global store | ||
if: steps.deps-cache.outputs.cache-hit != 'true' | ||
run: esy cleanup . | ||
- run: opam exec -- dune build | ||
|
||
- name: Test | ||
run: esy test | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ _release | |
*.install | ||
images/diff.png | ||
test/test-images/_*.png | ||
|
||
vcpkg_installed/* | ||
_opam/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
open Odiff.Diff | ||
(* open Odiff.Diff *) | ||
|
||
let printDiffResult makeParsableOutput result = | ||
(match (result, makeParsableOutput) with | ||
| Layout, true -> "" | ||
| Layout, false -> | ||
Pastel.createElement | ||
~children: | ||
[ | ||
(Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] | ||
() [@JSX]); | ||
" Images have different layout.\n"; | ||
] | ||
() [@JSX] | ||
| Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 -> | ||
"" | ||
| Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 | ||
-> | ||
Pastel.createElement | ||
~children: | ||
[ | ||
(Pastel.createElement ~color:Green ~bold:true | ||
~children:[ "Success!" ] () [@JSX]); | ||
" Images are equal.\n"; | ||
(Pastel.createElement ~dim:true | ||
~children:[ "No diff output created." ] | ||
() [@JSX]); | ||
] | ||
() [@JSX] | ||
| Pixel (_output, diffCount, diffPercentage, stack), true | ||
when not (Stack.is_empty stack) -> | ||
Int.to_string diffCount ^ ";" | ||
^ Float.to_string diffPercentage | ||
^ ";" | ||
^ (stack | ||
|> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") | ||
| Pixel (_output, diffCount, diffPercentage, _), true -> | ||
Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage | ||
| Pixel (_output, diffCount, diffPercentage, _lines), false -> | ||
Pastel.createElement | ||
~children: | ||
[ | ||
(Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] | ||
() [@JSX]); | ||
" Images are different.\n"; | ||
"Different pixels: "; | ||
(Pastel.createElement ~color:Red ~bold:true | ||
~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ] | ||
() [@JSX]); | ||
] | ||
() [@JSX]) | ||
|> Console.log; | ||
(* (match (result, makeParsableOutput) with *) | ||
(* | Layout, true -> "" *) | ||
(* | Layout, false -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) | ||
(* () [@JSX]); *) | ||
(* " Images have different layout.\n"; *) | ||
(* ] *) | ||
(* () [@JSX] *) | ||
(* | Pixel (_output, diffCount, _percentage, _lines), true when diffCount == 0 -> *) | ||
(* "" *) | ||
(* | Pixel (_output, diffCount, _percentage, _lines), false when diffCount == 0 *) | ||
(* -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Green ~bold:true *) | ||
(* ~children:[ "Success!" ] () [@JSX]); *) | ||
(* " Images are equal.\n"; *) | ||
(* (Pastel.createElement ~dim:true *) | ||
(* ~children:[ "No diff output created." ] *) | ||
(* () [@JSX]); *) | ||
(* ] *) | ||
(* () [@JSX] *) | ||
(* | Pixel (_output, diffCount, diffPercentage, stack), true *) | ||
(* when not (Stack.is_empty stack) -> *) | ||
(* Int.to_string diffCount ^ ";" *) | ||
(* ^ Float.to_string diffPercentage *) | ||
(* ^ ";" *) | ||
(* ^ (stack *) | ||
(* |> Stack.fold (fun acc line -> (line |> Int.to_string) ^ "," ^ acc) "") *) | ||
(* | Pixel (_output, diffCount, diffPercentage, _), true -> *) | ||
(* Int.to_string diffCount ^ ";" ^ Float.to_string diffPercentage *) | ||
(* | Pixel (_output, diffCount, diffPercentage, _lines), false -> *) | ||
(* Pastel.createElement *) | ||
(* ~children: *) | ||
(* [ *) | ||
(* (Pastel.createElement ~color:Red ~bold:true ~children:[ "Failure!" ] *) | ||
(* () [@JSX]); *) | ||
(* " Images are different.\n"; *) | ||
(* "Different pixels: "; *) | ||
(* (Pastel.createElement ~color:Red ~bold:true *) | ||
(* ~children:[ Printf.sprintf "%i (%f%%)" diffCount diffPercentage ] *) | ||
(* () [@JSX]); *) | ||
(* ] *) | ||
(* () [@JSX]) *) | ||
(* |> Console.log; *) | ||
result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.