From 66362500ac7ad40a974a526bd9a189fb63050edb Mon Sep 17 00:00:00 2001 From: Johan Mabille Date: Wed, 7 Feb 2024 17:00:24 +0100 Subject: [PATCH] Added GitHub Actions --- .github/workflows/linux.yml | 85 +++++++++++++++++++++++++++++++++++ .github/workflows/osx.yml | 50 +++++++++++++++++++++ .github/workflows/windows.yml | 63 ++++++++++++++++++++++++++ test/CMakeLists.txt | 2 +- 4 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/linux.yml create mode 100644 .github/workflows/osx.yml create mode 100644 .github/workflows/windows.yml diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..ad4603a6 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,85 @@ +name: Linux +on: + workflow_dispatch: + pull_request: + push: + branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash -e -l {0} +jobs: + build: + runs-on: ubuntu-20.04 + name: ${{ matrix.sys.compiler }} ${{ matrix.sys.version }} + strategy: + fail-fast: false + matrix: + sys: + - {compiler: clang, version: '15'} + - {compiler: clang, version: '16'} + - {compiler: gcc, version: '11'} + - {compiler: gcc, version: '13'} + + steps: + + - name: Setup GCC + if: ${{ matrix.sys.compiler == 'gcc' }} + run: | + GCC_VERSION=${{ matrix.sys.version }} + sudo apt-get update + sudo apt-get --no-install-suggests --no-install-recommends install g++-$GCC_VERSION + CC=gcc-$GCC_VERSION + echo "CC=$CC" >> $GITHUB_ENV + CXX=g++-$GCC_VERSION + echo "CXX=$CXX" >> $GITHUB_ENV + + - name: Setup clang + if: ${{ matrix.sys.compiler == 'clang' }} + run: | + LLVM_VERSION=${{ matrix.sys.version }} + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - || exit 1 + if [[ $LLVM_VERSION -ge 13 ]]; then + sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" || exit 1 + else + sudo add-apt-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal main" || exit 1 + fi || exit 1 + sudo apt-get update || exit 1 + sudo apt-get --no-install-suggests --no-install-recommends install clang-$LLVM_VERSION || exit 1 + sudo apt-get --no-install-suggests --no-install-recommends install g++-9 g++-9-multilib || exit 1 + sudo ln -s /usr/include/asm-generic /usr/include/asm + CC=clang-$LLVM_VERSION + echo "CC=$CC" >> $GITHUB_ENV + CXX=clang++-$LLVM_VERSION + echo "CXX=$CXX" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Configure using CMake + # env: + # CC: ${{ env.CC }} + # CXX: ${{ env.CXX }} + run: cmake -G Ninja -Bbuild -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON + + - name: Install + working-directory: build + run: cmake --install . + + - name: Build + working-directory: build + run: cmake --build . --target test_xparrow_lib --parallel 8 + + - name: Run tests + working-directory: build + run: ./test/test_xparrow_lib diff --git a/.github/workflows/osx.yml b/.github/workflows/osx.yml new file mode 100644 index 00000000..567c1f6e --- /dev/null +++ b/.github/workflows/osx.yml @@ -0,0 +1,50 @@ +name: OSX +on: + workflow_dispatch: + pull_request: + push: + branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash -e -l {0} +jobs: + build: + runs-on: macos-${{ matrix.os }} + name: macos-${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: + - 11 + - 12 + + steps: + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + + - name: Configure using CMake + run: cmake -Bbuild -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON + + - name: Install + working-directory: build + run: cmake --install . + + - name: Build + working-directory: build + run: cmake --build . --target test_xparrow_lib --parallel 8 + + - name: Run tests + working-directory: build + run: ./test/test_xparrow_lib diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml new file mode 100644 index 00000000..4c35f506 --- /dev/null +++ b/.github/workflows/windows.yml @@ -0,0 +1,63 @@ +name: Windows +on: + workflow_dispatch: + pull_request: + push: + branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} + cancel-in-progress: true +defaults: + run: + shell: bash -e -l {0} +jobs: + build: + runs-on: ${{ matrix.runs-on }} + name: ${{ matrix.sys.compiler }} + strategy: + fail-fast: false + matrix: + runs-on: [windows-latest] + sys: + - {compiler: default} + - {compiler: clang} + + steps: + + - name: Setup MSVC + if: matrix.sys.compiler == 'default' + uses: ilammy/msvc-dev-cmd@v1 + + - name: Setup clang + if: matrix.sys.compiler == 'clang' + run: | + echo "CC=clang" >> $GITHUB_ENV + echo "CXX=clang++" >> $GITHUB_ENV + + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set conda environment + uses: mamba-org/setup-micromamba@main + with: + environment-name: myenv + environment-file: environment-dev.yml + init-shell: bash + cache-downloads: true + create-args: | + ninja + + - name: Configure using CMake + run: cmake -Bbuild -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DBUILD_TESTS=ON -G Ninja + + - name: Install + working-directory: build + run: cmake --install . + + - name: Build + working-directory: build + run: cmake --build . --target test_xparrow_lib --parallel 8 + + - name: Run tests + working-directory: build + run: ./test/test_xparrow_lib diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d45956e1..7f5a192f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,6 +30,6 @@ endif() set(XPARROW_TESTS main.cpp ) -set(test_target "test_xsparrow_lib") +set(test_target "test_xparrow_lib") add_executable(${test_target} ${XPARROW_TESTS}) target_link_libraries(${test_target} PRIVATE doctest::doctest)