Skip to content
Merged
Changes from 1 commit
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
106 changes: 106 additions & 0 deletions .github/workflows/build.yml
Copy link
Contributor

@kjohnsen kjohnsen Feb 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! The biggest question I have in my mind is what compilers are being used in the configure/build steps? One of the biggest headaches in getting the project to build right is that some compilers work and others don't for no apparent reason. Clang has worked most consistently across platforms, but not every version and not every machine we've tested...a mess. Assuming we will still have these problems, I think we will need to just choose a compiler, like Clang.

We may want to merge this now to get it working before adding more, but things we will want:

  • a static vs. dynamic option in the matrix
    • dynamic mostly to test install
    • static for goal of creating pre-compiled static binaries
  • config?
    • for static, easy-install binaries probably want both Release and RelWithDebInfo.
    • for dynamic probably just debug
  • deploying static binaries somewhere (probably GitHub releases?)

Then after getting the C++ build working:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project uses default compilers: GCC on Linux, Clang on macOS, and MSVC on Windows, which are working fine so far. It's possible to specify Clang as the compiler for all platforms, but I'm unsure if it's necessary since the compiler is automatically selected based on the platform.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great---if default compilers are working let's just run with those

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Build and Test ldsCtrlEst

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive

- name: Cache vcpkg binaries
uses: actions/cache@v3
with:
path: ${{ runner.os == 'Windows' && 'C:\\Users\\runneradmin\\AppData\\Local\\vcpkg\\' || '~/.cache/vcpkg' }}
key: vcpkg-binary-${{ matrix.os }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-binary-${{ matrix.os }}-
- name: Cache vcpkg directory
uses: actions/cache@v3
with:
path: vcpkg
key: vcpkg-${{ matrix.os }}-${{ hashFiles('vcpkg.json') }}
restore-keys: |
vcpkg-${{ matrix.os }}-
- name: Set up vcpkg for Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
if (Test-Path -Path "vcpkg") {
Remove-Item -Recurse -Force "vcpkg"
}
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
.\bootstrap-vcpkg.bat
.\vcpkg integrate install
- name: Set up vcpkg for macOS/Linux
if: runner.os != 'Windows'
run: |
rm -rf vcpkg
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these vcpkg steps can likely be taken care of for you by someone else:

- name: Set up dependencies for macOS and Linux
if: runner.os != 'Windows'
run: |
if [ "${{ runner.os }}" == "macOS" ]; then
brew install cmake gfortran curl zip unzip gnu-tar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we leave out gfortran and let vcpkg take care of it? we want to minimize these dependency installation steps that don't get cached

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these tools come pre-installed and some have a convenient GitHub action to set up to speed up this step on all three OS's

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For an example of pre-installed software available on Ubuntu: https://github.com/actions/runner-images/blob/main/images/ubuntu/toolsets/toolset-2404.json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

elif [ "${{ runner.os }}" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y cmake gfortran pkg-config build-essential
fi
- name: Set up dependencies for Windows
if: runner.os == 'Windows'
run: |
choco install cmake git
- name: Cache build directory
uses: actions/cache@v3
with:
path: build
key: build-${{ matrix.os }}-${{ hashFiles('CMakeLists.txt') }}
restore-keys: |
build-${{ matrix.os }}-
- name: Configure and build for macOS/Linux
if: runner.os != 'Windows'
run: |
mkdir -p build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
cmake --build . --config Release --parallel
- name: Configure and build for Windows
if: runner.os == 'Windows'
shell: pwsh
run: |
if (Test-Path -Path "build") {
Remove-Item -Recurse -Force "build"
}
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install
cmake --build . --config Release --parallel
- name: Install (Windows only)
if: runner.os == 'Windows'
run: |
cd build
cmake --install .
- name: Add install directory to PATH (Windows only)
if: runner.os == 'Windows'
run: echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- name: Run tests
run: |
cd build
ctest -C Release
Loading