Skip to content

Commit

Permalink
Switch CI to Github Actions and massively simplify Makefile setup
Browse files Browse the repository at this point in the history
To utilize the new CMake presets
  • Loading branch information
RichieSams committed Oct 29, 2023
1 parent c7e8515 commit 9a4820b
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 261 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Test

on:
push:

jobs:
linux:
name: ${{ matrix.config.name }}
runs-on: ubuntu-22.04
strategy:
matrix:
config:
- name: linux_gcc_9
compiler: gcc
compiler_version: 9
- name: linux_gcc_12
compiler: gcc
compiler_version: 12
- name: linux_clang_12
compiler: clang
compiler_version: 12
- name: linux_clang_15
compiler: clang
compiler_version: 15
container:
image: quay.io/richiesams/docker_${{ matrix.config.compiler }}:${{ matrix.config.compiler_version }}
steps:
- uses: actions/checkout@v4
- name: Build Debug
run: make CMAKE_PRESET=Unix_x64_Debug generate build
- name: Build Release
run: make CMAKE_PRESET=Unix_x64_Release generate build
- name: Test
run: make test
darwin:
name: ${{ matrix.config.name }}
runs-on: macOS-13
strategy:
matrix:
config:
- name: darwin_gcc_9
compiler: gcc
compiler_version: 9
- name: darwin_gcc_12
compiler: gcc
compiler_version: 12
- name: darwin_clang_12
compiler: clang
compiler_version: 12
- name: darwin_clang_15
compiler: clang
compiler_version: 15
env:
COMPILER: ${{ matrix.config.compiler }}
VERSION: ${{ matrix.config.compiler_version }}
steps:
- uses: actions/checkout@v4
- name: Install
run: bash ci_scripts/darwin_install_compiler.sh
- name: Build Debug
run: make CMAKE_PRESET=Unix_x64_Debug generate build
- name: Build Release
run: make CMAKE_PRESET=Unix_x64_Release generate build
- name: Test
run: make test
windows:
name: ${{ matrix.config.name }}
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- name: windows_vs_2019
os: windows-2019
compiler_version: 2019
- name: windows_vs_2022
os: windows-2022
compiler_version: 2022
steps:
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
with:
vsversion: "${{ matrix.compiler_version }}"
- uses: seanmiddleditch/gha-setup-ninja@master
- name: Build Debug
run: make CMAKE_PRESET=Win_x64_Debug generate build
- name: Build Release
run: make CMAKE_PRESET=Win_x64_Release generate build
- name: Test
run: make test
42 changes: 32 additions & 10 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@
}
},
{
"name": "Linux_x64_Debug",
"displayName": "Linux x64 - Debug",
"description": "Linux, Makefile generator, x64 architecture, Debug build",
"name": "Unix_x64_Debug",
"displayName": "Unix x64 - Debug",
"description": "Unix, Makefile generator, x64 architecture, Debug build",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/Debug",
"architecture": {
Expand All @@ -86,9 +86,9 @@
"vendor": {}
},
{
"name": "Linux_x64_Release",
"displayName": "Linux - Release",
"description": "Linux, Makefile generator, x64 architecture, Release build",
"name": "Unix_x64_Release",
"displayName": "Unix - Release",
"description": "Unix, Makefile generator, x64 architecture, Release build",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/RelWithDebInfo",
"architecture": {
Expand All @@ -105,6 +105,28 @@
},
"environment": {},
"vendor": {}
},
{
"name": "Valgrind",
"displayName": "Valgrind",
"description": "Valgrind",
"generator": "Unix Makefiles",
"binaryDir": "${sourceDir}/build/Valgrind",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"FTL_DISABLE_ITERATOR_DEBUG": true,
"FTL_FIBER_CANARY_BYTES": false,
"FTL_FIBER_STACK_GUARD_PAGES": true,
"FTL_WERROR": true,
"FTL_CPP_17": true,
"FTL_VALGRIND": true
},
"environment": {},
"vendor": {}
}
],
"buildPresets": [
Expand All @@ -117,12 +139,12 @@
"configurePreset": "Win_x64_Release"
},
{
"name": "Linux_x64_Debug",
"configurePreset": "Linux_x64_Debug"
"name": "Unix_x64_Debug",
"configurePreset": "Unix_x64_Debug"
},
{
"name": "Linux_x64_Release",
"configurePreset": "Linux_x64_Release"
"name": "Unix_x64_Release",
"configurePreset": "Unix_x64_Release"
}
]
}
166 changes: 56 additions & 110 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,141 +1,87 @@
ifeq ($(OS),Windows_NT)
detected_OS := Windows
export SHELL=cmd
else
detected_OS := $(shell uname -s)
export SHELL=cmd
endif

FIBER_GUARD_PAGES?=
CPP_17?=
WERROR?=
CMAKE_EXTRA_ARGS?=

export COMPILER?=gcc
export VERSION?=9

ifeq ($(COMPILER),gcc)

export CC=gcc
export CXX=g++

else
ifeq ($(COMPILER),clang)

export CC=clang
export CXX=clang++
CMAKE_OVERRIDE_ARGS=

ifneq ($(FIBER_GUARD_PAGES),)
CMAKE_OVERRIDE_ARGS+=-DFTL_FIBER_STACK_GUARD_PAGES=$(FIBER_GUARD_PAGES)
endif
ifneq ($(CPP_17),)
CMAKE_OVERRIDE_ARGS+=-DFTL_CPP_17=$(CPP_17)
endif

FIBER_GUARD_PAGES?=1
CPP_17?=0
WERROR?=1
CMAKE_EXTRA_ARGS?=

ifeq ($(FIBER_GUARD_PAGES),1)
FIBER_STACK_CMAKE_ARGS= -DFTL_FIBER_STACK_GUARD_PAGES=1
else
FIBER_STACK_CMAKE_ARGS=
ifneq ($(WERROR),)
CMAKE_OVERRIDE_ARGS+=-DFTL_WERROR=$(WERROR)
endif

ifeq ($(CPP_17),1)
CPP_17_CMAKE_ARGS= -DFTL_CPP_17=1
CMAKE_OVERRIDE_ARGS+=$(CMAKE_EXTRA_ARGS)

ifeq ($(OS),Windows_NT)
CMAKE_PRESET?=Win_x64_Debug
else
CPP_17_CMAKE_ARGS=
CMAKE_PRESET?=Unix_x64_Debug
endif

CMAKE_GEN_NAME?=Visual Studio 15 2017 Win64
CMAKE_ARCH_ARG?=

DOCKER_IMAGE=quay.io/richiesams/docker_$(COMPILER):$(VERSION)
.PHONY: build

.PHONY: pull_image generate_linux generate_linux_native build_linux test_linux clean_linux generate_osx build_osx test_osx clean_osx generate_windows build_windows test_windows clean_windows valgrind_linux_build valgrind_linux_build_native valgrind_linux_run build generate
all: generate build clean

all: generate build

#################################
# Building
#################################

generate:
mkdir -p build/debug
mkdir -p build/release
cmake --version
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Debug -Bbuild/debug .
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Release -Bbuild/release .

build:
make -j -C build/debug
make -j -C build/release

test:
/bin/sh -c "(cd build/debug/tests && exec ./ftl-test)"
/bin/sh -c "(cd build/release/tests && exec ./ftl-test)"

benchmark:
/bin/sh -c "(cd build/release/benchmarks && exec ./ftl-benchmark)"


generate_linux:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) make COMPILER=$(COMPILER) VERSION=$(VERSION) FIBER_GUARD_PAGES=$(FIBER_GUARD_PAGES) CPP_17=$(CPP_17) WERROR=$(WERROR) CMAKE_EXTRA_ARGS=$(CMAKE_EXTRA_ARGS) generate_linux_native

generate_linux_native:
mkdir -p build_linux/debug
mkdir -p build_linux/release
cmake --version
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Debug -Bbuild_linux/debug .
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Release -Bbuild_linux/release .

build_linux:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) make -j -C build_linux/debug
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) make -j -C build_linux/release

test_linux:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) /bin/sh -c "(cd build_linux/debug/tests && exec ./ftl-test)"
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) /bin/sh -c "(cd build_linux/release/tests && exec ./ftl-test)"
cmake --preset=$(CMAKE_PRESET) .

clean_linux:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) rm -rf build_linux
build: generate
cmake --build --preset=$(CMAKE_PRESET) -j

valgrind_linux_build:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) make COMPILER=$(COMPILER) VERSION=$(VERSION) FIBER_GUARD_PAGES=$(FIBER_GUARD_PAGES) CPP_17=$(CPP_17) WERROR=$(WERROR) CMAKE_EXTRA_ARGS=$(CMAKE_EXTRA_ARGS) valgrind_linux_build_native

valgrind_linux_build_native:
mkdir -p build_linux_debug
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DFTL_VALGRIND=1 -Bbuild_linux_debug -DCMAKE_BUILD_TYPE=Debug .
make -j -C build_linux_debug
#################################
# Testing
#################################

valgrind_linux_run:
docker run --rm -v $(CURDIR):/app -w /app $(DOCKER_IMAGE) /bin/sh -c "(cd build_linux_debug/tests && exec valgrind --leak-check=yes --log-file=memcheck_output.txt ./ftl-test)"


generate_osx:
mkdir -p build_linux/debug
mkdir -p build_linux/release
cmake --version
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Debug -Bbuild_osx/debug .
cmake $(FIBER_STACK_CMAKE_ARGS) $(CPP_17_CMAKE_ARGS) -DFTL_WERROR=$(WERROR) $(CMAKE_EXTRA_ARGS) -DCMAKE_BUILD_TYPE=Release -Bbuild_osx/release .

build_osx:
make -j -C build_osx/debug
make -j -C build_osx/release

test_osx:
(cd build_osx/debug/tests && exec ./ftl-test)
(cd build_osx/release/tests && exec ./ftl-test)

clean_osx:
rm -rf build_osx
test:
ifeq ($(OS),Windows_NT)
cmd /c "cd build\Debug\tests && ftl-test.exe"
cmd /c "cd build\RelWithDebInfo\tests && ftl-test.exe"
else
/bin/sh -c "(cd build/Debug/tests && exec ./ftl-test)"
/bin/sh -c "(cd build/RelWithDebInfo/tests && exec ./ftl-test)"
endif

benchmark:
ifeq ($(OS),Windows_NT)
cmd /c "cd build\Debug\benchmarks && ftl-benchmark.exe"
cmd /c "cd build\RelWithDebInfo\benchmarks && ftl-benchmark.exe"
else
/bin/sh -c "(cd build/Debug/benchmarks && exec ./ftl-benchmark)"
/bin/sh -c "(cd build/RelWithDebInfo/benchmarks && exec ./ftl-benchmark)"
endif

generate_windows:
if not exist build_windows mkdir build_windows
cmake --version
cmake -G "$(CMAKE_GEN_NAME)" $(CMAKE_ARCH_ARG) -Bbuild_windows .
valgrind_run:
/bin/sh -c "(cd build/Valgrind/tests && exec valgrind --leak-check=yes --log-file=memcheck_output.txt ./ftl-test)"

build_windows:
cmake --build build_windows --config Debug -- /v:m /m
cmake --build build_windows --config Release -- /v:m /m

test_windows:
cd build_windows\tests\Debug & ftl-test.exe
cd build_windows\tests\Release & ftl-test.exe
#################################
# Miscellaneous
#################################

clean_windows:
if exist rmdir /s /q build_windows
clean:
ifeq ($(OS),Windows_NT)
if exist build del /s /q build > nul
if exist build rmdir /s /q build > nul
else
rm -rf build
endif

format:
docker run --rm -v $(CURDIR):/app -w /app quay.io/richiesams/clang-tools-extra:latest /usr/bin/python3 tools/run-clang-format.py -r --clang-format-executable clang-format-15 -i benchmarks examples include source tests
Expand Down
Loading

0 comments on commit 9a4820b

Please sign in to comment.