|
| 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 |
0 commit comments