Skip to content

[WIP] Add cmake build scheme #5029

[WIP] Add cmake build scheme

[WIP] Add cmake build scheme #5029

Workflow file for this run

# Note that the workflows below use Powershell (pwsh) as they were originally written for Windows runners.
name: Rtools & ARM64 CI
on:
pull_request:
branches: [ develop, master ]
push:
branches: [ develop ]
paths-ignore:
- 'doxygen/**'
- 'hooks/**'
- 'licenses/**'
- 'LICENSE.md'
- 'README.md'
- 'RELEASE-NOTES.txt'
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
prim-rev:
name: ${{ matrix.config.label }} tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-11-arm, windows-latest, ubuntu-24.04-arm]
config: [
# { label: misc, tests: 'test/unit/*_test.cpp test/unit/math/*_test.cpp' },
# { label: tu, tests: 'unit_tu_all_tests' },
{ label: test_framework, tests: 'unit_math_ad_testing_all_tests' },
{ label: memory, tests: 'unit_math_memory_all_tests' },
{ label: prim, tests: 'unit_math_prim_all_tests' },
{ label: rev, tests: 'unit_math_rev_all_tests' },
{ label: fwd, tests: 'unit_math_fwd_all_tests' },
{ label: 'mix core', tests: 'unit_math_mix_core_all_tests' },
{ label: 'mix meta', tests: 'unit_math_mix_meta_all_tests' },
{ label: 'mix eigen', tests: 'unit_math_mix_eigen_all_tests' }
]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Download and Install Rtools45
if: runner.os == 'Windows'
run: |
$ARCH = if ('${{ matrix.os }}' -eq 'windows-11-arm') { 'aarch64' } else { 'x86_64' }
$RTOOLS = if ('${{ matrix.os }}' -eq 'windows-11-arm') { "rtools45-$ARCH" } else { 'rtools45' }
# Installation will hang if the toolchain is already installed
if (-Not $(Test-Path -Path "C:/$RTOOLS")) {
Invoke-WebRequest `
-Uri https://github.com/r-hub/rtools45/releases/download/latest/$RTOOLS.exe `
-OutFile "$RTOOLS.exe"
Start-Process -FilePath "$RTOOLS.exe" -ArgumentList "/INSTALL /VERYSILENT /SUPPRESSMSGBOXES" -Wait
}
echo "C:/$RTOOLS/usr/bin;C:/$RTOOLS/$ARCH-w64-mingw32.static.posix/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
# TODO: This needs to be the same across builds or it will break too often
echo "$(pwd)/build/gnu_14.2_cxx17_64_release" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
echo "$(pwd)/build/clang_19.1_cxx17_64_release" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Build Math libs
shell: pwsh
run: |
Add-Content make\local "CPPFLAGS=-w -Wno-psabi -Wno-misleading-indentation`n"
Add-Content make\local "STAN_THREADS=true`n"
make -f make/standalone math-libs -j2
- name: Run ${{ matrix.config.label }} unit tests
shell: pwsh
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=RELEASE;
cd build && make -j4 ${{ matrix.config.tests }} && ctest -R ${{ matrix.config.tests }} --output-on-failure --output-junit test-results-${{ matrix.config.label }}.xml
# python runTests.py -j4
- name: Upload gtest_output xml
uses: actions/upload-artifact@v4
if: failure()
with:
name: gtest_outputs_xml
path: '**/*_test.xml'
mix-fun:
name: mix fun and prob tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-11-arm, windows-latest, ubuntu-24.04-arm]
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: '3.x'
- name: Download and Install Rtools45
if: runner.os == 'Windows'
run: |
$ARCH = if ('${{ matrix.os }}' -eq 'windows-11-arm') { 'aarch64' } else { 'x86_64' }
$RTOOLS = if ('${{ matrix.os }}' -eq 'windows-11-arm') { "rtools45-$ARCH" } else { 'rtools45' }
# Installation will hang if the toolchain is already installed
if (-Not $(Test-Path -Path "C:/$RTOOLS")) {
Invoke-WebRequest `
-Uri https://github.com/r-hub/rtools45/releases/download/latest/$RTOOLS.exe `
-OutFile "$RTOOLS.exe"
Start-Process -FilePath "$RTOOLS.exe" -ArgumentList "/INSTALL /VERYSILENT /SUPPRESSMSGBOXES" -Wait
}
echo "C:/$RTOOLS/usr/bin;C:/$RTOOLS/$ARCH-w64-mingw32.static.posix/bin" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
echo "$(pwd)/build/gnu_14.2_cxx17_64_release" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Build Math libs
shell: pwsh
run: |
Add-Content make\local "CPPFLAGS=-w -Wno-psabi -Wno-misleading-indentation`n"
Add-Content make\local "STAN_THREADS=true`n"
make -f make/standalone math-libs -j2
- name: Run mix/fun unit tests
shell: pwsh
run: |
cmake -S . -B build -DCMAKE_BUILD_TYPE=RELEASE -DSTAN_THREADS=ON;
cd build && make -j4 unit_math_mix_fun_all_tests unit_math_mix_prob_all_tests && ctest -R unit_math_mix --output-on-failure --output-junit test-results-${{ matrix.config.label }}.xml
# python runTests.py -j2 $MixFunProbTestsArray[(${{ matrix.group }} - 1)]
- name: Upload gtest_output xml
uses: actions/upload-artifact@v4
if: failure()
with:
name: gtest_outputs_xml
path: '**/*_test.xml'