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 MSVC to CI #183

Merged
merged 4 commits into from
Sep 19, 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
2,782 changes: 2,782 additions & 0 deletions .ci/dkml-compilers/pc/setup-dkml-windows_x86.ps1

Large diffs are not rendered by default.

2,781 changes: 2,781 additions & 0 deletions .ci/dkml-compilers/pc/setup-dkml-windows_x86_64.ps1

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
*.ml linguist-language=OCaml

# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_character_encoding?view=powershell-7.1
*.ps1 text working-tree-encoding=UTF-16 eol=crlf
*.psm1 text working-tree-encoding=UTF-16 eol=crlf
# Other file types that must be CRLF
*.sln text eol=crlf
106 changes: 106 additions & 0 deletions .github/workflows/dkml.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
##########################################################################
# File: dktool/cmake/scripts/dkml/workflow/compilers-github-workflows-dkml.in.yml#
# #
# Copyright 2022 Diskuv, Inc. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
# implied. See the License for the specific language governing #
# permissions and limitations under the License. #
# #
##########################################################################

# Updating
# --------
#
# 1. Delete this file.
# 2. Run dk with your original arguments:
# ./dk dkml.workflow.compilers CI GitHub Desktop OS Windows
# or get help to come up with new arguments:
# ./dk dkml.workflow.compilers HELP

name: Build with DkML compiler

on:
# trigger on any push
push:
# ... or trigger manually from GitHub web interface
workflow_dispatch:

jobs:
build:
strategy:
matrix:
include: #
- gh_os: windows-2019
abi_pattern: win32-windows_x86
dkml_host_abi: windows_x86
- gh_os: windows-2019
abi_pattern: win32-windows_x86_64
dkml_host_abi: windows_x86_64

runs-on: ${{ matrix.gh_os }}
name: build / ${{ matrix.abi_pattern }}

# mirage-crypto does not support MSVC as of 2023-09-03. Remove
# this when MSVC is properly supported.
continue-on-error: true

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Cache DkML compilers code
uses: actions/cache@v3
id: cache-dkml-compilers
with:
path: .ci/dkml-compilers
key: ${{ runner.os }}

- name: Checkout DkML compilers code
if: steps.cache-dkml-compilers.outputs.cache-hit != 'true'
# For help: ./dk dkml.workflow.compilers HELP
run: ./dk dkml.workflow.compilers CI GitHub

# The .ci/dkml-compilers "pre" actions will create the environment variables:
# opam_root, exe_ext, dkml_host_abi, abi_pattern (and many more)
#
- name: Setup DkML compilers on a Windows host
if: startsWith(matrix.dkml_host_abi, 'windows_')
uses: ./.ci/dkml-compilers/gh-windows/pre
with:
DKML_COMPILER: ${{ env.DKML_COMPILER }}
CACHE_PREFIX: ${{ env.CACHE_PREFIX }}

# This section is for your own build logic which you should place in
# ci/build-test.sh or a similar file

- name: Build and test on Windows host
if: startsWith(matrix.dkml_host_abi, 'windows_')
shell: msys2 {0}
run: ci/build-test.sh

- name: Build and test on non-Windows host
if: "!startsWith(matrix.dkml_host_abi, 'windows_')"
run: ci/build-test.sh

# The .ci/dkml-compilers "post" actions will finalize caching, etc.

- name: Teardown DkML compilers on a Windows host
if: startsWith(matrix.dkml_host_abi, 'windows_')
uses: ./.ci/dkml-compilers/gh-windows/post

- name: Teardown DkML compilers on a Darwin host
if: startsWith(matrix.dkml_host_abi, 'darwin_')
uses: ./.ci/dkml-compilers/gh-darwin/post

- name: Teardown DkML compilers on a Linux host
if: startsWith(matrix.dkml_host_abi, 'linux_')
uses: ./.ci/dkml-compilers/gh-linux/post
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,13 @@ mirage/myocamlbuild.ml
mirage/.mirage.config
_opam
*.install

# CI using dkml-workflows' DkML compilers.
# DkML compilers populate the .opam folder.
/.opam/
# GitHub, unlike GitLab, does not need its CI files to exist
# before referencing them. That means the GitHub scripts do not need
# to be checked in.
/.ci/dkml-compilers/gh-*
# Desktop testing on Windows uses MSYS2.
/msys64/
84 changes: 84 additions & 0 deletions ci/build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/sh
##########################################################################
# File: dktool/cmake/scripts/dkml/workflow/compilers-build-test.in.sh #
# #
# Copyright 2022 Diskuv, Inc. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or #
# implied. See the License for the specific language governing #
# permissions and limitations under the License. #
# #
##########################################################################

# Updating
# --------
#
# 1. Delete this file.
# 2. Run dk with your original arguments:
# ./dk dkml.workflow.compilers CI GitHub Desktop OS Windows
# or get help to come up with new arguments:
# ./dk dkml.workflow.compilers HELP

set -euf

# Set project directory
if [ -n "${CI_PROJECT_DIR:-}" ]; then
PROJECT_DIR="$CI_PROJECT_DIR"
elif [ -n "${PC_PROJECT_DIR:-}" ]; then
PROJECT_DIR="$PC_PROJECT_DIR"
elif [ -n "${GITHUB_WORKSPACE:-}" ]; then
PROJECT_DIR="$GITHUB_WORKSPACE"
else
PROJECT_DIR="$PWD"
fi
if [ -x /usr/bin/cygpath ]; then
PROJECT_DIR=$(/usr/bin/cygpath -au "$PROJECT_DIR")
fi

# shellcheck disable=SC2154
echo "
=============
build-test.sh
=============
.
---------
Arguments
---------
$*
.
------
Matrix
------
dkml_host_abi=$dkml_host_abi
abi_pattern=$abi_pattern
opam_root=$opam_root
exe_ext=${exe_ext:-}
.
"

# PATH. Add opamrun
export PATH="$PROJECT_DIR/.ci/sd4/opamrun:$PATH"

# Initial Diagnostics (optional but useful)
opamrun switch
opamrun list
opamrun var
opamrun config report
opamrun option
opamrun exec -- ocamlc -config

# Update
opamrun update

# Make your own build logic!
opamrun install --yes --deps-only -t mirage-crypto mirage-crypto-rng mirage-crypto-rng-lwt mirage-crypto-rng-mirage mirage-crypto-pk mirage-crypto-ec
opamrun exec -- dune build -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec
opamrun exec -- dune runtest -p mirage-crypto,mirage-crypto-rng,mirage-crypto-rng-lwt,mirage-crypto-rng-mirage,mirage-crypto-pk,mirage-crypto-ec
Loading