Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflows to test OCaml trunk on Cygwin #305

Merged
merged 7 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/opam/ocaml-variants.opam.unix
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
opam-version: "2.0"
name: "ocaml-variants"
synopsis: "Custom compiler __OCAML_COMPILER_FULL_VERSION__"
maintainer: "platform@lists.ocaml.org"
authors: [
Expand Down
6 changes: 4 additions & 2 deletions .github/opam/ocaml-variants.opam.windows
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
opam-version: "2.0"
name: "ocaml-variants"
synopsis: "Custom compiler __OCAML_COMPILER_FULL_VERSION__"
license: "LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception"
maintainer: "platform@lists.ocaml.org"
Expand All @@ -15,7 +14,8 @@ depends: [
"base-domains" {post}
"base-nnp" {post}
"ocaml-option-bytecode-only" {arch != "arm64" & arch != "x86_64"}
("flexdll" {os = "win32"} | "flexdll-bin" {os = "win32"} & "flexlink" {post})
"conf-flexdll" {os = "cygwin"}
("flexdll" {os = "win32"} | "flexdll-bin" {os = "win32"} & "flexlink" {os = "win32" & post})
]
conflict-class: "ocaml-core-compiler"
flags: compiler
Expand Down Expand Up @@ -53,6 +53,8 @@ build: [
# Windows ports
"--build=x86_64-pc-cygwin" {os = "win32" & arch = "x86_64"}
"--build=i686-pc-cygwin" {os = "win32" & arch = "i686"}
# Fix on Cygwin
"--enable-imprecise-c99-float-ops" {os = "cygwin"}

"--host=i686-w64-mingw32" {ocaml-option-mingw:installed & ocaml-option-32bit:installed}
"--host=x86_64-w64-mingw32" {ocaml-option-mingw:installed & !ocaml-option-32bit:installed}
Expand Down
117 changes: 113 additions & 4 deletions .github/workflows/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ on:
description: 'Type of machine + OS on which to run the tests'
type: string
default: 'ubuntu-latest'
cygwin:
description: >
Whether Cygwin should be used on Windows (empty if not), and
how ('waiter' will sleep 1 hour if the cache is not
initialized when it starts, 'initializer' will assume it has
the role of creating that cache)
type: string
default: ''
timeout:
description: 'Timeout'
type: number
Expand Down Expand Up @@ -39,6 +47,10 @@ on:
description: 'When repeating a test, stop as soon as one test fails'
type: boolean
default: false
subsuite:
description: 'Directories which should be taken as part of the test suite'
type: string
default: 'src'
compiler:
description: 'Compiler to use'
type: string
Expand Down Expand Up @@ -87,6 +99,7 @@ jobs:
SEED: ${{ inputs.seed }}
REPEATS: ${{ inputs.repeats }}
REPEATS_FAILFAST: ${{ inputs.repeats_failfast }}
SUBSUITE: ${{ inputs.subsuite }}
COMPILER: ${{ inputs.compiler }}
OCAML_COMPILER_GIT_REF: ${{ inputs.compiler_git_ref }}
CUSTOM_COMPILER_VERSION: ${{ inputs.custom_compiler_version }}
Expand All @@ -105,6 +118,19 @@ jobs:
timeout-minutes: ${{ inputs.timeout }}

steps:
- name: Configure environment (Cygwin)
run: |
# Ensure that .expected files are not modified by check out
# as, in Cygwin, the .expected should use LF line endings,
# rather than Windows’ CRLF
git config --global core.autocrlf input

# Set up OPAM environment variables for the particular
# Cygwin case
echo OPAMYES=1 >> $env:GITHUB_ENV
echo OPAMROOT=/cygdrive/d/opam >> $env:GITHUB_ENV
if: "runner.os == 'Windows' && inputs.cygwin != ''"

- name: Checkout code
uses: actions/checkout@v2

Expand Down Expand Up @@ -170,6 +196,9 @@ jobs:
echo "PATH=$GITHUB_WORKSPACE/.github/bin:$PATH" >> $GITHUB_ENV
fi

# Save pristine PATH for cache action (Cygwin messes it up)
echo "cache_path=$PATH" >> "$GITHUB_OUTPUT"

- name: Install OCaml compiler ${{ env.COMPILER }} (Linux / macOS)
uses: ocaml/setup-ocaml@v2
with:
Expand All @@ -195,7 +224,72 @@ jobs:
upstream: https://github.com/ocaml/opam-repository.git
opam-depext: false
cache-prefix: ${{ steps.presetup.outputs.cache_prefix }}
if: runner.os == 'Windows'
if: "runner.os == 'Windows' && inputs.cygwin == ''"

- name: Restore Cygwin packages (Cygwin)
uses: actions/cache/restore@v3
id: cache_cygwin
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
C:\cygwin-packages
key: cygwin-packages-opam-2.0.7-1
if: "runner.os == 'Windows' && inputs.cygwin != ''"

- name: Install Cygwin (in particular OPAM) (Cygwin)
uses: cygwin/cygwin-install-action@v3
with:
packages: opam
install-dir: 'D:\cygwin'
if: "runner.os == 'Windows' && inputs.cygwin != ''"

- name: Save Cygwin packages (Cygwin)
uses: actions/cache/save@v3
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
C:\cygwin-packages
key: cygwin-packages-opam-2.0.7-1
if: "runner.os == 'Windows' && inputs.cygwin == 'initializer' && steps.cache_cygwin.outputs.cache-hit != 'true'"

- name: Restore OPAM state (Cygwin)
uses: actions/cache/restore@v3
id: cache_opam
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
D:\opam
key: ${{ steps.presetup.outputs.cache_prefix }}-cygwin-opam-${{ env.COMPILER }}
if: "runner.os == 'Windows' && inputs.cygwin != ''"

- name: Wait for the cache (Cygwin)
run: sleep 3600
if: "runner.os == 'Windows' && inputs.cygwin == 'waiter' && steps.cache_opam.outputs.cache-hit != 'true'"

- name: Retry restoring OPAM packages (Cygwin)
uses: actions/cache/restore@v3
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
D:\opam
key: ${{ steps.presetup.outputs.cache_prefix }}-cygwin-opam-${{ env.COMPILER }}
fail-on-cache-miss: true
if: "runner.os == 'Windows' && inputs.cygwin == 'waiter' && steps.cache_opam.outputs.cache-hit != 'true'"

- name: Install OCaml compiler ${{ env.COMPILER }} (Cygwin)
run: |
opam init --disable-sandboxing --auto-setup --bare
opam repository add --all main "https://github.com/ocaml/opam-repository.git"
opam repository add --all windows "https://github.com/fdopen/opam-repository-mingw.git#opam2"
opam repository add --all override "https://github.com/shym/custom-opam-repository.git"
opam repository add --all dra27 "https://github.com/dra27/opam-repository.git#windows-5.0"
opam repository add --all local "./.github/opam/custom/"
opam switch create default --repositories=dra27,override,windows,main --packages "${env:COMPILER}"
if: "runner.os == 'Windows' && inputs.cygwin == 'initializer' && steps.cache_opam.outputs.cache-hit != 'true'"

- name: Set up macOS environment ($OPAMJOBS)
if: runner.os == 'macOS'
Expand All @@ -205,6 +299,7 @@ jobs:
- name: Install Multicore Tests dependencies
run: |
opam install . --deps-only --with-test
opam clean --all-switches --unused-repositories --logs --download-cache --repo-cache

- name: Show configuration
run: |
Expand All @@ -213,6 +308,16 @@ jobs:
opam exec -- dune printenv
opam list --columns=name,installed-version,repository,synopsis-or-target

- name: Save OPAM state (Cygwin)
uses: actions/cache/save@v3
env:
PATH: ${{ steps.presetup.outputs.cache_path }}
with:
path: |
D:\opam
key: ${{ steps.presetup.outputs.cache_prefix }}-cygwin-opam-${{ env.COMPILER }}
if: "runner.os == 'Windows' && inputs.cygwin == 'initializer'"

- name: Build the test suite
run: opam exec -- dune build
if: env.ONLY_TEST == ''
Expand All @@ -221,9 +326,13 @@ jobs:
run: opam exec -- dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice test/
if: env.ONLY_TEST == ''

- name: Run the multicore test suite
run: opam exec -- dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice src/
if: env.ONLY_TEST == ''
- name: Run the multicore test suite (Linux / macOS)
run: opam exec -- dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice $SUBSUITE
if: "runner.os != 'Windows' && env.ONLY_TEST == ''"

- name: Run the multicore test suite (Windows / Cygwin)
run: opam exec -- dune runtest -j1 --no-buffer --display=quiet --cache=disabled --error-reporting=twice @(-Split $Env:SUBSUITE)
if: "runner.os == 'Windows' && env.ONLY_TEST == ''"

- name: Run only one test (Linux / macOS)
run: |
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/cygwin1-510-trunk-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Cygwin trunk (1)

on: [push, pull_request, workflow_dispatch]

jobs:
build:
uses: ./.github/workflows/common.yml
with:
runs_on: windows-latest
compiler: ocaml.5.1.0
cygwin: initializer
compiler_git_ref: refs/heads/trunk
timeout: 360
subsuite: src/array src/atomic src/bigarray src/buffer src/bytes src/domain src/dynlink src/ephemeron src/floatarray src/hashtbl src/io
14 changes: 14 additions & 0 deletions .github/workflows/cygwin2-510-trunk-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Cygwin trunk (2)

on: [push, pull_request, workflow_dispatch]

jobs:
build:
uses: ./.github/workflows/common.yml
with:
runs_on: windows-latest
compiler: ocaml.5.1.0
cygwin: waiter
compiler_git_ref: refs/heads/trunk
timeout: 360
subsuite: src/lazy src/neg_tests src/queue src/semaphore src/stack src/statistics src/sys src/thread src/threadomain src/weak
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Multicore tests
[![Windows 5.1.0+trunk](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-510-trunk-workflow.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-510-trunk-workflow.yml)
[![Windows 5.1.0+trunk-bytecode](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-510-trunk-bytecode-workflow.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/windows-510-trunk-bytecode-workflow.yml)

[![Cygwin trunk (1)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin1-510-trunk-workflow.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin1-510-trunk-workflow.yml)
[![Cygwin trunk (2)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin2-510-trunk-workflow.yml/badge.svg)](https://github.com/ocaml-multicore/multicoretests/actions/workflows/cygwin2-510-trunk-workflow.yml)

Property-based tests of (parts of) the OCaml multicore compiler and run time.

This project contains
Expand Down
2 changes: 2 additions & 0 deletions src/sys/stm_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ struct

let cleanup _ =
match Sys.os_type with
| "Cygwin"
| "Unix" -> ignore (Sys.command ("rm -r " ^ Filename.quote sandbox_root))
| "Win32" -> ignore (Sys.command ("rd /s /q " ^ Filename.quote sandbox_root))
| v -> failwith ("Sys tests not working with " ^ v)
Expand Down Expand Up @@ -285,6 +286,7 @@ struct
Permission denied: seen on Windows *)
and msg_path_not_dir =
match Sys.os_type with
| "Cygwin"
| "Unix" -> "Not a directory"
| "Win32" -> "No such file or directory"
| v -> failwith ("Sys tests not working with " ^ v)
Expand Down