FTXUI/.github/workflows/build.yaml

240 lines
6.4 KiB
YAML
Raw Normal View History

name: Build
on:
create:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: "Tests"
strategy:
fail-fast: false
matrix:
include:
- name: Linux GCC
os: ubuntu-latest
2022-04-17 21:47:20 +08:00
compiler: gcc
gcov_executable: gcov
- name: Linux Clang
os: ubuntu-latest
2022-04-17 21:47:20 +08:00
compiler: llvm
gcov_executable: "llvm-cov gcov"
2024-08-17 16:57:13 +08:00
# https://github.com/aminya/setup-cpp/issues/246
#- name: MacOS clang
#os: macos-latest
#compiler: llvm
#gcov_executable: "llvm-cov gcov"
- name: Windows MSVC
os: windows-latest
compiler: cl
runs-on: ${{ matrix.os }}
steps:
2023-05-19 18:11:12 +08:00
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: "Checkout repository"
2024-08-17 16:57:13 +08:00
uses: actions/checkout@v3
2022-04-17 21:47:20 +08:00
- name: "Setup Cpp"
uses: aminya/setup-cpp@v1
with:
compiler: ${{ matrix.compiler }}
vcvarsall: ${{ contains(matrix.os, 'windows' )}}
cmake: true
ninja: true
2023-05-19 18:11:12 +08:00
clangtidy: false
2022-04-17 21:47:20 +08:00
cppcheck: false
2022-05-23 23:34:07 +08:00
gcovr: "5.0"
2022-04-17 21:47:20 +08:00
opencppcoverage: true
2022-04-17 21:47:20 +08:00
# make sure coverage is only enabled for Debug builds, since it sets -O0
# to make sure coverage has meaningful results
- name: "Configure CMake"
run: >
cmake -S .
-B ./build
-DCMAKE_BUILD_TYPE:STRING=Debug
2023-05-19 18:11:12 +08:00
-DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }}
2022-04-17 21:47:20 +08:00
-DFTXUI_ENABLE_COVERAGE:BOOL=ON
-DFTXUI_BUILD_DOCS:BOOL=OFF
-DFTXUI_BUILD_EXAMPLES:BOOL=ON
-DFTXUI_BUILD_TESTS:BOOL=ON
-DFTXUI_BUILD_TESTS_FUZZER:BOOL=OFF
-DFTXUI_ENABLE_INSTALL:BOOL=ON
-DFTXUI_DEV_WARNINGS:BOOL=ON ;
2022-04-17 21:47:20 +08:00
- name: "Build"
run: >
2022-04-17 21:47:20 +08:00
cmake
--build ./build
2024-08-17 16:57:13 +08:00
- name: Unix - Test
2022-04-17 21:47:20 +08:00
if: runner.os != 'Windows'
working-directory: ./build
run: >
ctest -C Debug --rerun-failed --output-on-failure;
2024-08-17 16:57:13 +08:00
- name: Unix - coverage
if: runner.os != 'Windows'
working-directory: ./build
run: >
2022-04-17 21:47:20 +08:00
gcovr
-j ${{env.nproc}}
--delete
--root ../
--exclude "../examples"
--exclude ".*google.*"
2022-04-27 19:25:43 +08:00
--exclude ".*test.*"
2022-04-28 17:32:30 +08:00
--exclude-unreachable-branches
--exclude-throw-branches
--sort-uncovered
2022-04-17 21:47:20 +08:00
--print-summary
--xml-pretty
--xml
coverage.xml
.
--gcov-executable '${{ matrix.gcov_executable }}';
- name: Windows - Test and coverage
if: runner.os == 'Windows'
working-directory: ./build
run: >
OpenCppCoverage.exe
--export_type cobertura:coverage.xml
--cover_children
--
ctest -C Debug --rerun-failed --output-on-failure;
2022-04-17 21:47:20 +08:00
- name: Publish to codecov
2022-08-15 21:00:28 +08:00
uses: codecov/codecov-action@v3
2022-04-17 21:47:20 +08:00
with:
flags: ${{ runner.os }}
name: ${{ runner.os }}-coverage
files: ./build/coverage.xml
# Create a release on new v* tags
release:
needs: test
if: ${{ github.event_name == 'create' && startsWith(github.ref, 'refs/tags/v') }}
name: "Create release"
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: "Create release"
uses: softprops/action-gh-release@v1
id: create_release
with:
draft: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Build artifact for the release
package:
name: "Build packages"
needs: release
strategy:
matrix:
include:
- os: ubuntu-latest
asset_path: build/ftxui*Linux*
- os: macos-latest
asset_path: build/ftxui*Darwin*
- os: windows-latest
asset_path: build/ftxui*Win64*
runs-on: ${{ matrix.os }}
steps:
2023-05-19 18:11:12 +08:00
- name: Get number of CPU cores
uses: SimenB/github-actions-cpu-cores@v1
id: cpu-cores
- name: "Checkout repository"
2024-08-17 16:57:13 +08:00
uses: actions/checkout@v3
- name: "Install cmake"
uses: lukka/get-cmake@latest
- name: "Build packages"
run: >
mkdir build;
cd build;
cmake ..
-DCMAKE_BUILD_TYPE=Release
2023-05-19 18:11:12 +08:00
-DCMAKE_BUILD_PARALLEL_LEVEL=${{ steps.cpu-cores.outputs.count }}
-DFTXUI_BUILD_DOCS=OFF
-DFTXUI_BUILD_EXAMPLES=OFF
-DFTXUI_BUILD_TESTS=OFF
-DFTXUI_BUILD_TESTS_FUZZER=OFF
-DFTXUI_ENABLE_INSTALL=ON
-DFTXUI_DEV_WARNINGS=ON ;
2022-04-17 21:47:20 +08:00
cmake --build . --target package;
2023-05-19 18:11:12 +08:00
- uses: shogo82148/actions-upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ${{ matrix.asset_path }}
overwrite: true
documentation:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: "Checkout repository"
2024-08-17 16:57:13 +08:00
uses: actions/checkout@v3
- name: "Install cmake"
uses: lukka/get-cmake@latest
- name: "Install emsdk"
uses: mymindstorm/setup-emsdk@v7
- name: "Install Doxygen/Graphviz"
run: >
sudo apt-get update;
sudo apt-get install doxygen graphviz;
- name: "Build documentation"
run: >
mkdir build;
cd build;
emcmake cmake ..
-DCMAKE_BUILD_TYPE=Release
-DFTXUI_BUILD_DOCS=ON
-DFTXUI_BUILD_EXAMPLES=ON
-DFTXUI_BUILD_TESTS=OFF
-DFTXUI_BUILD_TESTS_FUZZER=OFF
-DFTXUI_ENABLE_INSTALL=OFF
-DFTXUI_DEV_WARNINGS=ON ;
2022-07-10 01:12:45 +08:00
cmake --build . --target doc;
cmake --build . ;
rsync -amv
--include='*/'
--include='*.html'
2023-11-19 19:09:52 +08:00
--include='*.css'
--include='*.mjs'
--include='*.js'
--include='*.wasm'
--exclude='*'
examples
doc/doxygen/html;
- name: "Deploy"
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: build/doc/doxygen/html/
enable_jekyll: false
allow_empty_commit: false
force_orphan: true
publish_branch: gh-pages