This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/819-simplify-devcontainer-setup in repository https://gitbox.apache.org/repos/asf/celix.git
commit 7b36859652fed0cb714d824eae27e9d82df09a92 Author: Pepijn Noltes <[email protected]> AuthorDate: Fri Feb 6 17:07:28 2026 +0000 gh-819: Simplify devcontainer setup Remove the build script and conan profiles. Change the setup to support Conan --- .devcontainer/Containerfile | 108 +++++---------------- .devcontainer/README.md | 56 +++++------ .devcontainer/build-devcontainer-image.sh | 33 ------- .devcontainer/build-project-with-conan.sh | 24 ----- .devcontainer/conan-container-debug-profile | 26 ----- .devcontainer/conan-container-default-profile | 26 ----- .devcontainer/devcontainer.json | 37 ++++++- .devcontainer/run-devcontainer.sh | 133 -------------------------- .devcontainer/setup-project-with-apt.sh | 36 ------- .devcontainer/setup-project-with-conan.sh | 26 ----- .github/workflows/containers.yml | 74 ++++---------- 11 files changed, 104 insertions(+), 475 deletions(-) diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile index cc2b2f8ca..21b3f8bfb 100644 --- a/.devcontainer/Containerfile +++ b/.devcontainer/Containerfile @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as build +FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as base # Install dependencies RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ @@ -28,101 +28,41 @@ RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ make \ zip \ ninja-build \ + clang-tidy \ lcov \ sudo \ python3 \ pipx && \ apt-get clean -#python3-pip && \ - # Build image using conan & cmake -FROM build as conan-build - -# Install conan -#RUN pip3 install conan && pip3 cache purge -##RUN DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ -# python3-conan && \ -# apt-get clean -ENV PATH="${PATH}:/root/.local/bin" -RUN pipx install conan - -# Setup conan profile for root -COPY conan-container-default-profile /root/.conan2/profiles/default -COPY conan-container-debug-profile /root/.conan2/profiles/debug - -# Build image using apt dependencies -FROM build as apt-build +FROM base as conan-build -# Install celix dependencies (note git needed for cloning gtest) -RUN DEBIAN_FRONTEND="noninteractive" sudo apt-get update && \ - DEBIAN_FRONTEND="noninteractive" sudo apt-get install -y --no-install-recommends \ - git \ - civetweb \ - libavahi-compat-libdnssd-dev \ - libcivetweb-dev \ - libcpputest-dev \ - libcurl4-openssl-dev \ - libczmq-dev \ - libffi-dev \ - libjansson-dev \ - libxml2-dev \ - libzip-dev \ - libuv1-dev \ - rapidjson-dev \ - uuid-dev && \ - sudo apt-get clean +ARG USERNAME=celixdev +ARG USER_UID=1000 +ARG USER_GID=1000 -#Note from build not conan-build, because conan-dev uses a celixdev user -FROM build as conan-dev - -# Remove ubuntu user and add celixdev with sudo rights and a "celixdev" password RUN userdel -r ubuntu && \ - groupadd --gid 1000 celixdev && \ - useradd --uid 1000 --gid 1000 -m \ - -s /bin/bash -G sudo celixdev && \ - echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ - echo "celixdev:celixdev" | chpasswd -USER celixdev -WORKDIR /home/celixdev - -#Create workdir, used in vscode -#RUN sudo mkdir -p /workspaces/celix/build && sudo chown -R celixdev:celixdev /workspaces - -# Setup python venv for celixdev and install conan -ENV PATH="${PATH}:/home/celixdev/.local/bin" -RUN pipx install conan + groupadd --gid ${USER_GID} ${USERNAME} && \ + useradd --uid ${USER_UID} --gid ${USER_GID} --create-home --shell /bin/bash ${USERNAME} && \ + usermod -aG sudo ${USERNAME} && \ + echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -# Setup conan profile for celixdev -COPY --chown=celixdev:celixdev conan-container-default-profile /home/celixdev/.conan2/profiles/default -COPY --chown=celixdev:celixdev conan-container-debug-profile /home/celixdev/.conan2/profiles/debug +USER ${USERNAME} +WORKDIR /home/${USERNAME} -#Install development dependencies -RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \ - sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ - gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim openssh-server cmake-curses-gui gdb \ - wget curl && \ - sudo apt-get clean - -RUN sudo mkdir /run/sshd +ENV PATH="${PATH}:/home/${USERNAME}/.local/bin" +RUN pipx install conan && \ + conan profile detect --force && \ + cp /home/${USERNAME}/.conan2/profiles/default /home/${USERNAME}/.conan2/profiles/release && \ + cp /home/${USERNAME}/.conan2/profiles/default /home/${USERNAME}/.conan2/profiles/debug && \ + sed -i 's/^build_type=.*/build_type=Release/' /home/${USERNAME}/.conan2/profiles/release && \ + sed -i 's/^build_type=.*/build_type=Debug/' /home/${USERNAME}/.conan2/profiles/debug -FROM apt-build as apt-dev - -# Remove ubuntu user and add celixdev with sudo rights and a "celixdev" password -RUN userdel -r ubuntu && \ - groupadd --gid 1000 celixdev && \ - useradd --uid 1000 --gid 1000 -m \ - -s /bin/bash -G sudo celixdev && \ - echo "%sudo ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \ - echo "celixdev:celixdev" | chpasswd -USER celixdev -WORKDIR /home/celixdev +FROM base as conan-dev -#Install development dependencies -RUN sudo DEBIAN_FRONTEND="noninteractive" apt-get update && \ - sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ - gnupg2 dos2unix git locales-all rsync tar ssh tzdata sudo vim openssh-server cmake-curses-gui gdb \ +RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ + gnupg2 dos2unix locales-all ssh rsync tar tzdata sudo vim cmake-curses-gui gdb \ wget curl && \ - sudo apt-get clean - -RUN sudo mkdir /run/sshd + apt-get clean \ diff --git a/.devcontainer/README.md b/.devcontainer/README.md index f521d8c29..597bf71da 100644 --- a/.devcontainer/README.md +++ b/.devcontainer/README.md @@ -21,49 +21,51 @@ limitations under the License. This directory contains a [DevContainer](https://containers.dev) setup for developing Apache Celix inside a container. -Although Apache Celix can be built using CMake with APT-installed dependencies or Conan with Conan-installed/built -dependencies, this DevContainer setup currently only supports Conan. +Although Apache Celix can be built using CMake with APT-installed dependencies or Conan +with Conan-installed/built dependencies, this DevContainer setup is based on Conan. Please note, the DevContainer setup is not broadly tested and might not work on all systems. -It has been tested on Ubuntu 23.10 and Fedora 40. +It has been tested on MacOS 26 and Fedora 43, using podman. + +## Mounts + +The devcontainer uses the following container volumes to ensure dependency build and project +building is more efficient, even after recreating a devcontainer: + +- celixdev-conan-package-cache +- celixdev-conan-download-cache +- celixdev-ccache-cache + +Use `podman volume rm` / `docker volume rm` to remove the volumes if you do no longer use them. ## VSCode Usage VSCode has built-in support for DevContainers. -Simply launch VSCode using the Celix workspace folder, and you will be prompted to open the workspace in a container. +Launch VSCode using the Celix workspace folder, and you will be prompted to +open the workspace in a container. -VSCode ensures that your host `.gitconfig` file, `.gnupg` directory, and SSH agent forwarding are available in the -container. +VSCode ensures that your host `.gitconfig` file and SSH agent forwarding +are available in the container. ## CLion Usage -At the time of writing this readme, CLion does not fully support DevContainers, -but there is some support focusing on Docker. Using a container and remote development via SSH with CLion works. +CLion 2025.3.1 includes DevContainer support (including Podman), so you can open this repository directly +using the IDE's DevContainer workflow. Once the container is built, enable and select the conan-debug (generated) +profile. -To start developing in a container with build a CevContainer image using the `build-devcontainer-image.sh` script -and then start a container with SSHD running and interactively set up `.gitconfig`, `.gnupg`, and SSH agent -forwarding, using the `.devcontainer/run-dev-container.sh` script: +## Building -```bash -cd ${CELIX_ROOT} -./.devcontainer/build-devcontainer-image.sh -./.devcontainer/run-devcontainer.sh -ssh -p 2233 celixdev@localhost -``` +Build can be done from the root workspace dir: -In CLion, open the Remote Development window by navigating to "File -> Remote Development..." and add a new -configuration. When a new configuration is added, you can start a new project using `/home/celixdev/workspace` as the -project root and selecting CLion as the IDE. - -Also ensure the CMake profile from the - conan generated - `CMakeUserPresets.json` is used: Enable the profile in the -Settings -> "Build, Execution, Deployment" -> CMake menu. +```shell +cmake --build build --parallel +``` ## Running tests + Tests can be run using ctest. -When building with conan, the conanrun.sh script will setup the environment for the -built dependencies. To run the tests, execute the following commands: +When building with Conan, run tests from the build directory after configuring/building: ```shell -cd build -ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh +ctest --output-on-failure --test-dir build ``` diff --git a/.devcontainer/build-devcontainer-image.sh b/.devcontainer/build-devcontainer-image.sh deleted file mode 100755 index 65641c574..000000000 --- a/.devcontainer/build-devcontainer-image.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")") -CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..") -IMAGE_TARGET="${1:-conan-dev}" - -# Check which container engine is available. -# Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command. -if command -v podman > /dev/null 2>&1; then - CONTAINER_ENGINE="podman" -else - CONTAINER_ENGINE="docker" -fi - -cd "${SCRIPT_LOCATION}" -${CONTAINER_ENGINE} build -t apache/celix-${IMAGE_TARGET} -f Containerfile --target ${IMAGE_TARGET} . diff --git a/.devcontainer/build-project-with-conan.sh b/.devcontainer/build-project-with-conan.sh deleted file mode 100755 index d9819dec1..000000000 --- a/.devcontainer/build-project-with-conan.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -conan build . --profile debug \ - --options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True \ - --options celix/*:enable_testing=True --options celix/*:enable_ccache=True \ - --conf:build tools.cmake.cmaketoolchain:generator=Ninja \ - --output-folder build diff --git a/.devcontainer/conan-container-debug-profile b/.devcontainer/conan-container-debug-profile deleted file mode 100644 index c10d4ab7a..000000000 --- a/.devcontainer/conan-container-debug-profile +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#Based on gcc from ubuntu:24.04 base image -[settings] -arch=x86_64 -build_type=Debug -compiler=gcc -compiler.cppstd=17 -compiler.libcxx=libstdc++11 -compiler.version=13 -os=Linux diff --git a/.devcontainer/conan-container-default-profile b/.devcontainer/conan-container-default-profile deleted file mode 100644 index 93ca74d75..000000000 --- a/.devcontainer/conan-container-default-profile +++ /dev/null @@ -1,26 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -#Based on gcc from ubuntu:24.04 base image -[settings] -arch=x86_64 -build_type=Release -compiler=gcc -compiler.cppstd=17 -compiler.libcxx=libstdc++11 -compiler.version=13 -os=Linux diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7c9ee3307..caa694801 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,12 +4,41 @@ "dockerfile": "Containerfile", "target": "conan-dev" }, - "runArgs" : [ + "runArgs": [ "--userns=keep-id" ], - "securityOpt":["label=disable"], + "mounts": [ + "type=volume,source=celixdev-conan-package-cache,target=/home/celixdev/.conan2/p", + "type=volume,source=celixdev-conan-download-cache,target=/home/celixdev/.conan2/d", + "type=volume,source=celixdev-ccache-cache,target=/home/celixdev/.ccache" + ], + "containerEnv": { + "CONAN_PROFILE": "debug", + "CONAN_OUT": "build", + "CONAN_OPTS": "--options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True --options celix/*:enable_testing=True --options celix/*:enable_ccache=True --options celix/*:enable_code_coverage=True", + "CONAN_CONF": "--conf tools.cmake.cmaketoolchain:generator=Ninja" + }, + "securityOpt": [ + "label=disable" + ], "remoteUser": "celixdev", "containerUser": "celixdev", - "onCreateCommand": "sh .devcontainer/setup-project-with-conan.sh", - "postCreateCommand": "sh .devcontainer/build-project-with-conan.sh" + "postCreateCommand": "conan install . --build missing --profile ${CONAN_PROFILE} ${CONAN_OPTS} ${CONAN_CONF} --output-folder ${CONAN_OUT} && cmake --preset conan-debug", + "features": { + "ghcr.io/devcontainers/features/git:1": {}, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-vscode.cpptools-extension-pack", + "ms-vscode.cpptools", + "matepek.vscode-catch2-test-adapter", + "ms-vscode.cmake-tools" + ] + }, + "jetbrains": { + "backend": "CLion" + } + } } diff --git a/.devcontainer/run-devcontainer.sh b/.devcontainer/run-devcontainer.sh deleted file mode 100755 index 7af6b7a6d..000000000 --- a/.devcontainer/run-devcontainer.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -# Start a Celix dev container with all needed dependencies -# pre-installed already. - -SCRIPT_LOCATION=$(realpath "$(dirname "${BASH_SOURCE[0]}")") -CELIX_REPO_ROOT=$(realpath "${SCRIPT_LOCATION}/..") -CELIX_CONTAINER_ROOT="/home/celixdev/workspace" - -CONTAINER_SSH_PORT=2233 -CONTAINER_COMMAND_DEFAULT="sudo chown -R celixdev:celixdev ${CELIX_CONTAINER_ROOT} && sudo /usr/sbin/sshd -D -e -p ${CONTAINER_SSH_PORT}" -CONTAINER_COMMAND=${1:-${CONTAINER_COMMAND_DEFAULT}} -CONTAINER_NAME="celixdev" - -# Check which container engine is available. -# Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command. -if command -v podman > /dev/null 2>&1; then - CONTAINER_ENGINE="podman" -else - CONTAINER_ENGINE="docker" -fi - -ask_and_execute() { - local QUESTION="$1" - local FUNC_NAME="$2" - - # Prompt the user with the question - while true; do - read -p "${QUESTION} (yes/no): " yn - case $yn in - [Yy]* ) - # Call the provided function if the answer is yes - ${FUNC_NAME} - echo "" - break;; - [Nn]* ) - # Exit if the answer is no - break;; - * ) - echo "Please answer yes or no.";; - esac - done -} - -remove_celixdev_container() { - echo "Removing container '${CONTAINER_NAME}'" - ${CONTAINER_ENGINE} rm -f ${CONTAINER_NAME} -} -# Check if container celixdev already exists -if [ "$(${CONTAINER_ENGINE} ps -a --format '{{.Names}}' | grep ${CONTAINER_NAME})" ]; then - ask_and_execute "Container '${CONTAINER_NAME}' already exists. Do you want to remove it?" remove_celixdev_container -fi - -# Check again if container celixdev already exists and exit if it does -if [ "$(${CONTAINER_ENGINE} ps -a --format '{{.Names}}' | grep ${CONTAINER_NAME})" ]; then - echo "Container '${CONTAINER_NAME}' already exists. Exiting." - exit 1 -fi - -ADDITIONAL_ARGS="" - -GNUPG_DIR_MOUNTED=false -add_gnupg_mount() { - echo "Adding .gnupg directory mount arguments" - ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume ${HOME}/.gnupg:/home/celixdev/.gnupg:O" - GNUPG_DIR_MOUNTED=true -} -if [ -e "${HOME}/.gnupg" ]; then - ask_and_execute "Do you want to mount the .gnupg directory to the container (as an overlayfs)?" add_gnupg_mount -fi - -add_gitconfig_mount() { - echo "Adding .gitconfig file mount arguments" - ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume ${HOME}/.gitconfig:/home/celixdev/.gitconfig:ro" -} -if [ -e "${HOME}/.gitconfig" ]; then - ask_and_execute "Do you want to mount the .gitconfig file to the container (as read-only)?" add_gitconfig_mount -fi - -add_sshagent_forward() -{ - echo "Adding SSH agent forwarding" - ADDITIONAL_ARGS="${ADDITIONAL_ARGS} --volume ${SSH_AUTH_SOCK}:/ssh-agent --env SSH_AUTH_SOCK=/ssh-agent" -} -if [ -n "${SSH_AUTH_SOCK}" ]; then - ask_and_execute "Do you want to forward the SSH agent to the container?" add_sshagent_forward -fi - -# Start a container with all the Celix dependencies pre-installed -# --userns=keep-id is used to keep the user id the same in the container as on the host -# --privileged to allow the unit tests to change thread priorities -# -d runs the container in detached mode -# -it starts the container in interactive mode -# --rm removes the container when it is stopped -# --net=host is used to allow e.g. communication with etcd -# --volume & --workdir are set to the Celix repo root (to allow building and editing of the Celix repo) -# --security-opt disables SELinux for the container -echo "Starting container '${CONTAINER_NAME}' with command: ${CONTAINER_COMMAND}" -${CONTAINER_ENGINE} run -it --rm --privileged -d \ - --name ${CONTAINER_NAME} \ - --userns=keep-id \ - --net=host \ - ${ADDITIONAL_ARGS} \ - --volume "${CELIX_REPO_ROOT}":${CELIX_CONTAINER_ROOT} \ - --workdir "${CELIX_CONTAINER_ROOT}" \ - --security-opt label=disable \ - apache/celix-conan-dev:latest bash -c "${CONTAINER_COMMAND}" -echo "" - -build_conan_deps() { - echo "Building Celix dependencies with Conan" - ${CONTAINER_ENGINE} exec -it ${CONTAINER_NAME} bash -c "cd ${CELIX_CONTAINER_ROOT} && .devcontainer/setup-project-with-conan.sh" -} -ask_and_execute "Do you want to build Celix dependencies with Conan?" build_conan_deps - -echo "Done. You can connect with ssh using 'ssh -p 2233 celixdev@localhost' and password 'celixdev'" diff --git a/.devcontainer/setup-project-with-apt.sh b/.devcontainer/setup-project-with-apt.sh deleted file mode 100755 index 403fb7379..000000000 --- a/.devcontainer/setup-project-with-apt.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -BUILD_TYPE=${1:-Debug} -LC_BUILD_TYPE=$(echo ${BUILD_TYPE} | tr '[:upper:]' '[:lower:]') - -mkdir -p cmake-build-${LC_BUILD_TYPE} - -cmake -S . \ - -G Ninja \ - -B cmake-build-${LC_BUILD_TYPE} \ - -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ - -DCMAKE_INSTALL_PREFIX=/tmp/celix-install \ - -DENABLE_TESTING=ON \ - -DENABLE_ADDRESS_SANITIZER=ON \ - -DRSA_JSON_RPC=ON \ - -DRSA_SHM=ON \ - -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON - -cmake --build cmake-build-${LC_BUILD_TYPE} --parallel diff --git a/.devcontainer/setup-project-with-conan.sh b/.devcontainer/setup-project-with-conan.sh deleted file mode 100755 index 0a9539997..000000000 --- a/.devcontainer/setup-project-with-conan.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -mkdir build - -conan install . --build missing --profile debug \ - --options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True \ - --options celix/*:enable_testing=True --options celix/*:enable_ccache=True \ - --conf:build tools.cmake.cmaketoolchain:generator=Ninja \ - --output-folder build diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index a47c1a197..6254fec1d 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -14,7 +14,7 @@ jobs: - name: Cache Conan uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2 with: - path: ~/.conan2-container + path: ~/.conan2-container-package-cache key: cache-conan-container-${{ runner.os }}-${{ github.job }}-${{ hashFiles('conanfile.py', '.devcontainer/*') }} restore-keys: cache-conan-container-${{ runner.os }}-${{ github.job }}- - name: Cache ccache @@ -27,68 +27,31 @@ jobs: run: | cd .devcontainer && \ docker build --tag apache/celix-conan-build:latest --target conan-build --file Containerfile . - - name: Build Celix dependencies - run: | #Using .conan2-container so that the steps can be reproduced locally without affecting the host conan - mkdir -p ~/.conan2-container/profiles && \ - cp .devcontainer/conan-container-default-profile ~/.conan2-container/profiles/default && \ - cp .devcontainer/conan-container-debug-profile ~/.conan2-container/profiles/debug && \ - docker run --rm -v ~/.conan2-container:/root/.conan2 -v $(pwd):/workspace \ - apache/celix-conan-build:latest /bin/bash -c \ - "cd /workspace && \ - conan install . --build missing --profile debug \ - --options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True \ - --options celix/*:enable_testing=True --options celix/*:enable_ccache=True \ - --conf:build tools.cmake.cmaketoolchain:generator=Ninja \ - --output-folder build" - name: Build Celix run: | - mkdir -p ~/.ccache-container && \ - docker run --rm -v ~/.conan2-container:/root/.conan2 -v ~/.ccache-container:/root/.ccache \ - -v $(pwd):/workspace apache/celix-conan-build:latest /bin/bash -c \ - "cd /workspace && \ - conan build . --profile debug \ + mkdir -p ~/.conan2-container-package-cache + chmod -R 777 ~/.conan2-container-package-cache + mkdir -p ~/.ccache-container + chmod -R 777 ~/.ccache-container + chmod -R 777 ${GITHUB_WORKSPACE} + docker run --rm \ + -v ~/.conan2-container-package-cache:/home/celixdev/.conan2/p \ + -v ~/.ccache-container:/bome/celixdev/.ccache \ + -v $(pwd):/home/celixdev/workspace apache/celix-conan-build:latest /bin/bash -c \ + "cd /home/celixdev/workspace && \ + conan build . --profile debug --build=missing \ --options celix/*:build_all=True --options celix/*:enable_address_sanitizer=True \ --options celix/*:enable_testing=True --options celix/*:enable_ccache=True \ --conf:build tools.cmake.cmaketoolchain:generator=Ninja \ --output-folder build" - name: Test Celix run: | - docker run --rm -v ~/.conan2-container:/root/.conan2 -v $(pwd):/workspace \ - apache/celix-conan-build:latest /bin/bash -c \ - "cd /workspace/build && \ + docker run --rm \ + -v ~/.conan2-container-package-cache:/home/celixdev/.conan2/p \ + -v $(pwd):/home/celixdev/workspace apache/celix-conan-build:latest /bin/bash -c \ + "cd /home/celixdev/workspace/build && \ source conanrun.sh && \ - ctest --output-on-failure" - - container-apt-build-ubuntu: - runs-on: ubuntu-22.04 - timeout-minutes: 120 - steps: - - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 - - name: Build container image - run: | - cd .devcontainer && \ - docker build --tag apache/celix-apt-build:latest --target apt-build --file Containerfile . - - name: Cache ccache - uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf #v4.2.2 - with: - path: ~/.ccache-container - key: cache-ccache-container-${{ runner.os }}-${{ github.job }}-${{ github.sha }} - restore-keys: cache-ccache-container-${{ runner.os }}-${{ github.job }}- - - name: Build Celix - run: | - docker run --rm -v ~/.ccache-container:/root/.ccache -v $(pwd):/workspace \ - apache/celix-apt-build:latest /bin/bash -c \ - "mkdir /workspace/build && cd /workspace/build && \ - cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_EXPERIMENTAL=ON -DENABLE_TESTING=ON -DRSA_JSON_RPC=ON \ - -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON -DENABLE_CCACHE=ON .. && \ - make -j" - - name: Test Celix - run: | - docker run --rm -v $(pwd):/workspace apache/celix-apt-build:latest /bin/bash -c \ - "cd /workspace/build && \ - ctest --output-on-failure" - + ctest --output-on-failure" build-dev-container-images: runs-on: ubuntu-22.04 timeout-minutes: 120 @@ -98,5 +61,4 @@ jobs: - name: Build dev container images run: | cd .devcontainer && \ - docker build --tag apache/celix-conan-dev:latest --target conan-dev --file Containerfile . && \ - docker build --tag apache/celix-apt-dev:latest --target apt-dev --file Containerfile . + docker build --tag apache/celix-conan-dev:latest --target conan-dev --file Containerfile .
