Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added GitHub Actions CI for Multi Platforms #341

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
61 changes: 61 additions & 0 deletions .github/CMakeLists.root
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 2.8...3.14)

project(
rpmalloc
VERSION 1.4.5
DESCRIPTION "General Purpose Memory Allocator"
HOMEPAGE_URL "https://github.com/mjansson/rpmalloc"
LANGUAGES C
)

set(CMAKE_C_STANDARD 11)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

include(CMakeDependentOption)
include(GNUInstallDirs)
include(CheckCCompilerFlag)
include(CMakePackageConfigHelpers)
include(CTest)

message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
if(WIN32)
if($ENV{Platform} STREQUAL x86)
message("Building Windows x86-32bit")
add_definitions(-D_WIN32_PLATFORM_X86=1)
endif()
endif()

set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/built")

cmake_dependent_option(BUILD_TESTING
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)

option(BUILD_SHARED_LIBS "Build the library as a shared (dynamically-linked) " OFF)

if(UNIX)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -D ENABLE_ASSERTS=1")
else()
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /D ENABLE_ASSERTS=1 ")
endif()

set(rpmalloc_files rpmalloc/rpmalloc.c )
add_definitions(-DENABLE_OVERRIDE=1)
if(BUILD_SHARED_LIBS)
add_library(rpmalloc SHARED ${rpmalloc_files})
else()
add_library(rpmalloc STATIC ${rpmalloc_files})
endif()
set_property(TARGET rpmalloc PROPERTY POSITION_INDEPENDENT_CODE True)

find_package(Threads)
target_link_libraries(rpmalloc PUBLIC ${CMAKE_THREAD_LIBS_INIT})

if(BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif()
7 changes: 7 additions & 0 deletions .github/CMakeLists.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include_directories(${CMAKE_SOURCE_DIR}/rpmalloc ${CMAKE_SOURCE_DIR}/test)

add_executable(main_test thread.c main.c)

target_link_libraries(main_test rpmalloc)

add_test(NAME main_test COMMAND main_test)
82 changes: 82 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Windows & Ubuntu & Apple macOS
on:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-ubuntu:
name: Linux ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: amd64
flags: -m64
- target: x86
flags: -m32
steps:
- uses: actions/checkout@v4
- name: Prepare
run: |
sudo dpkg --add-architecture i386
sudo apt-get update -q -y
sudo apt-get install -y gcc-multilib g++-multilib valgrind libc6-dbg libc6-dbg:i386
- name: Configure & build
run: |
cp -f .github/CMakeLists.root CMakeLists.txt
cp -f .github/CMakeLists.test test/CMakeLists.txt
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DCMAKE_C_FLAGS=${{ matrix.flags }} ..
cmake --build .
- name: Run test
run: |
cd build
./main_test

build-windows:
name: Windows (${{ matrix.arch }})
runs-on: windows-2019
strategy:
fail-fast: false
matrix:
arch: [x64, Win32]
steps:
- uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- uses: actions/checkout@v4
- name: Configure & build
shell: cmd
run: |
copy /Y .github\CMakeLists.root CMakeLists.txt
copy /Y .github\CMakeLists.test test\CMakeLists.txt
cd build
cmake .. -D BUILD_TESTING=ON -A ${{ matrix.arch }}
cmake --build . --config Debug
- name: Run test
shell: cmd
run: |
cd build\Debug
.\main_test.exe

build-macos:
name: macOS
runs-on: macos-11
steps:
- uses: actions/checkout@v4
- name: Setup
run: |
brew install cmake
- name: Configure & build
run: |
cp -f .github/CMakeLists.root CMakeLists.txt
cp -f .github/CMakeLists.test test/CMakeLists.txt
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
cmake --build .
- name: Run test examples
run: |
cd build
./main_test
32 changes: 32 additions & 0 deletions .github/workflows/ci_centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: CentOS Stream 9

on:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-centos:
name: CentOS
runs-on: ubuntu-latest
strategy:
fail-fast: false
container: quay.io/centos/centos:stream9
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare
run: |
dnf install git make cmake gcc gcc-c++ binutils glibc-devel valgrind autoconf libtool bison automake libxml2-devel sudo which -y
- name: Configure & build
run: |
cp -f .github/CMakeLists.root CMakeLists.txt
cp -f .github/CMakeLists.test test/CMakeLists.txt
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
cmake --build .
- name: Run tests
run: |
cd build
./main_test
53 changes: 53 additions & 0 deletions .github/workflows/ci_cpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: riscv64, s390x, armv7, aarch64, ppc64le

on:
pull_request:
branches: [ main ]
workflow_dispatch:

jobs:
build-qemu:
name: ${{ matrix.target }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: arm
arch: armv7
- target: aarch64
arch: aarch64
- target: ppc64v2
arch: ppc64le
- target: riscv64
arch: riscv64
- target: s390x
arch: s390x
steps:
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
with:
arch: ${{ matrix.arch }}
distro: ubuntu_latest
githubToken: ${{ github.token }}
setup: |
mkdir -p "${PWD}/artifacts"
install: |
apt-get update -q -y
apt-get install -q -y --no-install-recommends cmake build-essential
env: |
# Valgrind on arm will fail if the stack size is larger than 8MB.
# Set QEMUs stack size to 8MB since Github runners use 16MB default.
QEMU_STACK_SIZE: 8388608
run: |
cp -f .github/CMakeLists.root CMakeLists.txt
cp -f .github/CMakeLists.test test/CMakeLists.txt
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON ..
cmake --build .
cd ../build
./main_test
- name: Show the artifact
run: |
ls -al "${PWD}/artifacts"
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,12 @@ coverallsreport.json
codecov.json
codecovreport.json
benchmark-*.txt
build/CMakeFiles/
build/test/
build/cmake_install.cmake
build/CMakeCache.txt
build/compile_commands.json
build/CTestTestfile.cmake
build/DartConfiguration.tcl
build/Makefile
built/