From 45a40ff4783c510784a77dcecddc4d799a6be027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Re=C3=A9?= Date: Fri, 10 Jan 2025 14:06:31 +0100 Subject: [PATCH] Build linux-arm64 executable on CI --- .github/workflows/ci.yml | 96 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 89 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f8e582a..302eac6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,9 @@ jobs: os: [ubuntu-latest] ocaml-version: [4.14.1] node-version: [16.x] + container: + image: ocaml/opam:ubuntu-20.04-ocaml-4.14 + options: --user root steps: - name: Checkout repo @@ -27,6 +30,9 @@ jobs: with: node-version: ${{ matrix.node-version }} + - name: Install Yarn + run: npm install -g yarn + - name: Print Yarn cache id: print-yarn-cache run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT @@ -42,12 +48,13 @@ jobs: run: yarn install - name: Setup OCaml ${{ matrix.ocaml-version }} - uses: ocaml/setup-ocaml@v2 - with: - ocaml-compiler: ${{ matrix.ocaml-version }} + # uses: ocaml/setup-ocaml@v2 + # with: + # ocaml-compiler: ${{ matrix.ocaml-version }} + run: opam init -a --disable-sandboxing --compiler=4.14.1 - name: Install Opam deps - run: opam install . --deps-only --with-test + run: opam install . --deps-only --with-test --yes - name: Build PPX run: opam exec -- dune build @@ -182,6 +189,73 @@ jobs: name: ${{ matrix.container-os }} path: _build/default/ppx/bin/bin.exe + build_linux_arm: + name: Build on ${{ matrix.container-os }} + runs-on: ${{ matrix.host-os }} + if: startsWith(github.ref, 'refs/tags/v') + needs: + - validate + strategy: + matrix: + host-os: [ubuntu-24.04-arm] + container-os: [linux-arm] + ocaml-version: [4.14.1] + node-version: [16.x] + container: + image: ocaml/opam:ubuntu-20.04-ocaml-4.14 + options: --user root + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install Node 16.x + uses: actions/setup-node@v4 + with: + node-version: 16.x + + - name: Install Yarn + run: npm install -g yarn + + - name: Print Yarn cache + id: print-yarn-cache + run: echo "yarn-cache=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Restore Yarn cache + id: yarn-cache + uses: actions/cache@v4 + with: + path: ${{ steps.print-yarn-cache.outputs.yarn-cache }} + key: ${{ matrix.container-os }}-yarn-${{ hashFiles('yarn.lock', '*/yarn.lock') }} + + - name: Install Yarn deps + run: yarn install + + - name: Setup OCaml ${{ matrix.ocaml-version }} + run: opam init -a --disable-sandboxing --compiler=${{ matrix.ocaml-version }} + + - name: Install Opam deps + run: opam install . --deps-only --with-test + + - name: Build PPX + run: opam exec -- dune build --profile static + + - name: Build ReScript lib + run: | + cd lib + yarn run build + + - name: Build ReScript examples + run: | + cd examples + yarn run build + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.container-os }} + path: _build/default/ppx/bin/bin.exe + build_windows: name: Build on ${{ matrix.os }} runs-on: ${{ matrix.os }} @@ -263,6 +337,7 @@ jobs: needs: - build_macos - build_linux + - build_linux_arm - build_windows name: Release runs-on: ubuntu-latest @@ -290,11 +365,17 @@ jobs: name: macos-14 path: _bin/darwin/arm - - name: Download Linux artifacts + - name: Download Linux x86 artifacts uses: actions/download-artifact@v4 with: name: linux-alpine-3 - path: _bin/linux + path: _bin/linux/intel + + - name: Download Linux ARM artifacts + uses: actions/download-artifact@v4 + with: + name: linux-arm + path: _bin/linux/arm - name: Download Windows artifacts uses: actions/download-artifact@v4 @@ -307,7 +388,8 @@ jobs: mkdir -p _release/bin mv _bin/darwin/intel/bin.exe _release/bin/rescript-logger-ppx-darwin-x64.exe mv _bin/darwin/arm/bin.exe _release/bin/rescript-logger-ppx-darwin-arm64.exe - mv _bin/linux/bin.exe _release/bin/rescript-logger-ppx-linux-x64.exe + mv _bin/linux/intel/bin.exe _release/bin/rescript-logger-ppx-linux-x64.exe + mv _bin/linux/arm/bin.exe _release/bin/rescript-logger-ppx-linux-arm64.exe mv _bin/windows/bin.exe _release/bin/rescript-logger-ppx-win-x64.exe rm -rf _bin