-added CMake helper functions located in hypertextcpp.cmake; #41
This file contains 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 & test (clang, gcc, MSVC) | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "master", "dev"] | |
paths-ignore: | |
- '**.md' | |
pull_request: | |
branches: [ "master", "dev"] | |
paths-ignore: | |
- '**.md' | |
jobs: | |
build: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Ubuntu Latest gcc", | |
os: ubuntu-latest, | |
cmake-preset: gcc-release, | |
artifacts-path: "" | |
} | |
- { | |
name: "Ubuntu Latest clang", | |
os: ubuntu-latest, | |
cmake-preset: clang-release, | |
artifacts-path: "" | |
} | |
- { | |
name: "Windows Latest MSVC", | |
os: windows-latest, | |
cmake-preset: msvc-release, | |
artifacts-path: "/Release" | |
} | |
steps: | |
- name: Install ninja (Windows) | |
if: matrix.config.os == 'windows-latest' | |
run: choco install ninja | |
- name: Install ninja (Linux) | |
if: matrix.config.os == 'ubuntu-latest' | |
run: sudo apt install ninja-build | |
- uses: actions/checkout@v4 | |
- uses: rui314/setup-mold@v1 | |
- uses: hendrikmuhs/ccache-action@v1.2 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- name: Configure CMake | |
run: cmake --preset=${{ matrix.config.cmake-preset }} -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=ON -DENABLE_EXAMPLES=ON | |
- name: Build | |
run: cmake --build ${{github.workspace}}/build --config Release | |
- name: Test | |
working-directory: ${{github.workspace}}/build | |
run: ctest | |
- name: Prepare examples artifacts | |
shell: bash | |
run: | | |
mkdir examples-build | |
find build/examples -type f -name "ex_*" -exec cp {} examples-build \; | |
find build/examples -type f -name "*.so" -exec cp {} examples-build \; | |
find build/examples -type f -name "*.dll" -exec cp {} examples-build \; | |
- name: Upload examples build artifact | |
if: matrix.config.cmake-preset != 'gcc-release' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hypertextcpp-examples-${{ matrix.config.os }} | |
path: | | |
${{github.workspace}}/examples-build | |
functional_tests: | |
name: Functional testing (${{ matrix.config.name }}) | |
needs: build | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: "Windows", | |
os: "windows-latest", | |
lunchtoast_exec: "lunchtoast.exe", | |
shell_command: -shell="msys2 -c", | |
} | |
- { | |
name: "Linux", | |
os: "ubuntu-latest", | |
lunchtoast_exec: "lunchtoast", | |
shell_command: "", | |
} | |
steps: | |
- uses: actions/checkout@v4 | |
- if: matrix.config.name == 'Windows' | |
uses: msys2/setup-msys2@v2 | |
with: | |
path-type: inherit | |
- uses: robinraju/release-downloader@v1.11 | |
with: | |
repository: "kamchatka-volcano/lunchtoast" | |
latest: true | |
filename: ${{ matrix.config.lunchtoast_exec }} | |
out-file-path: "lunchtoast/" | |
- name: Set lunchtoast execute permissions | |
if: matrix.config.name == 'Linux' | |
shell: sh | |
working-directory: ${{github.workspace}}/lunchtoast | |
run: chmod +x lunchtoast | |
- name: Download hypertextcpp examples build | |
id: pre_launch_tests | |
uses: actions/download-artifact@v4 | |
with: | |
name: hypertextcpp-examples-${{ matrix.config.os }} | |
path: examples-build | |
- name: Set artifacts execute permissions | |
if: matrix.config.name == 'Linux' | |
shell: sh | |
working-directory: ${{github.workspace}}/examples-build | |
run: chmod +x ex* | |
- name: Prepare tests | |
shell: bash | |
run: | | |
cp examples-build/*.so functional_tests/example_5/ || true | |
cp examples-build/*.dll functional_tests/example_5/ || true | |
ls functional_tests/example_5/ | |
- name: Launch tests | |
id: launch_tests | |
working-directory: ${{github.workspace}} | |
run: lunchtoast/lunchtoast functional_tests ${{ matrix.config.shell_command }} -collectFailedTests=failed_tests -config="ci.cfg" | |
- name: Upload failed tests | |
if: failure() && steps.launch_tests.outcome != 'success' && steps.pre_launch_tests.outcome == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: hypertextcpp-failed-tests-${{ matrix.config.os }} | |
path: failed_tests |