diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..cbad1428e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +# Project Files unneeded by docker +ci/cache +ci/docker +.git +.gitignore +.github +.dockerignore +.travis.yml +.clang-format +AUTHORS +INSTALL +install-sh +missing +README +README.md + +build/ + +# Editor directories and files +*.user +*.swp diff --git a/.github/workflows/amd64_docker.yml b/.github/workflows/amd64_docker.yml new file mode 100644 index 000000000..41b7cfad2 --- /dev/null +++ b/.github/workflows/amd64_docker.yml @@ -0,0 +1,45 @@ +# ref: https://github.com/docker-library/official-images +name: amd64 Docker + +on: [push, pull_request, workflow_dispatch] + +jobs: + docker: + strategy: + matrix: + distro: [ + almalinux, + alpine, + archlinux, + debian, + fedora, + opensuse, + rockylinux, + ubuntu + ] + fail-fast: false + name: amd64 • ${{ matrix.distro }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check docker + run: | + docker info + docker buildx ls + - name: Build env image + run: make --directory=ci amd64_${{ matrix.distro }}_env + - name: Build devel project + run: make --directory=ci amd64_${{ matrix.distro }}_devel + - name: Build project + run: make --directory=ci amd64_${{ matrix.distro }}_build + - name: Test project + run: make --directory=ci amd64_${{ matrix.distro }}_test + + - name: Build install env image + run: make --directory=ci amd64_${{ matrix.distro }}_install_env + - name: Build install devel project + run: make --directory=ci amd64_${{ matrix.distro }}_install_devel + - name: Build install project + run: make --directory=ci amd64_${{ matrix.distro }}_install_build + - name: Test install project + run: make --directory=ci amd64_${{ matrix.distro }}_install_test diff --git a/.github/workflows/amd64_linux.yml b/.github/workflows/amd64_linux.yml new file mode 100644 index 000000000..9555ee045 --- /dev/null +++ b/.github/workflows/amd64_linux.yml @@ -0,0 +1,61 @@ +# ref: https://github.com/actions/runner-images +name: amd64 Linux + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + cmake: [ + {generator: "Unix Makefiles", config: "Release"}, + {generator: "Ninja", config: "Release"}, + {generator: "Ninja Multi-Config", config: "Release"}, + ] + fail-fast: false + name: Linux • ${{ matrix.cmake.generator }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Install Ninja + run: | + sudo apt-get update + sudo apt-get install ninja-build + - name: Check cmake + run: cmake --version + - name: Install CoinUtils + run: > + cd /tmp + && git clone -b stable/2.11 --depth=1 https://github.com/Mizux/CoinUtils.git + && cd CoinUtils + && cmake -S. -Bbuild + && cmake --build build --config Release + && sudo cmake --build build --config Release --target install + && cd .. + && rm -rf CoinUtils + - name: Configure + run: > + cmake -S. -Bbuild + -G "${{ matrix.cmake.generator }}" + -DCMAKE_BUILD_TYPE="$BUILD_TYPE" + -DCMAKE_INSTALL_PREFIX=build/install + - name: Build + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target all + -v -j2 + - name: Test + run: > + CTEST_OUTPUT_ON_FAILURE=1 + cmake --build build + --config ${{ matrix.cmake.config }} + --target test + -v + - name: Install + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target install + -v diff --git a/.github/workflows/amd64_macos.yml b/.github/workflows/amd64_macos.yml new file mode 100644 index 000000000..bb842e607 --- /dev/null +++ b/.github/workflows/amd64_macos.yml @@ -0,0 +1,56 @@ +# ref: https://github.com/actions/runner-images +name: amd64 MacOS + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + cmake: [ + {generator: "Xcode", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: install}, + {generator: "Unix Makefiles", config: Release, build_target: all, test_target: test, install_target: install}, + ] + fail-fast: false + name: MacOS • ${{ matrix.cmake.generator }} + runs-on: macos-13 # last macos intel based runner + steps: + - uses: actions/checkout@v4 + - name: Check cmake + run: cmake --version + - name: Install CoinUtils + run: > + cd /tmp + && git clone -b stable/2.11 --depth=1 https://github.com/Mizux/CoinUtils.git + && cd CoinUtils + && cmake -S. -Bbuild + && cmake --build build --config Release + && sudo cmake --build build --config Release --target install + && cd .. + && rm -rf CoinUtils + - name: Configure + run: > + cmake -S. -Bbuild + -G "${{ matrix.cmake.generator }}" + -DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }} + -DCMAKE_INSTALL_PREFIX=build/install + - name: Build + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.build_target }} + -v -j2 + - name: Test + run: > + CTEST_OUTPUT_ON_FAILURE=1 + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.test_target }} + -v + - name: Install + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.install_target }} + -v diff --git a/.github/workflows/amd64_windows.yml b/.github/workflows/amd64_windows.yml new file mode 100644 index 000000000..90d50b124 --- /dev/null +++ b/.github/workflows/amd64_windows.yml @@ -0,0 +1,59 @@ +# ref: https://github.com/actions/runner-images +name: amd64 Windows + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + cmake: [ + {generator: "Visual Studio 17 2022", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: INSTALL}, + {generator: "Visual Studio 17 2022", config: Debug, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: INSTALL}, + ] + fail-fast: false + name: Windows • ${{ matrix.cmake.generator }} (${{ matrix.cmake.config }}) + runs-on: windows-latest + env: + CTEST_OUTPUT_ON_FAILURE: 1 + steps: + - uses: actions/checkout@v4 + - name: Check cmake + run: | + cmake --version + cmake -G || true + - name: Install CoinUtils + run: > + git clone -b stable/2.11 --depth=1 https://github.com/Mizux/CoinUtils.git + && cd CoinUtils + && cmake -S. -Bbuild + && cmake --build build --config Release + && cmake --build build --config Release --target install + && cd .. + && Remove-Item CoinUtils -Recurse -Include *.* + - name: Configure + run: > + cmake -S. -Bbuild + -G "${{ matrix.cmake.generator }}" + -DCMAKE_CONFIGURATION_TYPES=${{ matrix.cmake.config }} + -DBUILD_DEPS=ON + -DCMAKE_INSTALL_PREFIX=build/install + - name: Build + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.build_target }} + -v -j2 + - name: Test + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.test_target }} + -v + - name: Install + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.install_target }} + -v diff --git a/.github/workflows/arm64_macos.yml b/.github/workflows/arm64_macos.yml new file mode 100644 index 000000000..da1b44382 --- /dev/null +++ b/.github/workflows/arm64_macos.yml @@ -0,0 +1,56 @@ +# ref: https://github.com/actions/runner-images +name: arm64 MacOS + +on: [push, pull_request, workflow_dispatch] + +# Building using the github runner environement directly. +jobs: + native: + strategy: + matrix: + cmake: [ + {generator: "Xcode", config: Release, build_target: ALL_BUILD, test_target: RUN_TESTS, install_target: install}, + {generator: "Unix Makefiles", config: Release, build_target: all, test_target: test, install_target: install}, + ] + fail-fast: false + name: MacOS • ${{ matrix.cmake.generator }} + runs-on: macos-latest # macos M1 based runner + steps: + - uses: actions/checkout@v4 + - name: Check cmake + run: cmake --version + - name: Install CoinUtils + run: > + cd /tmp + && git clone -b stable/2.11 --depth=1 https://github.com/Mizux/CoinUtils.git + && cd CoinUtils + && cmake -S. -Bbuild + && cmake --build build --config Release + && sudo cmake --build build --config Release --target install + && cd .. + && rm -rf CoinUtils + - name: Configure + run: > + cmake -S. -Bbuild + -G "${{ matrix.cmake.generator }}" + -DCMAKE_BUILD_TYPE=${{ matrix.cmake.config }} + -DCMAKE_INSTALL_PREFIX=build/install + - name: Build + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.build_target }} + -v -j2 + - name: Test + run: > + CTEST_OUTPUT_ON_FAILURE=1 + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.test_target }} + -v + - name: Install + run: > + cmake --build build + --config ${{ matrix.cmake.config }} + --target ${{ matrix.cmake.install_target }} + -v diff --git a/ci/Makefile b/ci/Makefile new file mode 100644 index 000000000..655dfdce2 --- /dev/null +++ b/ci/Makefile @@ -0,0 +1,252 @@ +PROJECT := osi +BRANCH := $(shell git rev-parse --abbrev-ref HEAD) +SHA1 := $(shell git rev-parse --verify HEAD) + +# General commands +.PHONY: help +BOLD:=\e[1m +RESET:=\e[0m + +help: + @echo -e "${BOLD}SYNOPSIS${RESET}" + @echo -e "\tmake [NOCACHE=1] [VERBOSE=1]" + @echo + @echo -e "${BOLD}DESCRIPTION${RESET}" + @echo -e "\ttest build inside docker container to have a reproductible build." + @echo + @echo -e "${BOLD}MAKE TARGETS${RESET}" + @echo -e "\t${BOLD}help${RESET}: display this help and exit." + @echo + @echo -e "\tBuild using docker and the host platform." + @echo -e "\t${BOLD}_${RESET}: build a docker image for a specific distro." + @echo -e "\t${BOLD}save__${RESET}: Save a docker image for a specific distro." + @echo -e "\t${BOLD}sh__${RESET}: run a container using the docker image specified (debug purpose)." + @echo -e "\t${BOLD}clean__${RESET}: Remove a docker image for a specific distro." + @echo -e "\t${BOLD}clean_native${RESET}: Remove ALL caches and docker images." + @echo + @echo -e "\tWith ${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}almalinux${RESET} (latest)" + @echo -e "\t\t${BOLD}alpine${RESET} (edge)" + @echo -e "\t\t${BOLD}archlinux${RESET} (latest)" + @echo -e "\t\t${BOLD}debian${RESET} (latest)" + @echo -e "\t\t${BOLD}fedora${RESET} (latest)" + @echo -e "\t\t${BOLD}opensuse${RESET} (tumbleweed)" + @echo -e "\t\t${BOLD}rockylinux${RESET} (9)" + @echo -e "\t\t${BOLD}ubuntu${RESET} (latest)" + @echo -e "\t\t${BOLD}all${RESET}: trigger ALL DISTROS." + @echo + @echo -e "\tWith ${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}env${RESET}" + @echo -e "\t\t${BOLD}devel${RESET}" + @echo -e "\t\t${BOLD}build${RESET}" + @echo -e "\t\t${BOLD}test${RESET}" + @echo -e "\t\t${BOLD}install_env${RESET}" + @echo -e "\t\t${BOLD}install_devel${RESET}" + @echo -e "\t\t${BOLD}install_build${RESET}" + @echo -e "\t\t${BOLD}install_test${RESET}" + @echo -e "\te.g. 'make ubuntu_test'" + @echo + @echo -e "\tBuild using docker buildx with a platform specified." + @echo -e "\t${BOLD}_${RESET}: build docker images for ALL DISTROS." + @echo -e "\t${BOLD}__${RESET}: build docker image for a specific distro." + @echo -e "\t${BOLD}save__${RESET}: Save docker images for ALL DISTROS." + @echo -e "\t${BOLD}save___${RESET}: Save the docker image for a specific distro." + @echo -e "\t${BOLD}sh___${RESET}: run a container using the docker image specified (debug purpose)." + @echo -e "\t${BOLD}clean___${RESET}: Remove cache and docker image." + @echo -e "\t${BOLD}clean_platforms${RESET}: Remove ALL cache and docker image." + @echo + @echo -e "\tWith ${BOLD}${RESET}:" + @echo -e "\t\t${BOLD}amd64${RESET}: linux/amd64 (x86_64)" + @echo -e "\t\t${BOLD}386${RESET}: linux/386 (x86)" + @echo -e "\t\t${BOLD}arm${RESET}: linux/arm (armv7)" + @echo -e "\t\t${BOLD}arm64${RESET}: linux/arm64 (aarch64, arm64v8)" + @echo -e "\t\t${BOLD}mips${RESET}: linux/mips (mips 32bits)" + @echo -e "\t\t${BOLD}mipsle${RESET}: linux/mipsle (mips 32bits Little Endian)" + @echo -e "\t\t${BOLD}mips64${RESET}: linux/mips64 (mips 64bits)" + @echo -e "\t\t${BOLD}mips64le${RESET}: linux/mips64le (mips 64bits Little Endian)" + @echo -e "\t\t${BOLD}ppc64${RESET}: linux/ppc64 (PowerPC 64Bits)" + @echo -e "\t\t${BOLD}ppc64le${RESET}: linux/ppc64le (PowerPC 64Bits Little Endian)" + @echo -e "\t\t${BOLD}riscv64${RESET}: linux/riscv64 (RISC-V 64bits)" + @echo -e "\t\t${BOLD}s390x${RESET}: linux/s390x (IBM System/390x)" + @echo -e "\te.g. 'make amd64_ubuntu_test'" + @echo -e "\tDocker image unavailable: arm64_archlinux" + @echo + @echo -e "\tGlobal targets." + @echo -e "\t${BOLD}clean${RESET}: Remove ALL caches and docker images." + @echo -e "\t${BOLD}distclean${RESET}: Remove everything." + @echo + @echo -e "\t${BOLD}NOCACHE=1${RESET}: use 'docker build --no-cache' when building container (default use cache)." + @echo -e "\t${BOLD}VERBOSE=1${RESET}: use 'docker build --progress=plain' when building container." + @echo + @echo -e "branch: $(BRANCH)" + @echo -e "sha1: $(SHA1)" + +# Need to add cmd_distro to PHONY otherwise target are ignored since they do not +# contain recipe (using FORCE do not work here) +.PHONY: all +all: all_test + +# Delete all implicit rules to speed up makefile +MAKEFLAGS += --no-builtin-rules +.SUFFIXES: +# Remove some rules from gmake that .SUFFIXES does not remove. +SUFFIXES := +# Keep all intermediate files +# ToDo: try to remove it later +.SECONDARY: + +# Docker image name prefix. +IMAGE := ${PROJECT} + +DOCKER_BUILD_CMD := docker build +DOCKER_BUILDX_CMD := docker buildx build +ifdef NOCACHE +DOCKER_BUILD_CMD := ${DOCKER_BUILD_CMD} --no-cache +DOCKER_BUILDX_CMD := ${DOCKER_BUILDX_CMD} --no-cache +endif +ifdef VERBOSE +DOCKER_BUILD_CMD := ${DOCKER_BUILD_CMD} --progress=plain +DOCKER_BUILDX_CMD := ${DOCKER_BUILDX_CMD} --progress=plain +endif +DOCKER_RUN_CMD := docker run --rm --init --net=host + +# Currently supported distro +DISTROS := \ + almalinux \ + alpine \ + archlinux \ + debian \ + fedora \ + opensuse \ + rockylinux \ + ubuntu + +# $* stem +# $< first prerequist +# $@ target name + +############ +## STAGES ## +############ +STAGES := env devel build test install_env install_devel install_build install_test + +define make-stage-target = +#$$(info STAGE: $1) +#$$(info Create targets: all_$1 $(addsuffix _$1, $(DISTROS)).) +targets_$1 := $(addsuffix _$1, $(DISTROS)) +.PHONY: all_$1 $$(targets_$1) +all_$1: $$(targets_$1) +$$(targets_$1): %_$1: docker/%/Dockerfile + #@docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null + ${DOCKER_BUILD_CMD} --target=$1 --tag ${IMAGE}:$$*_$1 -f $$< .. + +#$$(info Create targets: save_all_$1 $(addprefix save_, $(addsuffix _$1, $(DISTROS))) (debug).) +save_targets_$1 := $(addprefix save_, $(addsuffix _$1, $(DISTROS))) +.PHONY: save_all_$1 $$(save_targets_$1) +save_all_$1: $$(save_targets_$1) +$$(save_targets_$1): save_%_$1: cache/%/docker_$1.tar +cache/%/docker_$1.tar: %_$1 + @rm -f $$@ + mkdir -p cache/$$* + docker save ${IMAGE}:$$*_$1 -o $$@ + +#$$(info Create targets: $(addprefix sh_, $(addsuffix _$1, $(DISTROS))) (debug).) +sh_targets_$1 := $(addprefix sh_, $(addsuffix _$1, $(DISTROS))) +.PHONY: $$(sh_targets_$1) +$$(sh_targets_$1): sh_%_$1: %_$1 + ${DOCKER_RUN_CMD} -it --name ${IMAGE}_$$*_$1 ${IMAGE}:$$*_$1 + +#$$(info Create targets: clean_all_$1 $(addprefix clean_, $(addsuffix _$1, $(DISTROS))).) +clean_targets_$1 := $(addprefix clean_, $(addsuffix _$1, $(DISTROS))) +.PHONY: clean_all_$1 $$(clean_targets_$1) +clean_all_$1: $$(clean_targets_$1) +$$(clean_targets_$1): clean_%_$1: + docker image rm -f ${IMAGE}:$$*_$1 2>/dev/null + rm -f cache/$$*/docker_$1.tar +endef + +$(foreach stage,$(STAGES),$(eval $(call make-stage-target,$(stage)))) + +## MERGE ## +.PHONY: clean_all +clean_all: $(addprefix clean_all_, $(STAGES)) + rm -f $(addprefix cache/, $(DISTROS)) + +############## +## PLATFORM ## +############## +# ref: https://go.dev/doc/install/source#environment +# ref: https://github.com/containerd/containerd/blob/269548fa27e0089a8b8278fc4fc781d7f65a939b/platforms/platforms.go#L80-L94 +PLATFORMS := \ + 386 amd64 \ + arm arm64 \ + mips mipsle mips64 mips64le \ + ppc64 ppc64le \ + riscv64 \ + s390x + +define make-platform-stage-target = +#$$(info PLATFORM: '$1' STAGE: '$2') +#$$(info Create targets: $1_all_$2 $(addprefix $1_, $(addsuffix _$2, $(DISTROS))).) +targets_$1_$2 := $(addprefix $1_, $(addsuffix _$2, $(DISTROS))) +.PHONY: $1_all_$2 $$(targets_$1_$2) +$1_all_$2: $$(targets_$1_$2) +$$(targets_$1_$2): $1_%_$2: docker/%/Dockerfile + #@docker image rm -f ${IMAGE}:$1_$$*_$2 2>/dev/null + ${DOCKER_BUILDX_CMD} --platform linux/$1 --target=$2 --tag ${IMAGE}:$1_$$*_$2 -f $$< .. + +#$$(info Create save targets: save_$1_all_$2 $(addprefix save_$1_, $(addsuffix _$2, $(DISTROS))) (debug).) +save_targets_$1_$2 := $(addprefix save_$1_, $(addsuffix _$2, $(DISTROS))) +.PHONY: save_$1_all_$2 $$(save_targets_$1_$2) +save_$1_all_$2: $$(save_targets_$1_$2) +$$(save_targets_$1_$2): save_$1_%_$2: cache/$1/%/docker_$2.tar +cache/$1/%/docker_$2.tar: $1_%_$2 + @rm -f $$@ + mkdir -p cache/$1/$$* + docker save ${IMAGE}:$1_$$*_$2 -o $$@ + +#$$(info Create sh targets: $(addprefix sh_$1_, $(addsuffix _$2, $(DISTROS))) (debug).) +sh_targets_$1_$2 := $(addprefix sh_$1_, $(addsuffix _$2, $(DISTROS))) +.PHONY: $$(sh_targets_$1_$2) +$$(sh_targets_$1_$2): sh_$1_%_$2: $1_%_$2 + ${DOCKER_RUN_CMD} --platform linux/$1 -it --name ${IMAGE}_$1_$$*_$2 ${IMAGE}:$1_$$*_$2 + +#$$(info Create targets: clean_$1_all_$2 $(addprefix clean_$1_, $(addsuffix _$2, $(DISTROS))).) +clean_targets_$1_$2 := $(addprefix clean_$1_, $(addsuffix _$2, $(DISTROS))) +.PHONY: clean_$1_all_$2 $$(clean_targets_$1_$2) +clean_$1_all_$2: $$(clean_targets_$1_$2) +$$(clean_targets_$1_$2): clean_$1_%_$2: + docker image rm -f ${IMAGE}:$1_$$*_$2 2>/dev/null + rm -f cache/$1/$$*/docker_$2.tar +endef + +define make-platform-target = +#$$(info PLATFORM: $1) +$(foreach stage,$(STAGES),$(eval $(call make-platform-stage-target,$1,$(stage)))) + +# merge +.PHONY: clean_$1 +clean_$1: $(addprefix clean_$1_all_, $(STAGES)) + -rmdir $(addprefix cache/$1/, $(DISTROS)) + -rmdir cache/$1 +endef + +$(foreach platform,$(PLATFORMS),$(eval $(call make-platform-target,$(platform)))) + +## MERGE ## +.PHONY: clean_platforms +clean_platforms: $(addprefix clean_, $(PLATFORMS)) + +########### +## CLEAN ## +########### +.PHONY: clean +clean: clean_all clean_platforms + docker container prune -f + docker image prune -f + -rmdir cache + +.PHONY: distclean +distclean: clean + -docker container rm -f $$(docker container ls -aq) + -docker image rm -f $$(docker image ls -aq) diff --git a/ci/docker/almalinux/Dockerfile b/ci/docker/almalinux/Dockerfile new file mode 100644 index 000000000..bb31512d4 --- /dev/null +++ b/ci/docker/almalinux/Dockerfile @@ -0,0 +1,49 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/almalinux +FROM almalinux:latest AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN dnf -y update \ +&& dnf -y install git wget openssl-devel cmake \ +&& dnf -y groupinstall "Development Tools" \ +&& dnf clean all \ +&& rm -rf /var/cache/dnf +CMD [ "/usr/bin/bash" ] + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/alpine/Dockerfile b/ci/docker/alpine/Dockerfile new file mode 100644 index 000000000..ce047853a --- /dev/null +++ b/ci/docker/alpine/Dockerfile @@ -0,0 +1,44 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/alpine +FROM alpine:edge AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN apk add --no-cache git build-base linux-headers cmake + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/archlinux/Dockerfile b/ci/docker/archlinux/Dockerfile new file mode 100644 index 000000000..1e997dd46 --- /dev/null +++ b/ci/docker/archlinux/Dockerfile @@ -0,0 +1,44 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/archlinux/ +FROM archlinux:latest AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN pacman -Syu --noconfirm git base-devel cmake + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/debian/Dockerfile b/ci/docker/debian/Dockerfile new file mode 100644 index 000000000..e9cf60fa4 --- /dev/null +++ b/ci/docker/debian/Dockerfile @@ -0,0 +1,47 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/debian +FROM debian:unstable AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN apt-get update -qq \ +&& apt-get install -yq git wget libssl-dev build-essential cmake \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/fedora/Dockerfile b/ci/docker/fedora/Dockerfile new file mode 100644 index 000000000..149b56620 --- /dev/null +++ b/ci/docker/fedora/Dockerfile @@ -0,0 +1,48 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/fedora +FROM fedora:latest AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN dnf -y update \ +&& dnf -y install git wget \ +&& dnf -y install @development-tools \ +&& dnf -y install gcc-c++ cmake \ +&& dnf clean all + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/opensuse/Dockerfile b/ci/docker/opensuse/Dockerfile new file mode 100644 index 000000000..11466b0a4 --- /dev/null +++ b/ci/docker/opensuse/Dockerfile @@ -0,0 +1,47 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/r/opensuse/tumbleweed +FROM opensuse/tumbleweed AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN zypper update -y \ +&& zypper install -y git patch gcc gcc-c++ cmake \ +&& zypper clean -a +ENV CC=gcc CXX=g++ + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/rockylinux/Dockerfile b/ci/docker/rockylinux/Dockerfile new file mode 100644 index 000000000..17f807e90 --- /dev/null +++ b/ci/docker/rockylinux/Dockerfile @@ -0,0 +1,49 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/rockylinux +FROM rockylinux:9 AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN dnf -y update \ +&& dnf -y install git wget openssl-devel cmake \ +&& dnf -y groupinstall "Development Tools" \ +&& dnf clean all \ +&& rm -rf /var/cache/dnf +CMD [ "/usr/bin/bash" ] + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/docker/ubuntu/Dockerfile b/ci/docker/ubuntu/Dockerfile new file mode 100644 index 000000000..81b898254 --- /dev/null +++ b/ci/docker/ubuntu/Dockerfile @@ -0,0 +1,49 @@ +# Create a virtual environment with all tools installed +# ref: https://hub.docker.com/_/ubuntu +FROM ubuntu:latest AS env + +# Install system build dependencies +ENV PATH=/usr/local/bin:$PATH +RUN apt update -q \ +&& DEBIAN_FRONTEND=noninteractive apt install -yq \ + git wget libssl-dev \ + build-essential cmake \ +&& apt-get clean \ +&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +RUN cd /tmp \ +&& git clone -b stable/2.11 https://github.com/Mizux/CoinUtils.git \ +&& cd CoinUtils \ +&& cmake -S. -Bbuild \ +&& cmake --build build --target install \ +&& cd .. \ +&& rm -rf CoinUtils + +# Add the library src to our build env +FROM env AS devel +WORKDIR /home/project +COPY . . + +FROM devel AS build +RUN cmake --version +RUN cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release +RUN cmake --build build --target all -v +RUN cmake --build build --target install -v + +FROM build AS test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v + +# Test install rules +FROM env AS install_env +COPY --from=build /usr/local /usr/local/ + +FROM install_env AS install_devel +WORKDIR /home/sample +COPY ci/sample . + +FROM install_devel AS install_build +RUN cmake -S. -Bbuild +RUN cmake --build build --target all -v + +FROM install_build AS install_test +RUN CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test -v diff --git a/ci/sample/CMakeLists.txt b/ci/sample/CMakeLists.txt new file mode 100644 index 000000000..2c40d8254 --- /dev/null +++ b/ci/sample/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.5) +project(Sample VERSION 1.0.0 LANGUAGES CXX) + +include(CTest) +find_package(Osi REQUIRED) + +add_executable(sample main.cpp) +#target_compile_features(sample PUBLIC cxx_std_11) +set_target_properties(sample PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + VERSION ${PROJECT_VERSION}) +target_link_libraries(sample PRIVATE Coin::Osi) + +if(BUILD_TESTING) + add_test(NAME sample_UT COMMAND sample) +endif() + +include(GNUInstallDirs) +install(TARGETS sample + EXPORT SampleTargets + DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/ci/sample/main.cpp b/ci/sample/main.cpp new file mode 100644 index 000000000..d2b9c1565 --- /dev/null +++ b/ci/sample/main.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(int argc, char** argv) { + std::cout << "coinutils version: " << COINUTILS_VERSION << std::endl; + std::cout << "osi version: " << OSI_VERSION << std::endl; + return 0; +} +