diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bb9859a8..417785a4 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 @@ -37,9 +39,15 @@ 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 + 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 @@ -105,7 +113,6 @@ jobs: cd python/ pytest -v - test_julia_client: needs: [build_test_models] runs-on: ${{matrix.os}} @@ -175,3 +182,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/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) } 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