From 572c3302e5856e3363839c096c52bbcc0b56efcc Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Tue, 13 Sep 2022 14:37:12 -0400 Subject: [PATCH 1/3] Add partial Windows CI --- .github/workflows/main.yaml | 56 +++++++++++++++++++++++++++++++++++-- stan/build_all.ps1 | 5 +--- 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bb9859a8..163acb8d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -16,17 +16,19 @@ jobs: runs-on: ${{matrix.os}} strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [windows-latest, ubuntu-latest, macos-latest] python-version: [3.9] env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - name: Check out github uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Install cmdstanpy for cmdstan install run: | pip install cmdstanpy @@ -39,7 +41,7 @@ jobs: - name: Install CmdStan run: | - python -m cmdstanpy.install_cmdstan --version "${{ env.CMDSTAN_VERSION }}" --cores 2 + python -m cmdstanpy.install_cmdstan --version "${{ env.CMDSTAN_VERSION }}" --cores 2 --verbose # we use the cache here to build the Stan models once for multiple interfaces - name: Set up test model cache @@ -105,7 +107,6 @@ jobs: cd python/ pytest -v - test_julia_client: needs: [build_test_models] runs-on: ${{matrix.os}} @@ -175,3 +176,52 @@ jobs: cd R/tests/ gcc -fpic -shared -o test_collisions.so test_collisions.c Rscript test_bridgestan.R + + # Seperate for now, weird dynamic linking issues need resolving in GHA runner + test_clients_windows: + needs: [build_test_models] + runs-on: windows-latest + steps: + - name: Check out github + uses: actions/checkout@v2 + + - name: Restore CmdStan + uses: actions/cache@v2 + with: + path: ~/.cmdstan + key: ${{ runner.os }}-cmdstan-${{ env.CMDSTAN_VERSION }} + + - name: Setup TBB + run: | + cd ~/.cmdstan/cmdstan-${{ env.CMDSTAN_VERSION }} + Add-Content $env:GITHUB_PATH "$(pwd)/stan/lib/stan_math/lib/tbb" + + - name: Restore built models + uses: actions/cache@v2 + id: test-models + with: + path: ./stan/ + key: ${{ hashFiles('**/*.stan', 'src/*') }}-windows-latest-cmdstan-${{ env.CMDSTAN_VERSION }}-v${{ env.CACHE_VERSION }} + + - name: Install R + uses: r-lib/actions/setup-r@v2 + + - name: Install R dependencies + uses: r-lib/actions/setup-r-dependencies@v2 + with: + packages: | + any::R6 + any::testthat + + - name: Set up Julia + uses: julia-actions/setup-julia@v1 + + - name: Run Julia tests + run: | + julia --project=./julia -t 2 -e "using Pkg; Pkg.test()" + + - name: Run R tests + run: | + cd R/tests/ + gcc -fpic -shared -o test_collisions.dll test_collisions.c + Rscript test_bridgestan.R diff --git a/stan/build_all.ps1 b/stan/build_all.ps1 index 3eef38d0..7f87f53b 100644 --- a/stan/build_all.ps1 +++ b/stan/build_all.ps1 @@ -4,8 +4,5 @@ $models = "throw_tp", "throw_gq", "throw_lp", "throw_data", "jacobian", "ma $cmdstanfixed = $env:CMDSTAN.replace('\', '/') foreach ($model in $models) { - mingw32-make.exe CMDSTAN="$($cmdstanfixed)/" -j4 O=0 "stan/$($model)/$($model)_model.so" + mingw32-make.exe CMDSTAN="$($cmdstanfixed)/" STAN_THREADS="True" -j4 O=0 "stan/$($model)/$($model)_model.so" } - -cd "$($env:BRIDGESTAN)/R/test" -gcc.exe -fpic -shared -o test_collisions.dll test_collisions.c From f92a975b9f4406c559f1c3b1fca60f09687f4294 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Tue, 13 Sep 2022 14:39:50 -0400 Subject: [PATCH 2/3] No space in filename --- R/bridgestan.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bridgestan.R b/R/bridgestan.R index efa8a952..1f411c2d 100755 --- a/R/bridgestan.R +++ b/R/bridgestan.R @@ -4,7 +4,7 @@ StanModel <- R6::R6Class("StanModel", initialize = function(lib, data, rng_seed, chain_id) { if (.Platform$OS.type == "windows"){ lib_old <- lib - lib <- paste(tools::file_path_sans_ext(lib), ".dll") + lib <- paste0(tools::file_path_sans_ext(lib), ".dll") file.copy(from=lib_old, to=lib) } From 74f26608f5a7db4d5be7c75c8f7b12fabbda37c4 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Tue, 13 Sep 2022 14:57:27 -0400 Subject: [PATCH 3/3] Add --compiler flag --- .github/workflows/main.yaml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 163acb8d..417785a4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -39,10 +39,16 @@ jobs: path: ~/.cmdstan key: ${{ runner.os }}-cmdstan-${{ env.CMDSTAN_VERSION }} - - name: Install CmdStan + - name: Install CmdStan (Unix) + if: matrix.os != 'windows-latest' run: | python -m cmdstanpy.install_cmdstan --version "${{ env.CMDSTAN_VERSION }}" --cores 2 --verbose + - name: Install CmdStan (Windows) + if: matrix.os == 'windows-latest' + run: | + python -m cmdstanpy.install_cmdstan --version "${{ env.CMDSTAN_VERSION }}" --cores 2 --verbose --compiler + # we use the cache here to build the Stan models once for multiple interfaces - name: Set up test model cache uses: actions/cache@v2