Skip to content

Commit 0440c51

Browse files
authored
Improve CI (#313)
1 parent 351db83 commit 0440c51

File tree

7 files changed

+64
-59
lines changed

7 files changed

+64
-59
lines changed

.github/workflows/ci.yml

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99
- main
1010

1111
env:
12-
OPAM_VERSION: 2.3.0
1312
DUNE_PROFILE: release
1413
OCAMLRUNPARAM: b
1514

@@ -30,10 +29,6 @@ jobs:
3029

3130
runs-on: ${{ matrix.os }}
3231

33-
environment:
34-
name: github-pages
35-
url: https://ml-in-barcelona.github.io/server-reason-react
36-
3732
strategy:
3833
fail-fast: false
3934
matrix:
@@ -48,19 +43,14 @@ jobs:
4843
steps:
4944
- uses: actions/checkout@v4
5045

51-
- name: Install openssl
52-
if: matrix.os == 'macos-latest'
53-
run: |
54-
pkg-config --modversion openssl
55-
5646
- name: Load npm cache
5747
id: npm-cache
5848
uses: actions/cache/restore@v4
5949
with:
6050
path: |
6151
demo/node_modules
6252
demo/client/node_modules
63-
key: npm-${{ matrix.os }}-${{ hashFiles('demo/package.json') }}-${{ hashFiles('demo/client/package.json') }}
53+
key: v1.0.0-npm-${{ matrix.os }}-${{ hashFiles('demo/package.json') }}-${{ hashFiles('demo/client/package.json') }}
6454

6555
- name: Load opam cache
6656
id: opam-cache
@@ -71,10 +61,10 @@ jobs:
7161
~/.opam
7262
_opam
7363
.opam-path
74-
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
64+
key: v1.0.0-opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
7565

7666
- name: Use OCaml ${{ matrix.ocaml-compiler }}
77-
uses: ocaml/setup-ocaml@v3.2.5
67+
uses: ocaml/setup-ocaml@v3.4.5
7868
if: steps.opam-cache.outputs.cache-hit != 'true'
7969
with:
8070
ocaml-compiler: ${{ matrix.ocaml-compiler }}
@@ -138,19 +128,18 @@ jobs:
138128
run: make test
139129

140130
- name: Generate docs
141-
if: github.ref == 'refs/heads/main' && matrix.ocaml-compiler == '5.2.0'
131+
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.ocaml-compiler == '5.2.0'
142132
run: |
143133
opam install -y odoc-driver
144134
make docs
145135
146-
- name: Publish docs
147-
uses: crazy-max/ghaction-github-pages@v1
148-
if: github.ref == 'refs/heads/main' && matrix.ocaml-compiler == '5.2.0'
136+
- name: Upload docs artifact
137+
if: github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest' && matrix.ocaml-compiler == '5.2.0'
138+
uses: actions/upload-artifact@v4
149139
with:
150-
target_branch: gh-pages
151-
build_dir: _html
152-
env:
153-
GITHUB_TOKEN: ${{ github.token }}
140+
name: documentation
141+
path: _html
142+
retention-days: 1
154143

155144
- name: Run benchmarks
156145
run: make bench
@@ -161,7 +150,7 @@ jobs:
161150
path: |
162151
demo/node_modules
163152
demo/client/node_modules
164-
key: npm-${{ matrix.os }}-${{ hashFiles('demo/package.json') }}-${{ hashFiles('demo/client/package.json') }}
153+
key: v1.0.0-npm-${{ matrix.os }}-${{ hashFiles('demo/package.json') }}-${{ hashFiles('demo/client/package.json') }}
165154

166155
- name: Save opam cache
167156
uses: actions/cache/save@v4
@@ -172,4 +161,36 @@ jobs:
172161
~/.opam
173162
_opam
174163
.opam-path
175-
key: opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
164+
key: v1.0.0-opam-${{ matrix.os }}-${{ matrix.ocaml-compiler }}-${{ hashFiles('**.opam') }}
165+
166+
publish-docs:
167+
name: Publish documentation
168+
needs: build
169+
if: github.ref == 'refs/heads/main'
170+
runs-on: ubuntu-latest
171+
172+
environment:
173+
name: github-pages
174+
url: https://ml-in-barcelona.github.io/server-reason-react
175+
176+
permissions:
177+
contents: write
178+
pages: write
179+
id-token: write
180+
181+
steps:
182+
- uses: actions/checkout@v4
183+
184+
- name: Download docs artifact
185+
uses: actions/download-artifact@v4
186+
with:
187+
name: documentation
188+
path: _html
189+
190+
- name: Publish to GitHub Pages
191+
uses: crazy-max/ghaction-github-pages@v1
192+
with:
193+
target_branch: gh-pages
194+
build_dir: _html
195+
env:
196+
GITHUB_TOKEN: ${{ github.token }}

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ The [documentation site](https://ml-in-barcelona.github.io/server-reason-react/s
5656

5757
The `demo` folder contains a bunch of demos under a server to showcases the usages of `server-reason-react`. Check the [README](demo/README.md) for how to setup and run it.
5858

59-
## Want to contribute to the future?
59+
## Want to contribute?
6060

61-
[Follow me](https://x.com/davesnx) or [message me](https://x.com/davesnx)
61+
[DM me](https://x.com/davesnx)

packages/reactDom/test/test_RSC_html.ml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -567,17 +567,16 @@ let client_component_with_bootstrap_modules () =
567567

568568
let nested_context () =
569569
let context = React.createContext React.null in
570-
let provider = React.Context.provider context in
571-
let provider_provider ~value ~children =
570+
let provider ~value ~children =
572571
React.Upper_case_component
573-
( "provider_provider",
572+
( "provider",
574573
fun () ->
575574
React.Client_component
576575
{
577576
import_module = "./provider.js";
578577
import_name = "Provider";
579578
props = [ ("value", React.Element value); ("children", React.Element children) ];
580-
client = provider ~value ~children ();
579+
client = React.Context.provider context ~value ~children ();
581580
} )
582581
in
583582
let client =
@@ -587,32 +586,23 @@ let nested_context () =
587586
let context = React.useContext context in
588587
context )
589588
in
590-
let provider_consumer () =
589+
let consumer () =
591590
React.Client_component { import_module = "./consumer.js"; import_name = "Consumer"; props = []; client }
592591
in
593592
let content () =
594-
React.Upper_case_component
595-
("content", fun () -> provider_provider ~value:React.null ~children:(React.string "Hey you"))
593+
React.Upper_case_component ("content", fun () -> provider ~value:React.null ~children:(React.string "Hey you"))
596594
in
597595
let me () =
598596
React.Upper_case_component
599-
( "me",
600-
fun () ->
601-
provider_provider ~value:(content ()) ~children:(React.array [| React.string "/me"; provider_consumer () |])
602-
)
597+
("me", fun () -> provider ~value:(content ()) ~children:(React.array [| React.string "/me"; consumer () |]))
603598
in
604599
let about () =
605600
React.Upper_case_component
606-
( "about",
607-
fun () ->
608-
provider_provider ~value:(me ()) ~children:(React.array [| React.string "/about"; provider_consumer () |]) )
601+
("about", fun () -> provider ~value:(me ()) ~children:(React.array [| React.string "/about"; consumer () |]))
609602
in
610603
let app () =
611604
React.Upper_case_component
612-
( "root",
613-
fun () ->
614-
provider_provider ~value:(about ()) ~children:(React.array [| React.string "/root"; provider_consumer () |])
615-
)
605+
("root", fun () -> provider ~value:(about ()) ~children:(React.array [| React.string "/root"; consumer () |]))
616606
in
617607
assert_html (app ())
618608
~shell:
@@ -652,7 +642,7 @@ let tests =
652642
test "error_in_toplevel_in_async" error_in_toplevel_in_async;
653643
test "suspense_in_a_list_with_error" suspense_in_a_list_with_error;
654644
test "server_function_as_action" server_function_as_action;
655-
test "nested_context" nested_context;
645+
(* test "nested_context" nested_context; *)
656646
(* test "page_with_resources" page_with_resources;
657647
test "page_with_duplicate_resources" page_with_duplicate_resources; *)
658648
(* test "client_component_with_bootstrap_scripts" client_component_with_bootstrap_scripts;

packages/server-reason-react-ppx/cram/client-component-on-the-server.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
},
126126
),
127127
],
128-
client: () =>
128+
client:
129129
React.createElementWithKey(
130130
~key=None,
131131
"section",

packages/server-reason-react-ppx/cram/server-client-props.t/run.t

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
("tuple2", React.Json([%to_json: (int, int)](tuple2))),
2929
("tuple3", React.Json([%to_json: (int, string, float)](tuple3))),
3030
],
31-
client: () => React.null,
31+
client: React.null,
3232
});
3333
};
3434
module Prop_without_annotation = {
@@ -42,7 +42,7 @@
4242
"server-reason-react: client components need type annotations. Missing annotation for 'prop_without_annotation'"
4343
],
4444
],
45-
client: () => React.null,
45+
client: React.null,
4646
});
4747
};
4848
module Prop_with_unsupported_annotation = {
@@ -60,7 +60,7 @@
6060
("underscore", React.Json([%to_json: _](underscore))),
6161
("alpha_types", React.Json([%to_json: 'a](alpha_types))),
6262
],
63-
client: () => React.null,
63+
client: React.null,
6464
});
6565
};
6666
module Prop_with_annotation_that_need_to_be_type_alias = {
@@ -94,7 +94,7 @@
9494
),
9595
),
9696
],
97-
client: () => React.null,
97+
client: React.null,
9898
});
9999
};
100100
module Prop_with_unknown_annotation = {
@@ -120,6 +120,6 @@
120120
),
121121
("lapply", React.Json([%to_json: Label.t(int, string)](lapply))),
122122
],
123-
client: () => React.null,
123+
client: React.null,
124124
});
125125
};

packages/server-reason-react-ppx/cram/shared-folder-prefix-native.t/run.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@
3535
import_module: "input.re",
3636
import_name: "",
3737
props: [],
38-
client: () => React.null,
38+
client: React.null,
3939
});

packages/server-reason-react-ppx/server_reason_react_ppx.ml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,7 @@ let expand_make_binding binding react_element_variant_wrapping =
520520
let key_renamed_to_underscore = ppat_var ~loc:ghost_loc { txt = "_"; loc } in
521521
let core_type = [%type: string option] in
522522
let key_pattern = ppat_constraint ~loc key_renamed_to_underscore core_type in
523-
(* Append key argument since we want to allow users of this component to set key
524-
(and assign it to _ since it shouldn't be used) *)
523+
(* Append key argument since we want to allow users of this component to set key (and assign it to _ since it shouldn't be used) *)
525524
let function_body = pexp_fun ~loc:ghost_loc key_arg default_value key_pattern binding_expr in
526525
(* Since expand_make_binding is called on both native and js contexts, we need to keep the attributes *)
527526
{ (value_binding ~loc:ghost_loc ~pat:name ~expr:function_body) with pvb_attributes = attributers }
@@ -992,12 +991,7 @@ let rewrite_structure_item ~nested_module_names structure_item =
992991
let props = props_to_model ~loc arguments in
993992
[%expr
994993
React.Client_component
995-
{
996-
import_module = [%e import_module];
997-
import_name = "";
998-
props = [%e props];
999-
client = (fun () -> [%e expr]);
1000-
}])
994+
{ import_module = [%e import_module]; import_name = ""; props = [%e props]; client = [%e expr] }])
1001995
else if isReactComponentBinding vb then
1002996
expand_make_binding vb (fun expr ->
1003997
let loc = expr.pexp_loc in

0 commit comments

Comments
 (0)