Skip to content

Commit

Permalink
Convert to OCaml (teamwalnut#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfrolich authored Mar 25, 2022
1 parent cb02945 commit 8276452
Show file tree
Hide file tree
Showing 994 changed files with 95,369 additions and 19,390 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Hide generated files
tests_bucklescript/**/*.bs.js linguist-generated
tests_bucklescript/__snapshots__/**/* linguist-generated
snapshot_tests/**/*.bs.js linguist-generated
snapshot_tests/__snapshots__/**/* linguist-generated
graphql_schema.json linguist-generated
package-lock.json linguist-generated
pokedex_schema.json linguist-generated
Expand Down
28 changes: 17 additions & 11 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]
os: [ubuntu-latest]

container:
Expand All @@ -35,20 +35,20 @@ jobs:
id: deps-cache
with:
path: ${{ steps.print_esy_cache.outputs.esy_cache }}
key: ${{ matrix.os }}---${{ hashFiles('**/index.json') }}
key: ${{ matrix.os }}-${{ hashFiles('**/index.json') }}
restore-keys: |
${{ matrix.os }}---
${{ matrix.os }}-
- name: build
run: esy b

- name: test-native
- name: native tests
run: |
esy b dune runtest -f
env:
CI: true

- name: test-bucklescript
- name: snapshot tests
env:
GRAPHQL_CI: true
run: |
Expand All @@ -60,14 +60,14 @@ jobs:
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/default/src/bucklescript_bin/bin.exe
path: _build/default/src/bin/bin.exe

test_and_build:
name: ${{ matrix.os }}/node-${{ matrix.node-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [12.x]
node-version: [16.x]
os: [windows-latest, macOS-latest]

steps:
Expand All @@ -80,7 +80,7 @@ jobs:

- name: Install esy
run: |
npm install -g [email protected].0
npm install -g [email protected].12
- name: Install
run: esy install
Expand All @@ -105,19 +105,23 @@ jobs:
env:
CI: true

- name: test-bucklescript
- name: npm ci
if: runner.os != 'Windows'
run: |
npm ci --no-optional
esy test
env:
GRAPHQL_CI: true

- name: snaphot tests
if: runner.os != 'Windows'
run: |
esy test
- name: (only on release) Upload artifacts ${{ matrix.os }}
uses: actions/upload-artifact@master
with:
name: ${{ matrix.os }}
path: _build/default/src/bucklescript_bin/bin.exe
path: _build/default/src/bin/bin.exe

publish:
needs: [test_and_build, test_and_build_linux]
Expand Down Expand Up @@ -156,6 +160,8 @@ jobs:
run: |
mkdir -p bin
mv binaries/darwin/bin.exe bin/graphql-ppx-darwin-x64.exe
# this one is checked in the repo, because we don't have CI runners for it
mv binaries/darwin-arm64/bin.exe bin/graphql-ppx-darwin-arm64.exe
mv binaries/windows/bin.exe bin/graphql-ppx-win-x64.exe
mv binaries/linux/bin.exe bin/graphql-ppx-linux-x64.exe
Expand Down
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max-indent = 2
Binary file added binaries/darwin-arm64/bin.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion bsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"suffix": ".bs.js",
"sources": [
{
"dir": "bucklescript",
"dir": "rescript-runtime",
"subdirs": true
}
],
Expand Down
42 changes: 0 additions & 42 deletions bucklescript/GraphQL_PPX.bs.js

This file was deleted.

52 changes: 0 additions & 52 deletions bucklescript/GraphQL_PPX.re

This file was deleted.

4 changes: 4 additions & 0 deletions build_m1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
esy b
mkdir -p bin
cp _build/default/src/bin/bin.exe binaries/darwin-arm64/bin.exe
5 changes: 5 additions & 0 deletions convert_to_ml.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
echo FILE: $1
FILE=$1
NO_EXT="${FILE%.*}"
esy x refmt --parse re -p ml $FILE > $NO_EXT.mlx && rm $FILE &&mv $NO_EXT.mlx $NO_EXT.ml
5 changes: 0 additions & 5 deletions copyPlatformBinaryInPlace.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ if (platform === "win32") {
platform = "win";
}

// Workaround for darwin arm64 to use Rosetta for now
if (platform === "darwin" && arch === "arm64") {
arch = "x64";
}

copyBinary("bin/graphql-ppx-" + platform + "-" + arch + ".exe", "ppx");

function copyBinary(filename, destFilename) {
Expand Down
2 changes: 1 addition & 1 deletion dune
Original file line number Diff line number Diff line change
@@ -1 +1 @@
(dirs src tests_native tests_bucklescript)
(dirs src tests_native snapshot_tests)
7 changes: 6 additions & 1 deletion dune-workspace
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
(lang dune 1.1)

(env (release-static (flags (:standard -ccopt -static))))
(env
(release-static
(flags
(:standard -ccopt -static)))
(release
(flags (:standard))))
19 changes: 7 additions & 12 deletions esy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,23 @@
"name": "graphql_ppx",
"description": "Used for native Reason/OCaml using latest version of OCaml",
"scripts": {
"watch": "esy refmterr dune build --promote-install-files --root . --watch",
"watch": "esy dune build --promote-install-files --root . --watch",
"format": "esy dune build @fmt --auto-promote",
"release-static": "dune build --root . --only-packages '#{self.name}' --ignore-promoted-rules --no-config --profile release-static",
"test": "dune exec tests_bucklescript/tests/RunTests.exe --"
"test": "./tests.sh"
},
"dependencies": {
"@opam/dune": "*",
"@opam/ppxlib": ">=0.21.0",
"@opam/reason": ">=3.6.0",
"@opam/yojson": "*"
"@opam/ppxlib": ">=0.21.0"
},
"devDependencies": {
"@opam/ocaml-lsp-server": "*",
"@opam/dune": "*",
"@opam/ocaml-lsp-server": "1.10.1",
"@opam/merlin": "*",
"@opam/alcotest": "*",
"ocaml": "~4.12.0",
"@reason-native/rely": "jfrolich/reason-native:rely.json#08085a4048974b06aaf3aab918b677b39dea3d18",
"refmterr": "jfrolich/reason-native:refmterr.json#08085a4048974b06aaf3aab918b677b39dea3d18"
"ocaml": "4.13.1000"
},
"esy": {
"build": "dune build -p #{self.name}",
"buildDev": "refmterr dune build --promote-install-files --root .",
"buildDev": "dune build --promote-install-files --root .",
"buildsInSource": "_build"
}
}
Loading

0 comments on commit 8276452

Please sign in to comment.