Skip to content
This repository was archived by the owner on Mar 13, 2026. It is now read-only.

Commit 973c8e1

Browse files
committed
Add shell script that builds dune and makes tarball
This makes it easier to test the binary distro offline since the tarball has the same logic as the release github action (which now just runs the script). This also makes it more reliable to test the build and packaging process since the script can be run from a test setting, so this change also introduces a github action that runs such a test. Signed-off-by: Stephen Sherratt <stephen@sherra.tt>
1 parent 30090e2 commit 973c8e1

File tree

4 files changed

+92
-17
lines changed

4 files changed

+92
-17
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,8 @@ jobs:
2525
- run: echo NAME=dune-${{ github.ref_name }}-${{ matrix.name }} >> $GITHUB_ENV
2626
- uses: actions/checkout@v4
2727
- uses: cachix/install-nix-action@v31
28-
- name: Build dune
29-
run: nix build ${{ matrix.output }}
30-
- name: Create dune tarball
31-
run: |
32-
cp -rL result $NAME
33-
chmod -R u+w $NAME
34-
tar czf $NAME.tar.gz $NAME
28+
- name: Build the binary distro and package it as a tarball
29+
- run: ./make_tarball.sh $NAME ${{ matrix.output }}
3530
- uses: ncipollo/release-action@v1
3631
with:
3732
allowUpdates: true

.github/workflows/test.yml

Lines changed: 62 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,68 @@ name: test
22
on: [push, pull_request]
33
jobs:
44

5-
shellcheck:
5+
test-make-tarball:
6+
name: "Test that we can build the binary distro and package it as a tarball"
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
matrix:
10+
include:
11+
- os: macos-13
12+
name: x86_64-apple-darwin
13+
output: .#dune.dynamic
14+
- os: macos-14
15+
name: aarch64-apple-darwin
16+
output: .#dune.dynamic
17+
- os: ubuntu-latest
18+
name: x86_64-unknown-linux-musl
19+
output: .#dune.static
20+
steps:
21+
- run: echo NAME=dune-${{ matrix.name }} >> $GITHUB_ENV
22+
- uses: actions/checkout@v4
23+
- if: matrix.os == 'ubuntu-latest'
24+
name: "Install shells on ubuntu"
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get install -y zsh fish
28+
- if: matrix.os != 'ubuntu-latest'
29+
name: "Install shells on macos"
30+
run: brew install fish
31+
- uses: cachix/install-nix-action@v31
32+
- name: "Build the binary distro and package it as a tarball"
33+
run: ./make_tarball.sh $NAME ${{ matrix.output }}
34+
- name: "Extract the tarball"
35+
run: tar xf $NAME.tar.gz
36+
- name: "Test that we can env scripts and the dune executable is in the expected place"
37+
run: |
38+
bash -c '. $NAME/share/dune/env/env.bash; __dune_env $PWD/$NAME; test $(which dune) = $PWD/$NAME/bin/dune'
39+
zsh -c '. $NAME/share/dune/env/env.zsh; __dune_env $PWD/$NAME; test $(which dune) = $PWD/$NAME/bin/dune'
40+
fish -c '. $NAME/share/dune/env/env.fish; __dune_env $PWD/$NAME; test $(which dune) = $PWD/$NAME/bin/dune'
41+
sh -c '. $NAME/share/dune/env/env.sh; __dune_env $PWD/$NAME; test $(which dune) = $PWD/$NAME/bin/dune'
42+
43+
44+
test-make-tarball-shellcheck:
45+
name: "Run shellcheck on the build script"
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: "Install shellcheck"
50+
run: |
51+
sudo apt-get update
52+
sudo apt-get install -y shellcheck
53+
- name: "Run shellcheck on the build script"
54+
run: shellcheck make_tarball.sh
55+
56+
57+
test-env-script-shellcheck:
658
name: "Run shellcheck on the shell env script"
759
runs-on: ubuntu-latest
860
steps:
9-
- uses: actions/checkout@v4
10-
- name: "Install shellcheck"
11-
run: |
12-
sudo apt-get update
13-
sudo apt-get install -y shellcheck
14-
- name: "Run shellcheck on the shell env script"
15-
run: |
16-
# exclude warning for sourcing missing external file
17-
shellcheck extra/share/dune/env/env.sh extra/share/dune/env/env.bash
61+
- uses: actions/checkout@v4
62+
- name: "Install shellcheck"
63+
run: |
64+
sudo apt-get update
65+
sudo apt-get install -y shellcheck
66+
- name: "Run shellcheck on the shell env script"
67+
run: |
68+
# exclude warning for sourcing missing external file
69+
shellcheck extra/share/dune/env/env.sh extra/share/dune/env/env.bash

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
result
2+
*.tar.gz

make_tarball.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
if [ "$#" -ne "2" ]; then
5+
echo "Usage: $0 NAME TARGET"
6+
echo
7+
echo "Creates a file NAME.tar.gz containing the dune binary distro."
8+
echo "TARGET is the nix target that gets built. It should be one of:"
9+
echo " - .#dune.dynamic (builds a dynamically-linked dune executable)"
10+
echo " - .#dune.static (builds a statically-linked dune executable)"
11+
exit 1
12+
fi
13+
14+
NAME="$1"
15+
TARGET="$2"
16+
17+
set -x
18+
19+
tmp_dir="$(mktemp -d)"
20+
trap 'rm -rf "$tmp_dir"' EXIT
21+
nix build "$TARGET"
22+
cp -rL result "$tmp_dir/$NAME"
23+
chmod -R u+w "$tmp_dir/$NAME"
24+
pushd "$tmp_dir"
25+
tar czf "$NAME.tar.gz" "$NAME"
26+
popd
27+
mv "$tmp_dir/$NAME.tar.gz" .

0 commit comments

Comments
 (0)