Skip to content

Commit 7fb45ca

Browse files
authored
Merge branch 'main' into ocaml-index-dev-tool
2 parents 8b176de + 2154a32 commit 7fb45ca

File tree

9 files changed

+362
-219
lines changed

9 files changed

+362
-219
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Multi-Repo Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
repos:
7+
description: 'Space-separated list of GitHub repos (e.g., "ocaml-dune/notty ocaml/ocaml-re")'
8+
required: true
9+
type: string
10+
depext_linux:
11+
description: 'Space-separated apt packages for Linux (optional)'
12+
required: false
13+
type: string
14+
default: ''
15+
depext_macos:
16+
description: 'Space-separated brew packages for macOS (optional)'
17+
required: false
18+
type: string
19+
default: ''
20+
21+
env:
22+
EXTRA_NIX_CONFIG: |
23+
extra-substituters = https://anmonteiro.nix-cache.workers.dev
24+
extra-trusted-public-keys = ocaml.nix-cache.com-1:/xI2h2+56rwFfKyyFVbkJSeGqSIYMC/Je+7XXqGKDIY=
25+
26+
jobs:
27+
build:
28+
name: Build repos with Dune
29+
strategy:
30+
fail-fast: false
31+
matrix:
32+
os:
33+
- ubuntu-latest
34+
- macos-latest
35+
runs-on: ${{ matrix.os }}
36+
env:
37+
# TODO: Remove
38+
DUNE_CONFIG__PKG_BUILD_PROGRESS: enabled
39+
steps:
40+
- name: Checkout Dune
41+
uses: actions/checkout@v5
42+
43+
- name: Set up Nix
44+
uses: nixbuild/nix-quick-install-action@v34
45+
with:
46+
nix_conf: ${{ env.EXTRA_NIX_CONFIG }}
47+
48+
- name: Cache Nix store
49+
uses: nix-community/cache-nix-action@v6
50+
with:
51+
primary-key: nix-${{ runner.os }}-nix-build-${{ hashFiles('**/*.nix', '**/flake.lock') }}
52+
restore-prefixes-first-match: nix-${{ runner.os }}-nix-build-
53+
save: false
54+
55+
- name: Build Dune
56+
run: nix build
57+
58+
- name: Set up workspace directory
59+
run: mkdir workspace
60+
61+
- name: Clone repositories
62+
run: |
63+
cd workspace
64+
for repo in ${{ inputs.repos }}; do
65+
echo "Cloning $repo..."
66+
repo_name=$(echo $repo | sed 's/.*\///')
67+
git clone https://github.com/$repo.git $repo_name
68+
done
69+
70+
- name: Generate dune-workspace
71+
run: |
72+
cd workspace
73+
cat > dune-workspace <<EOF
74+
(lang dune 3.21)
75+
(pkg enabled)
76+
EOF
77+
78+
echo "Generated dune-workspace:"
79+
cat dune-workspace
80+
81+
- name: Install system dependencies (Linux)
82+
if: runner.os == 'Linux' && inputs.depext_linux != ''
83+
run: |
84+
sudo apt-get update
85+
sudo apt-get install -y ${{ inputs.depext_linux }}
86+
87+
- name: Install system dependencies (macOS)
88+
if: runner.os == 'macOS' && inputs.depext_macos != ''
89+
run: |
90+
brew install ${{ inputs.depext_macos }}
91+
92+
- name: Lock dependencies
93+
run: cd workspace && nix run .. -- pkg lock
94+
95+
- name: Build
96+
run: cd workspace && nix run .. -- build

bin/build.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,11 @@ let poll_handling_rpc_build_requests ~(common : Common.t) ~config =
9898
match kind with
9999
| Build targets ->
100100
Target.interpret_targets (Common.root common) config setup targets
101-
| Runtest dir_or_cram_test_paths ->
102-
Runtest_common.make_request ~dir_or_cram_test_paths ~to_cwd:root.to_cwd setup
101+
| Runtest test_paths ->
102+
Runtest_common.make_request
103+
~contexts:setup.contexts
104+
~to_cwd:root.to_cwd
105+
~test_paths
103106
in
104107
run_build_system ~common ~request, outcome)
105108
;;

bin/runtest.ml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,15 @@ let runtest_info =
3636
let runtest_term =
3737
let name = Arg.info [] ~docv:"TEST" in
3838
let+ builder = Common.Builder.term
39-
and+ dir_or_cram_test_paths = Arg.(value & pos_all string [ "." ] name) in
39+
and+ test_paths = Arg.(value & pos_all string [ "." ] name) in
4040
let common, config = Common.init builder in
4141
match Dune_util.Global_lock.lock ~timeout:None with
4242
| Ok () ->
43-
Build.run_build_command
44-
~common
45-
~config
46-
~request:
47-
(Runtest_common.make_request
48-
~dir_or_cram_test_paths
49-
~to_cwd:(Common.root common).to_cwd)
43+
Build.run_build_command ~common ~config ~request:(fun setup ->
44+
Runtest_common.make_request
45+
~contexts:setup.contexts
46+
~to_cwd:(Common.root common).to_cwd
47+
~test_paths)
5048
| Error lock_held_by ->
5149
Scheduler.go_without_rpc_server ~common ~config (fun () ->
5250
let open Fiber.O in
@@ -56,7 +54,7 @@ let runtest_term =
5654
~lock_held_by
5755
builder
5856
Dune_rpc.Procedures.Public.runtest
59-
dir_or_cram_test_paths
57+
test_paths
6058
>>| Rpc.Rpc_common.wrap_build_outcome_exn ~print_on_success:true)
6159
;;
6260

bin/runtest_common.ml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,8 @@ let disambiguate_test_name path =
7575
| None -> explain_unsuccessful_search path ~parent_dir))
7676
;;
7777

78-
let make_request ~dir_or_cram_test_paths ~to_cwd (setup : Import.Main.build_system) =
79-
let contexts = setup.contexts in
80-
List.map dir_or_cram_test_paths ~f:(fun dir ->
78+
let make_request ~contexts ~to_cwd ~test_paths =
79+
List.map test_paths ~f:(fun dir ->
8180
let dir = Path.of_string dir |> Path.Expert.try_localize_external in
8281
let open Action_builder.O in
8382
let* contexts, alias_kind =

bin/runtest_common.mli

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
open Import
22

3-
(** [make_request ~dir_or_cram_test_paths ~to_cwd] returns a function suitable
4-
for passing to [Build_cmd.run_build_system] which runs the tests referred
5-
to by the elements of [dir_or_cram_test_paths]. *)
63
val make_request
7-
: dir_or_cram_test_paths:string list
4+
: contexts:Context.t list
85
-> to_cwd:string list
9-
-> Dune_rules.Main.build_system
6+
-> test_paths:string list
107
-> unit Action_builder.t

doc/reference/dune-project/package.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ is used when generating OPAM files (see :doc:`generate_opam_files`).
108108
``(sites (<section> <name>) ...)`` defines a site named ``<name>`` in the
109109
section ``<section>``.
110110

111+
.. describe:: (allow_empty)
112+
113+
.. versionadded:: 3.0
114+
115+
Allows packages that have no user-defined stanzas attached to them.
116+
117+
By default, starting from Dune 3.0, packages must contain at least one
118+
user-defined stanza (such as a ``library``, ``executable``, or
119+
``install`` stanza). If a package is intentionally empty, add
120+
``(allow_empty)`` to suppress the error.
121+
111122
Adding libraries to different packages is done via the ``public_name`` and
112123
``package`` fields. See :doc:`../dune/library` section for details.
113124

flake.nix

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@
164164
ocaml
165165
findlib
166166
];
167-
buildInputs = lib.optionals stdenv.isDarwin [
168-
darwin.apple_sdk.frameworks.CoreServices
169-
];
170167
strictDeps = true;
171168
buildFlags = [ "release" ];
172169
dontAddPrefix = true;
@@ -327,9 +324,6 @@
327324
mkShell {
328325
inherit INSIDE_NIX;
329326
nativeBuildInputs = lib.remove pkgs.ocamlformat (testNativeBuildInputs pkgs);
330-
buildInputs = lib.optionals stdenv.isDarwin [
331-
darwin.apple_sdk.frameworks.CoreServices
332-
];
333327
meta.description = ''
334328
provides a shell with just `opam` and minimal (external)
335329
dependencies to run the testsuite.";

0 commit comments

Comments
 (0)