GitHub Actions workflow for automated build and test #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Test ldsCtrlEst | |
| on: | |
| push: | |
| branches: | |
| - master | |
| 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: Set up dependencies for macOS and Linux | |
| if: runner.os != 'Windows' | |
| run: | | |
| if [ "${{ runner.os }}" == "macOS" ]; then | |
| brew install cmake ninja | |
| elif [ "${{ runner.os }}" == "Linux" ]; then | |
| sudo apt-get update | |
| sudo apt-get install -y cmake build-essential | |
| fi | |
| - name: Set up dependencies for Windows | |
| if: runner.os == 'Windows' | |
| run: | | |
| choco install cmake | |
| - name: Run vcpkg | |
| uses: lukka/run-vcpkg@v11 | |
| with: | |
| vcpkgJsonGlob: 'vcpkg.json' | |
| runVcpkgInstall: true | |
| - 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' | |
| uses: lukka/run-cmake@v10 | |
| with: | |
| cmakeListsTxtPath: CMakeLists.txt | |
| configurePreset: 'linux-release' | |
| buildPreset: 'linux-release' | |
| - name: Configure and build for Windows | |
| if: runner.os == 'Windows' | |
| uses: lukka/run-cmake@v10 | |
| with: | |
| cmakeListsTxtPath: CMakeLists.txt | |
| configurePreset: 'windows-release' | |
| buildPreset: 'windows-release' | |
| - name: Install and Update PATH (Windows only) | |
| if: runner.os == 'Windows' | |
| run: | | |
| cd build | |
| cmake --install . | |
| echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append | |
| - name: Run tests | |
| run: | | |
| cd build | |
| ctest -C Release |