Skip to content

Commit

Permalink
Add continuous testing on Windows using GitHub Actions (#8676)
Browse files Browse the repository at this point in the history
* Win CI: Cache external libraries to not rebuild them every time

* Win CI: Build an example on Windows in GitHub Actions

This is a pipeline using a Linux job that cross-compiles for Windows, followed by an actual Windows job linking and running that.

Based on https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows/30956f45a4e739204881694ee6c92f4fb0bc5395

* Win CI: Run stdlib specs

* Win CI: Enable tests also on pull requests

* Win CI: Use exact Crystal version

Co-Authored-By: Brian J. Cardiff <[email protected]>

Co-authored-by: Brian J. Cardiff <[email protected]>
  • Loading branch information
oprypin and bcardiff authored Jan 29, 2020
1 parent 4049ff7 commit 47bdbaa
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions .github/workflows/win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Windows CI

on: [push, pull_request]

jobs:
linux-job:
runs-on: ubuntu-latest
container: crystallang/crystal:0.32.1
steps:
- name: Download Crystal source
uses: actions/checkout@v2
- name: Install LLVM
run: |
apt-get -q update; apt-get -qy install llvm-8-dev
- name: Build Crystal
run: |
make
- name: Cross-compile stdlib specs
run: |
bin/crystal build --cross-compile --target x86_64-pc-windows-msvc --exclude-warnings spec/std spec/std_spec.cr
- name: Upload compiled object
uses: actions/upload-artifact@v1
with:
name: objs
path: std_spec.o

windows-job:
needs: linux-job
runs-on: windows-latest
steps:
- name: Disable CRLF line ending substitution
run: |
git config --global core.autocrlf false
- name: Download Crystal source
uses: actions/checkout@v2
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@233eac407f2676fcb3648e3b153b48e60d003803
- name: Cache libraries
id: cache-libs
uses: actions/cache@v1
with:
path: libs
key: win-libs-v1
- name: Download libgc
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: ivmai/bdwgc
ref: v7.6.4
path: bdwgc
- name: Download libatomic_ops
if: steps.cache-libs.outputs.cache-hit != 'true'
uses: actions/checkout@v2
with:
repository: ivmai/libatomic_ops
ref: v7.6.2
path: bdwgc/libatomic_ops
- name: Download win32.mak
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
iwr https://gist.github.com/ynkdir/688e62f419e5374347bf/raw/d250598ddf5129addd212b8390279a01bca12706/win32.mak -OutFile bdwgc\ntwin32.mak
- name: Build libgc
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./bdwgc
run: |
nmake -f NT_X64_STATIC_THREADS_MAKEFILE nodebug=1 _CL_=-DDONT_USE_USER32_DLL
- name: Download libpcre
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
iwr https://ftp.pcre.org/pub/pcre/pcre-8.42.zip -OutFile pcre.zip
Expand-Archive pcre.zip -DestinationPath .
mv pcre* pcre
- name: Build libpcre
if: steps.cache-libs.outputs.cache-hit != 'true'
working-directory: ./pcre
run: |
cmake . -G "Visual Studio 16 2019" -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON
cmake --build . --config release
- name: Gather libraries
if: steps.cache-libs.outputs.cache-hit != 'true'
run: |
mkdir libs
mv pcre/release/pcre.lib libs/pcre.lib
mv bdwgc/gc.lib libs/gc.lib
- name: Download compiled object
uses: actions/download-artifact@v1
with:
name: objs
- name: Link the executable
run: |
cl objs\std_spec.o /Festd_spec libs\pcre.lib libs\gc.lib advapi32.lib libcmt.lib legacy_stdio_definitions.lib
- name: Run the executable
run: |
.\std_spec.exe

0 comments on commit 47bdbaa

Please sign in to comment.