Skip to content

Migrate away from esy and use OCaml 5 #38

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

Merged
merged 62 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c06a353
See how far I got
davesnx Oct 8, 2023
4ee0b13
Fix ci file
davesnx Oct 8, 2023
ec9ec02
Make build pass
davesnx Oct 8, 2023
1924848
Specify compiler 5.1
davesnx Oct 8, 2023
07c9a56
Disable windows, opam things
davesnx Oct 8, 2023
76eedf6
Remove jsooreact from deps
davesnx Oct 8, 2023
44cf641
use opam 2.2
davesnx Oct 8, 2023
6268c27
Pin without invariance
davesnx Oct 8, 2023
3bdf566
Add description into dune project
davesnx Oct 8, 2023
8033484
Add runtime tests and simplify compiler
davesnx Oct 8, 2023
c5112ec
Fix I37 Int64 limit
davesnx Oct 8, 2023
32b9e91
Pin stuff
davesnx Oct 9, 2023
666b03e
Go with cram tests instead of bat
davesnx Oct 9, 2023
e540be8
Gardering
davesnx Oct 9, 2023
f922674
Remove esy.lock
davesnx Oct 9, 2023
daa2ae1
Remove e2e from CI
davesnx Oct 9, 2023
e31a309
Enable cram
davesnx Oct 9, 2023
5a20cff
Cleanup bin
davesnx Oct 9, 2023
23b30b6
Add more tests
davesnx Oct 9, 2023
3df0cd4
Fix typos on md
davesnx Oct 9, 2023
cb24a7e
Add more tests
davesnx Oct 9, 2023
bf5ef94
Pin jsoo-css
davesnx Oct 9, 2023
a4f253b
Cleanup Makefile
davesnx Oct 9, 2023
43fde02
Specify deps
davesnx Oct 9, 2023
120bc5f
Remove package from cram
davesnx Oct 9, 2023
bbd3fae
Fix bash stuff
davesnx Oct 9, 2023
ad84ca1
Let's push and see
davesnx Oct 10, 2023
397f26b
Cleanup stuff
davesnx Apr 22, 2025
455ce6e
Update CI
davesnx Apr 22, 2025
a1e9a0e
Change binary internally to query-json
davesnx Apr 22, 2025
f0bc952
Rename -web to -playground
davesnx Apr 22, 2025
e2057fa
See what happens with win
davesnx Apr 22, 2025
a65eac7
Merge branch 'main' of github.com:/davesnx/query-json into Move-to-op…
davesnx Apr 22, 2025
78c2dd3
Compilation pass
davesnx Apr 23, 2025
0eaa74b
Bundles with vite yay
davesnx Apr 23, 2025
84f26ab
Wrapped false and expose everything
davesnx Apr 23, 2025
4b47572
Expose QueryJson under window['query-json']
davesnx Apr 23, 2025
739307f
Fix ci js name
davesnx Apr 23, 2025
97817a3
Remove permisisons for ci
davesnx Apr 23, 2025
7735509
Ignore build folder
davesnx Apr 23, 2025
a693fea
Cleanup npm deps
davesnx Apr 23, 2025
dafff34
Nothing to pin
davesnx Apr 23, 2025
befe586
Delete esy scripts
davesnx Apr 23, 2025
1b24e60
Use node 20
davesnx Apr 23, 2025
ccf2747
Change npm ci -> npm install
davesnx Apr 23, 2025
d82b4a5
Specify @tailwindcss/cli
davesnx Apr 23, 2025
48af3df
dune listen to all folders, add tailwind during section bin
davesnx Apr 23, 2025
7d5a7c4
split install and build
davesnx Apr 23, 2025
5eeff47
Remove check formatting from ci
davesnx Apr 23, 2025
e77e0b2
Make prepush execccc
davesnx Apr 23, 2025
f38a839
Add ocamlformat, remove unused
davesnx Apr 23, 2025
09e44fa
Format js folder
davesnx Apr 23, 2025
60b3111
Deploy dist folder
davesnx Apr 23, 2025
fd01931
Deploy upwords
davesnx Apr 23, 2025
1f19972
Don't deploy to prod ffs
davesnx Apr 23, 2025
13adfe4
Fix binary name and conditionals on PR/main run
davesnx Apr 23, 2025
724eddb
Disable windows
davesnx Apr 23, 2025
667cba3
Bring back scripts/*
davesnx Apr 23, 2025
e62b5fc
Remove 000 version
davesnx Apr 23, 2025
964260f
Fix js/QueryJsonJs.bc.js
davesnx Apr 23, 2025
dc1a9d1
Hide windows completly
davesnx Apr 23, 2025
7a51f99
Merge pull request #40 from davesnx/melange-for-website
davesnx Apr 23, 2025
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
6 changes: 6 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

if ! ( make format-check ); then
echo "some files are not properly formatted, refusing to push"
exit 1
fi
181 changes: 63 additions & 118 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,128 +8,91 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [
ubuntu-latest,
macos-latest,
# windows-latest https://github.com/ocaml/dune/issues/11645
]
ocaml-compiler:
- 5.2.1

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js 16.x
- name: Use Node.js
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 20.x

- name: Restore global node modules cache
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/cache@v1
env:
cache-name: cache-node-modules
- name: Use OCaml ${{ matrix.ocaml-compiler }}
uses: ocaml/[email protected]
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-

- name: Install esy
run: npm install -g [email protected]

- name: Restore esy source cache
id: esy-cache
uses: actions/cache@v2
with:
path: ~/.esy/source
key: source-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
ocaml-compiler: ${{ matrix.ocaml-compiler }}
dune-cache: true
opam-disable-sandboxing: true

- name: Install
run: esy install
- name: Install deps
run: make install

- name: Print esy cache
id: print_esy_cache
run: node scripts/print-esy-cache.js
- name: Install npm deps
run: npm install

- name: Try to restore dependencies cache
id: deps-cache
uses: actions/cache@v2
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: deps-${{ matrix.os }}-${{ hashFiles('**/index.json') }}
restore-keys: deps-${{ matrix.os }}-

- name: Build dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy build-dependencies
- name: Pin some deps
run: make pin

- name: Build
run: esy build
run: make build

- name: Test
if: ${{ matrix.os != 'windows-latest' }}
run: |
rm test/__snapshots__/.gitkeep
esy dune runtest --instrument-with bisect_ppx --force
esy bisect-ppx-report send-to Coveralls
env:
BISECT_SILENT: "ERR"
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.number }}
- name: Run tests
run: make test

- name: Web build
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
esy b dune build
cd website
npm ci
npm run build-production
run: npm run build

- name: Deploy to prod
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name != 'pull_request' }}
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
working-directory: ./website
env:
SITE_ID: ${{ secrets.SITE_ID }}
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run:
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --prod --dir=build
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --prod --dir=../dist

- name: Deploy preview
if: ${{ matrix.os == 'ubuntu-latest' }}
if: ${{ matrix.os == 'ubuntu-latest' && github.event_name == 'pull_request' }}
working-directory: ./website
env:
SITE_ID: ${{ secrets.SITE_ID }}
AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
run:
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --dir=build
npx netlify deploy --site $SITE_ID --auth $AUTH_TOKEN --dir=../dist

- name: Upload artifacts for ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}-artifact
path: _build/default/bin/Bin.exe
path: _build/default/bin/bin.exe

- name: Upload JavaScript artifacts for NPM
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@master
with:
name: bundled
path: _build/default/js/Js.bc.js

# Cleanup build cache if dependencies have changed
- name: Clean build cache
if: steps.deps-cache.outputs.cache-hit != 'true'
run: esy cleanup .
name: query-json-js
path: _build/default/js/QueryJsonJs.bc.js

publish:
needs: build
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js 12.x
uses: actions/setup-node@v1
- name: Use Node.js 20.x
uses: actions/setup-node@v3
with:
node-version: 12.x
node-version: 20.x

- name: Generate NPM package and release
run: node scripts/make-npm-release.js
Expand All @@ -138,8 +101,8 @@ jobs:
if: ${{ success() }}
uses: actions/download-artifact@master
with:
name: bundled
path: _release/bundled
name: query-json-js
path: _release/query-json-js

- name: Download linux artifacts
if: ${{ success() }}
Expand All @@ -155,53 +118,35 @@ jobs:
name: macos-latest-artifact
path: _release/platform-darwin-x64

- name: Download windows artifacts
uses: actions/download-artifact@master
with:
name: windows-latest-artifact
path: _release/platform-windows-x64

- name: Publish query-json from linux artifcats
if: ${{ matrix.os == 'ubuntu-latest' }}
run: |
cp _release/platform-linux-x64/Bin.exe ./query-json
chmod +x query-json
# - name: Download windows artifacts
# uses: actions/download-artifact@master
# with:
# name: windows-latest-artifact
# path: _release/platform-windows-x64

- name: Create archives for Github release
run: |
cd _release/platform-darwin-x64
mv Bin.exe query-json
mv bin.exe query-json
zip -r ../../query-json-darwin-x64.zip .
cd ../..

cd _release/platform-linux-x64
mv Bin.exe query-json
mv bin.exe query-json
zip -r ../../query-json-linux-x64.zip .
cd ../..

cd _release/platform-windows-x64
mv Bin.exe query-json
zip -r ../../query-json-windows-x64.zip .
cd ../..

- name: End to end Test (Linux)
if: ${{ matrix.os == 'ubuntu-latest' }}
run: npx bats ./e2e/test.sh
env:
IS_CI: true

- name: End to end Test (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: sh -c 'npx bats ./e2e/test.sh' \"$(pwd)/node_modules/bats/bin/bats\"
env:
IS_CI: true
# cd _release/platform-windows-x64
# mv bin.exe query-json
# zip -r ../../query-json-windows-x64.zip .
# cd ../..

- name: Check if should be published
if: ${{ success() && github.event_name != 'pull_request' }}
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/main' }}
id: newVersion
run: |
REMOTE=$(npm view @davesnx/query-json version);
CURRENT=$(jq -r '.version' esy.json);
CURRENT=$(cat dune-project | grep -oE '\(version [0-9]+\.[0-9]+\.[0-9]+\)' | grep -o '\d\+.\d\+.\d\+');
if [ "$REMOTE" != "$CURRENT" ]
then
echo "::set-output name=shouldPublish::true";
Expand All @@ -210,7 +155,7 @@ jobs:
fi

- name: Publish
if: ${{ success() && github.event_name != 'pull_request' && steps.newVersion.outputs.shouldPublish == 'true' }}
if: ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.newVersion.outputs.shouldPublish == 'true' }}
run: |
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm config set scope "@davesnx"
Expand Down Expand Up @@ -268,13 +213,13 @@ jobs:
asset_name: query-json-linux-x64.zip
asset_content_type: application/gzip

- name: Upload query-json-windows-x64.zip to Github release
if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: query-json-windows-x64.zip
asset_name: query-json-windows-x64.zip
asset_content_type: application/gzip
# - name: Upload query-json-windows-x64.zip to Github release
# if: ${{ success() && steps.newVersion.outputs.shouldPublish == 'true' }}
# uses: actions/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: query-json-windows-x64.zip
# asset_name: query-json-windows-x64.zip
# asset_content_type: application/gzip
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,7 @@ _coverage
coverage.json

# Website artifacts
website/build
dist

# Vite build
build
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.github
.vscode
esy.lock/*
esy.lock
_opam
_build
File renamed without changes.
74 changes: 74 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
project_name = query-json

DUNE = opam exec -- dune
opam_file = $(project_name).opam

.PHONY: help
help: ## Print this help message
@echo "";
@echo "List of available make commands";
@echo "";
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}';
@echo "";

.PHONY: build
build: ## Build the project, including non installable libraries and executables
$(DUNE) build @all

.PHONY: build-prod
build-prod: ## Build for production (--profile=prod)
$(DUNE) build --profile=prod @all

.PHONY: dev
dev: ## Build in watch mode
$(DUNE) build -w @all

.PHONY: clean
clean: ## Clean artifacts
$(DUNE) clean

.PHONY: test
test: ## Run the unit tests
$(DUNE) build @runtest

.PHONY: test-watch
test-watch: ## Run the unit tests in watch mode
$(DUNE) build @runtest -w

.PHONY: test-promote
test-promote: ## Updates snapshots and promotes it to correct
$(DUNE) build @runtest --auto-promote

.PHONY: setup-githooks
setup-githooks: ## Setup githooks
git config core.hooksPath .githooks

.PHONY: deps
deps: $(opam_file) ## Alias to update the opam file and install the needed deps

.PHONY: format
format: ## Format the codebase with ocamlformat
@DUNE_CONFIG__GLOBAL_LOCK=disabled $(DUNE) build @fmt --auto-promote

.PHONY: format-check
format-check: ## Checks if format is correct
@DUNE_CONFIG__GLOBAL_LOCK=disabled $(DUNE) build @fmt

.PHONY: pin
pin: ## Pin dependencies
echo "Nothing to pin"

.PHONY: create-switch
create-switch: ## Create opam switch
opam switch create . 5.2.1 --deps-only --with-test -y

.PHONY: install
install: ## Install opam deps
opam install . --deps-only --with-test --with-doc --with-dev-setup -y

.PHONY: npm-install
npm-install: ## Install npm dependencies
npm install

.PHONY: init
init: setup-githooks create-switch pin install install-npm ## Create a local dev enviroment
Loading
Loading