From e884272ef7bb1c28f7a7a7876eb5bddb1fd10a8b Mon Sep 17 00:00:00 2001 From: Samuel Hym Date: Thu, 28 Sep 2023 14:22:58 +0200 Subject: [PATCH] CI: Add native and bytecode workflows using MSVC Add a native workflow and a bytecode one using MSVC Run the bytecode-only in two parts, like Cygwin Use the current bleeding edge versions of dune and QCheck as they recently merged fixes that are relevant for these workflows Add badges for those two new workflows --- .github/workflows/msvc-bytecode.yml | 19 ++++ .github/workflows/msvc-common.yml | 144 ++++++++++++++++++++++++++++ .github/workflows/msvc-native.yml | 7 ++ README.md | 3 + 4 files changed, 173 insertions(+) create mode 100644 .github/workflows/msvc-bytecode.yml create mode 100644 .github/workflows/msvc-common.yml create mode 100644 .github/workflows/msvc-native.yml diff --git a/.github/workflows/msvc-bytecode.yml b/.github/workflows/msvc-bytecode.yml new file mode 100644 index 00000000..93d5c341 --- /dev/null +++ b/.github/workflows/msvc-bytecode.yml @@ -0,0 +1,19 @@ +name: MSVC bytecode CI workflow + +on: [push, pull_request, workflow_dispatch] + +jobs: + part1: + uses: ./.github/workflows/msvc-common.yml + with: + bytecodeonly: true + dune_alias: 'ci1' + + part2: + needs: part1 + # Run part2 even if some test failed in part1: + if: ${{ always() }} + uses: ./.github/workflows/msvc-common.yml + with: + bytecodeonly: true + dune_alias: 'ci2' diff --git a/.github/workflows/msvc-common.yml b/.github/workflows/msvc-common.yml new file mode 100644 index 00000000..d73da250 --- /dev/null +++ b/.github/workflows/msvc-common.yml @@ -0,0 +1,144 @@ +name: Common MSVC CI workflow + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +on: + workflow_call: + inputs: + bytecodeonly: + type: boolean + default: false + dune_alias: + description: 'dune alias that should be built in the main step' + type: string + default: 'runtest' + +jobs: + build: + permissions: {} + + runs-on: windows-latest + + steps: + - name: Save pristine PATH + id: pristine + run: | + echo "pristine_path=${env:Path}" >> "${env:GITHUB_OUTPUT}" + + - name: Set up MSVC + uses: ilammy/msvc-dev-cmd@v1 + + - name: Fetch OCaml + uses: actions/checkout@v4 + with: + repository: dra27/ocaml + ref: restore-msvc + path: ocaml + submodules: true + + - name: Choose a cache key + id: key + env: + BC_KEY_PART: ${{ inputs.bytecodeonly && '-bytecode' || '' }} + run: | + git -C ocaml rev-parse HEAD | Tee-Object -Variable sha + echo "cache_key=ocaml-msvc${env:BC_KEY_PART}-${sha}" | Tee-Object -FilePath "${env:GITHUB_OUTPUT}" + + - name: Restore cache + uses: actions/cache/restore@v3 + id: cache + env: + PATH: ${{ steps.pristine.outputs.pristine_path }} + with: + path: | + C:\cygwin-packages + D:\ocaml + key: ${{ steps.key.outputs.cache_key }} + + - name: Install Cygwin (Cygwin) + uses: cygwin/cygwin-install-action@v3 + with: + packages: make,bash + install-dir: 'D:\cygwin' + + - name: Build OCaml + shell: bash -e {0} + env: + NATIVE: ${{ inputs.bytecodeonly && '--disable-native-compiler' || '' }} + run: | + cd ocaml # + mkdir /cygdrive/d/ocaml # + eval $(tools/msvs-promote-path) # + ./configure --host=x86_64-pc-windows --with-flexdll --prefix=/cygdrive/d/ocaml $NATIVE # + make # + make install # + if: "steps.cache.outputs.cache-hit != 'true'" + + - name: Fetch dune + uses: actions/checkout@v4 + with: + repository: ocaml/dune + path: dune + if: "steps.cache.outputs.cache-hit != 'true'" + + - name: Compile dune + shell: bash -e {0} + run: | + export PATH="/cygdrive/d/ocaml/bin:$PATH" # + eval $(ocaml/tools/msvs-promote-path) # + export INCLUDE="$INCLUDE;$(cygpath -w "$PWD/ocaml/runtime/winpthreads/include")" # + cd dune # + make release # + make install PREFIX='D:\ocaml' # + if: "steps.cache.outputs.cache-hit != 'true'" + + - name: Display configuration and set up PATH + run: | + D:\ocaml\bin\ocamlc -config + D:\ocaml\bin\dune --version + echo "D:\ocaml\bin" >> ${env:GITHUB_PATH} + + - name: Save cache + uses: actions/cache/save@v3 + env: + PATH: ${{ steps.pristine.outputs.pristine_path }} + with: + path: | + C:\cygwin-packages + D:\ocaml + key: ${{ steps.key.outputs.cache_key }} + if: "steps.cache.outputs.cache-hit != 'true'" + + - name: Fetch multicoretests + uses: actions/checkout@v4 + with: + path: mct + + - name: Fetch QCheck + uses: actions/checkout@v4 + with: + repository: c-cube/qcheck + path: mct/qcheck + + - name: Build the test suite + shell: bash -e {0} + run: | + eval $(ocaml/tools/msvs-promote-path) # + cd mct # + dune build # + dune build test/ # + + - name: Run the internal package tests + run: | + cd mct + dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice test/ + + - name: Run the multicore test suite + env: + QCHECK_MSG_INTERVAL: 60 + DUNE_CI_ALIAS: ${{ inputs.dune_alias }} + run: | + cd mct + dune build "@ci" -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice diff --git a/.github/workflows/msvc-native.yml b/.github/workflows/msvc-native.yml new file mode 100644 index 00000000..d214871a --- /dev/null +++ b/.github/workflows/msvc-native.yml @@ -0,0 +1,7 @@ +name: MSVC native CI workflow + +on: [push, pull_request, workflow_dispatch] + +jobs: + build: + uses: ./.github/workflows/msvc-common.yml diff --git a/README.md b/README.md index 1fb95e18..2180123b 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,9 @@ Multicore tests [![Windows 5.2.0+trunk-bytecode](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-520-trunk-bytecode.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-520-trunk-bytecode.yml) [![Cygwin 5.2.0+trunk](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin-520-trunk.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin-520-trunk.yml) +[![MSVC native](https://github.com/ocaml-multicore/multicoretests/actions/workflows/msvc-native.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/msvc-native.yml) +[![MSVC bytecode](https://github.com/ocaml-multicore/multicoretests/actions/workflows/msvc-bytecode.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/msvc-bytecode.yml) + Property-based tests of (parts of) the OCaml multicore compiler and run time. This project contains