This is an automated email from the ASF dual-hosted git repository. pengzheng pushed a commit to branch revert-731-feature/devcontainer in repository https://gitbox.apache.org/repos/asf/celix.git
commit ecd5db129d2981f1e258fd4ba716377348af9ec5 Author: PengZheng <[email protected]> AuthorDate: Sat Jan 11 21:39:49 2025 +0800 Revert "Feature/devcontainer" --- .devcontainer/Containerfile | 127 -------------------- .devcontainer/README.md | 69 ----------- .devcontainer/build-project-with-conan.sh | 24 ---- .devcontainer/conan-container-default-profile | 26 ---- .devcontainer/devcontainer.json | 15 --- .devcontainer/run-devcontainer.sh | 133 --------------------- .devcontainer/setup-project-with-apt.sh | 36 ------ .devcontainer/setup-project-with-conan.sh | 26 ---- .github/workflows/celix_etcdlib.yml | 2 +- .github/workflows/celix_promise.yml | 2 +- .github/workflows/conan_create.yml | 14 +-- .github/workflows/containers.yml | 98 +++------------ .github/workflows/coverage.yml | 6 +- .github/workflows/coverity-scan.yml | 2 +- .github/workflows/macos.yml | 10 +- .github/workflows/ubuntu.yml | 12 +- README.md | 2 +- .../discovery_zeroconf/gtest/CMakeLists.txt | 2 +- .../src/DiscoveryZeroconfAnnouncerTestSuite.cc | 4 +- .../gtest/src/DiscoveryZeroconfWatcherTestSuite.cc | 10 +- conanfile.py | 1 - container/Containerfile.gitpod | 61 ++++++++++ container/Containerfile.ubuntu | 71 +++++++++++ container/README.md | 55 +++++++++ .../build-ubuntu-container.sh | 5 +- .../run-ubuntu-container.sh | 20 +++- .../support-scripts/build-all.sh | 25 ++-- documents/development/README.md | 3 +- examples/conan_test_package/CMakeLists.txt | 13 -- examples/conan_test_package/conanfile.py | 1 - examples/conan_test_package_v2/conanfile.py | 1 - 31 files changed, 274 insertions(+), 602 deletions(-) diff --git a/.devcontainer/Containerfile b/.devcontainer/Containerfile deleted file mode 100644 index 622f1fd2b..000000000 --- a/.devcontainer/Containerfile +++ /dev/null @@ -1,127 +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. - -FROM docker.io/library/ubuntu:24.04@sha256:2e863c44b718727c860746568e1d54afd13b2fa71b160f5cd9058fc436217b30 as build - -# Install dependencies -RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ - DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ - build-essential \ - ccache \ - cmake \ - gcc \ - g++ \ - make \ - zip \ - ninja-build \ - 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 - -# 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 \ - rapidjson-dev \ - uuid-dev && \ - sudo apt-get clean - -#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 - -# 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 - -#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 - -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 - -#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 diff --git a/.devcontainer/README.md b/.devcontainer/README.md deleted file mode 100644 index f521d8c29..000000000 --- a/.devcontainer/README.md +++ /dev/null @@ -1,69 +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. ---> - -# Apache Celix Development Container - -## Introduction - -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. - -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. - -## 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. - -VSCode ensures that your host `.gitconfig` file, `.gnupg` directory, 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. - -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: - -```bash -cd ${CELIX_ROOT} -./.devcontainer/build-devcontainer-image.sh -./.devcontainer/run-devcontainer.sh -ssh -p 2233 celixdev@localhost -``` - -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. - -## 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: - -```shell -cd build -ctest --output-on-failure --test-command ./workspaces/celix/build/conanrun.sh -``` 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-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 deleted file mode 100644 index 7c9ee3307..000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "Apache Celix Dev Container", - "build": { - "dockerfile": "Containerfile", - "target": "conan-dev" - }, - "runArgs" : [ - "--userns=keep-id" - ], - "securityOpt":["label=disable"], - "remoteUser": "celixdev", - "containerUser": "celixdev", - "onCreateCommand": "sh .devcontainer/setup-project-with-conan.sh", - "postCreateCommand": "sh .devcontainer/build-project-with-conan.sh" -} diff --git a/.devcontainer/run-devcontainer.sh b/.devcontainer/run-devcontainer.sh deleted file mode 100755 index 9c36d9a3e..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 /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}:Z \ - --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/celix_etcdlib.yml b/.github/workflows/celix_etcdlib.yml index 9648fb189..cda0a6350 100644 --- a/.github/workflows/celix_etcdlib.yml +++ b/.github/workflows/celix_etcdlib.yml @@ -12,7 +12,7 @@ jobs: timeout-minutes: 15 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install dependencies run: | sudo apt-get update diff --git a/.github/workflows/celix_promise.yml b/.github/workflows/celix_promise.yml index 7e85fee9d..6b7706dd7 100644 --- a/.github/workflows/celix_promise.yml +++ b/.github/workflows/celix_promise.yml @@ -12,7 +12,7 @@ jobs: timeout-minutes: 15 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install dependencies run: | sudo apt-get update diff --git a/.github/workflows/conan_create.yml b/.github/workflows/conan_create.yml index aa4e4f433..84ea1d014 100644 --- a/.github/workflows/conan_create.yml +++ b/.github/workflows/conan_create.yml @@ -26,7 +26,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install build dependencies run: | sudo pip install -U conan @@ -41,7 +41,7 @@ jobs: sed -i 's/compiler.cppstd=gnu14/compiler.cppstd=gnu17/g' `conan profile path default` - name: Conan Cache id: cache-conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 env: cache-name: cache-conan2-modules with: @@ -53,7 +53,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-ccache-${{ matrix.compiler[0] }}-${{ matrix.type }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -80,7 +80,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install build dependencies run: | brew install python ninja @@ -90,7 +90,7 @@ jobs: conan profile detect -f - name: Conan Cache id: cache-conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 env: cache-name: cache-conan2-modules with: @@ -102,7 +102,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-ccache-Release-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -110,7 +110,7 @@ jobs: ${{ runner.os }}-ccache-Release- - name: Create Celix run: | - conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True -o celix/*:enable_address_sanitizer=True + conan create . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:build_all=True -o celix/*:enable_ccache=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -tf examples/conan_test_package_v2 -o celix/*:celix_cxx17=True -o celix/*:celix_install_deprecated_api=True - name: Dependency Deduction Test run: | conan inspect . | awk 'BEGIN { FS="[\t:]+"; output=0 } /build/ && !/build_all/ && !/build_rsa_remote_service_admin_shm_v2/ && !/build_rsa_discovery_zeroconf/ { if(output) print $1} /^options/ {output=1} /^options_definitions/ {output=0}' | while read option; do conan build . -c tools.cmake.cmaketoolchain:generator=Ninja -b missing -o celix/*:${option}=True -pr:b default -pr:h default -s:b build_type=Release -s:h build_type=Release -of ${option}_dir -o celix/*:celix_cxx17=Tru [...] diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml index 570609998..95b92edae 100644 --- a/.github/workflows/containers.yml +++ b/.github/workflows/containers.yml @@ -1,102 +1,38 @@ -name: Celix Containers +name: Celix development containers on: push: pull_request: + schedule: + - cron: '0 0 * * 0' # Weekly on Sunday at 00:00 UTC jobs: - container-conan-build-ubuntu: + container-build-ubuntu: runs-on: ubuntu-22.04 timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 - - name: Cache Conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 - with: - path: ~/.conan2-container - key: cache-conan-container-${{ runner.os }}-${{ github.job }}-${{ hashFiles('conanfile.py', '.devcontainer/*') }} - restore-keys: cache-conan-container-${{ runner.os }}-${{ github.job }}- - - name: Cache ccache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 - with: - path: ~/.ccache-container - key: cache-ccache-container-${{ runner.os }}-${{ github.job }}-${{ github.sha }} - restore-keys: cache-ccache-container-${{ runner.os }}-${{ github.job }}- + uses: actions/[email protected] - name: Build container image 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 + cd $GITHUB_WORKSPACE/container/ + ./build-ubuntu-container.sh + - name: Build Celix using container image 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 \ - --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 + cd $GITHUB_WORKSPACE/container/ + ./run-ubuntu-container.sh "mkdir -p build && cd build && ../container/support-scripts/build-all.sh && make -j" + - name: Run Celix tests using container image run: | - docker run --rm -v ~/.conan2-container:/root/.conan2 -v $(pwd):/workspace \ - apache/celix-conan-build:latest /bin/bash -c \ - "cd /workspace/build && \ - source conanrun.sh && \ - ctest --output-on-failure" + cd $GITHUB_WORKSPACE/container/ + ./run-ubuntu-container.sh "cd build && ctest --output-on-failure" - container-apt-build-ubuntu: + container-build-gitpod: runs-on: ubuntu-22.04 timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - 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@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 - 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" - - build-dev-container-images: - runs-on: ubuntu-22.04 - timeout-minutes: 120 - steps: - - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 - - 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 . + cd $GITHUB_WORKSPACE/container/ + docker build -t apache/celix-dev:gitpod-latest -f Containerfile.gitpod . diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index b3dd3c747..19665f19b 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -15,7 +15,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install conan and lcov run: | sudo apt-get install -yq --no-install-recommends lcov @@ -28,7 +28,7 @@ jobs: conan profile update settings.compiler.libcxx=libstdc++11 default - name: Conan Cache id: cache-conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 env: cache-name: cache-conan2-modules with: @@ -40,7 +40,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-gcov-ccache-${{ steps.ccache_cache_timestamp.outputs.timestamp }} diff --git a/.github/workflows/coverity-scan.yml b/.github/workflows/coverity-scan.yml index bb07bafd3..25d0191a3 100644 --- a/.github/workflows/coverity-scan.yml +++ b/.github/workflows/coverity-scan.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install dependencies run: | sudo apt-get update diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 10724134f..2e11482dd 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -20,7 +20,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install conan run: | brew install python ninja @@ -30,7 +30,7 @@ jobs: conan profile detect -f - name: Conan Cache id: cache-conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 env: cache-name: cache-conan2-modules with: @@ -42,7 +42,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-test-ccache-Release-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -72,7 +72,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install dependencies run: | brew install lcov jansson rapidjson libzip ccache ninja [email protected] @@ -81,7 +81,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-brew-test-ccache-Release-${{ steps.ccache_cache_timestamp.outputs.timestamp }} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 30a8f3bde..6a1079536 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -25,7 +25,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install build dependencies run: | sudo pip install -U conan==1.62.0 @@ -49,7 +49,7 @@ jobs: conan profile show default - name: Conan Cache id: cache-conan - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 env: cache-name: cache-conan2-modules with: @@ -61,7 +61,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-test-ccache-${{ matrix.compiler[0] }}-${{ matrix.type }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} @@ -80,7 +80,7 @@ jobs: -o celix:framework_curlinit=False -o celix:enable_ccache=True run: | - conan install . celix/ci -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing + conan install . celix/ci -c tools.cmake.cmaketoolchain:generator=Ninja -pr:b release -pr:h default -if build ${CONAN_BUILD_OPTIONS} -b missing --require-override=openssl/1.1.1s - name: Build env: CC: ${{ matrix.compiler[0] }} @@ -104,7 +104,7 @@ jobs: timeout-minutes: 120 steps: - name: Checkout source code - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c #v3.3.0 + uses: actions/[email protected] - name: Install dependencies run: | sudo apt-get update @@ -130,7 +130,7 @@ jobs: run: | echo timestamp=`date +"%Y-%m-%d-%H;%M;%S"` >> $GITHUB_OUTPUT - name: ccache Cache - uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c #v3 + uses: actions/cache@v3 with: path: ${{ env.CCACHE_DIR }} key: ${{ runner.os }}-apt-test-ccache-gcc-${{ matrix.type }}-${{ steps.ccache_cache_timestamp.outputs.timestamp }} diff --git a/README.md b/README.md index 228e9a413..dc7528a2c 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ limitations under the License.  [](https://codecov.io/gh/apache/celix) [](https://scan.coverity.com/projects/6685) -[](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/apache/celix) +[](https://gitpod.io/#https://github.com/apache/celix) Apache Celix is a framework for C and C++14 to develop dynamic modular software applications using component and in-process service-oriented programming. diff --git a/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt b/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt index ad9dddb7b..6581e573e 100644 --- a/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt +++ b/bundles/remote_services/discovery_zeroconf/gtest/CMakeLists.txt @@ -76,6 +76,6 @@ if (EI_TESTS) target_compile_definitions(unit_test_discovery_zeroconf PRIVATE -DMDNSD="${DNSSD_INCLUDE_DIR}/../bin/mdnsd") - add_test(NAME run_unit_test_discovery_zeroconf COMMAND unit_test_discovery_zeroconf) + add_test(NAME run_unit_test_discovery_zeroconf COMMAND sudo $<TARGET_FILE:unit_test_discovery_zeroconf>) setup_target_for_coverage(unit_test_discovery_zeroconf SCAN_DIR ..) endif () \ No newline at end of file diff --git a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc index f412e34d7..2f322a782 100644 --- a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc +++ b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfAnnouncerTestSuite.cc @@ -53,11 +53,11 @@ static int GetLoopBackIfIndex(void); class DiscoveryZeroconfAnnouncerTestSuite : public ::testing::Test { public: static void SetUpTestCase() { - (void)system("sudo " MDNSD); + (void)system(MDNSD); } static void TearDownTestCase() { - (void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); + (void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); } DiscoveryZeroconfAnnouncerTestSuite() { auto* props = celix_properties_create(); diff --git a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfWatcherTestSuite.cc b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfWatcherTestSuite.cc index c8929b8c0..cfa023115 100644 --- a/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfWatcherTestSuite.cc +++ b/bundles/remote_services/discovery_zeroconf/gtest/src/DiscoveryZeroconfWatcherTestSuite.cc @@ -127,11 +127,11 @@ static int GetTestNetInterfaceIndex() { class DiscoveryZeroconfWatcherTestSuite : public ::testing::Test { public: static void SetUpTestCase() { - (void)system("sudo " MDNSD); + (void)system(MDNSD); } static void TearDownTestCase() { - (void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); + (void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); } DiscoveryZeroconfWatcherTestSuite() { @@ -342,7 +342,7 @@ public: class DiscoveryZeroconfWatcherWatchServiceTestSuite : public DiscoveryZeroconfWatcherTestSuite { public: static void SetUpTestCase() { - (void)system("sudo " MDNSD); + (void)system(MDNSD); sleep(3);//wait for mdnsd start testServiceRef = RegisterTestService(GetTestNetInterfaceIndex()); EXPECT_TRUE(testServiceRef != nullptr); @@ -350,7 +350,7 @@ public: static void TearDownTestCase() { DNSServiceRefDeallocate(testServiceRef); - (void)system("sudo kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); + (void)system("kill -s 9 `ps -aux | grep mdnsd | awk '{print $2}'`"); } DiscoveryZeroconfWatcherWatchServiceTestSuite() { @@ -747,10 +747,12 @@ TEST_F(DiscoveryZeroconfWatcherTestSuite, BrowseServicesFailed1) { celix_status_t status = discoveryZeroconfWatcher_create(ctx.get(), logHelper.get(), &watcher); EXPECT_EQ(CELIX_SUCCESS, status); + auto rsaTrkId = TrackRsaService(watcher); auto timeOut = CheckMsgWithTimeOutInS(30); EXPECT_FALSE(timeOut); + celix_bundleContext_stopTracker(ctx.get(), rsaTrkId); discoveryZeroconfWatcher_destroy(watcher); } diff --git a/conanfile.py b/conanfile.py index cfce0de63..de23229d9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -351,7 +351,6 @@ class CelixConan(ConanFile): # https://github.com/conan-io/conan-center-index/pull/16254 self.requires("mdnsresponder/1310.140.1") # 'libzip/1.10.1' requires 'zlib/1.2.13' while 'libcurl/7.64.1' requires 'zlib/1.2.12' - self.requires("openssl/[>=3.2.0]", override=True) self.requires("zlib/1.2.13", override=True) if self.options.build_event_admin_remote_provider_mqtt: self.requires("mosquitto/[>=2.0.3 <3.0.0]") diff --git a/container/Containerfile.gitpod b/container/Containerfile.gitpod new file mode 100644 index 000000000..a9591d251 --- /dev/null +++ b/container/Containerfile.gitpod @@ -0,0 +1,61 @@ +# 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. + +FROM docker.io/gitpod/workspace-full:2023-10-06-16-22-14@sha256:76d3041cc7a2caa00d6f4610ace0e15009c361515f3d5d9ee6690e4019adcfd4 + +# Switch to root user to install dependencies and configure sshd +USER root + +# Install dependencies +RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ + # Development dependencies \ + dos2unix \ + git \ + locales-all \ + rsync \ + tar \ + ssh \ + tzdata \ + # Build dependencies \ + build-essential \ + ccache \ + cmake \ + curl \ + default-jdk \ + gcc \ + g++ \ + gdb \ + make \ + python3 \ + # Celix dependencies \ + civetweb \ + libavahi-compat-libdnssd-dev \ + libcivetweb-dev \ + libcpputest-dev \ + libcurl4-openssl-dev \ + libczmq-dev \ + libffi-dev \ + libjansson-dev \ + libxml2-dev \ + libzip-dev \ + rapidjson-dev \ + uuid-dev && \ + apt-get clean + +# Switch back to the (default) gitpod user +USER gitpod diff --git a/container/Containerfile.ubuntu b/container/Containerfile.ubuntu new file mode 100644 index 000000000..af732e059 --- /dev/null +++ b/container/Containerfile.ubuntu @@ -0,0 +1,71 @@ +# 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. + +# SSH credentials: +# root@password + +FROM docker.io/library/ubuntu:22.04@sha256:b492494d8e0113c4ad3fe4528a4b5ff89faa5331f7d52c5c138196f69ce176a6 + +# Install dependencies +RUN DEBIAN_FRONTEND="noninteractive" apt-get update && \ + DEBIAN_FRONTEND="noninteractive" apt-get install -y --no-install-recommends \ + # Development dependencies \ + dos2unix \ + git \ + locales-all \ + rsync \ + tar \ + ssh \ + tzdata \ + # Build dependencies \ + build-essential \ + ccache \ + cmake \ + curl \ + default-jdk \ + gcc \ + g++ \ + gdb \ + make \ + python3 \ + # Celix dependencies \ + civetweb \ + libavahi-compat-libdnssd-dev \ + libcivetweb-dev \ + libcpputest-dev \ + libcurl4-openssl-dev \ + libczmq-dev \ + libffi-dev \ + libjansson-dev \ + libxml2-dev \ + libzip-dev \ + rapidjson-dev \ + uuid-dev && \ + apt-get clean + +RUN ( \ + echo 'Port 2233'; \ + echo 'LogLevel INFO'; \ + echo 'PermitRootLogin yes'; \ + echo 'PasswordAuthentication yes'; \ + echo 'Subsystem sftp /usr/lib/openssh/sftp-server'; \ + ) > /etc/ssh/sshd_config_celix \ + && mkdir /run/sshd + +RUN yes password | passwd root + +CMD ["/usr/sbin/sshd", "-D", "-e", "-f", "/etc/ssh/sshd_config_celix"] diff --git a/container/README.md b/container/README.md new file mode 100644 index 000000000..1d24de756 --- /dev/null +++ b/container/README.md @@ -0,0 +1,55 @@ +# Celix dev container usage + +This subdirectory contains a [Gitpod Containerfile](./Containerfile.gitpod) for developing on Celix using [Gitpod](https://gitpod.io/#https://github.com/apache/celix) +and a [Ubuntu Containerfile](./Containerfile.ubuntu) for local development on Celix. + +The below steps only need to be executed if you want to develop locally, and not via Gitpod. + +## Build the celix-dev image yourself + +To always be able to develop on Celix with an up-to-date image, built the image yourself. + +```bash +./container/build-ubuntu-container.sh +``` + +## Using the image + +### Start locally with SSH daemon + +```bash +cd <project-root> + +# Start a local container with the SSH daemon running +./container/run-ubuntu-container.sh +``` + +Now connect to the container via the remote container option of your favoured IDE and start building/developing. + +For example, you can now start with: + +* CLion connected to the container using [JetBrains Gateway](https://www.jetbrains.com/help/clion/remote-development-a.html) +* CLion configured to connect to the container as [Remote Host](https://www.jetbrains.com/help/clion/remote-projects-support.html) + +When finished with development and testing, press `CTRL + \` to stop the SSH daemon and exit the container. + +### Start locally with only a bash shell + +The start script allows passing of additional parameters, which will override the starting of the SSH daemon. +Execute the following commands to open a bash shell and build Celix from the command line: + +```bash +cd <project-root> + +# Start a local container and open a bash shell +./container/run-ubuntu-container.sh bash + +# Build Apache Celix +mkdir -p build +cd build +../container/support-scripts/build-all.sh +make -j + +# Run the unit tests for Apache Celix +ctest --output-on-failure +``` diff --git a/.devcontainer/build-devcontainer-image.sh b/container/build-ubuntu-container.sh similarity index 88% copy from .devcontainer/build-devcontainer-image.sh copy to container/build-ubuntu-container.sh index 65641c574..457a5639c 100755 --- a/.devcontainer/build-devcontainer-image.sh +++ b/container/build-ubuntu-container.sh @@ -16,10 +16,11 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# +# Build a Celix dev container with all needed dependencies pre-installed. 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. @@ -30,4 +31,4 @@ else fi cd "${SCRIPT_LOCATION}" -${CONTAINER_ENGINE} build -t apache/celix-${IMAGE_TARGET} -f Containerfile --target ${IMAGE_TARGET} . +${CONTAINER_ENGINE} build -t apache/celix-dev:ubuntu-latest -f Containerfile.ubuntu . diff --git a/.devcontainer/build-devcontainer-image.sh b/container/run-ubuntu-container.sh similarity index 55% rename from .devcontainer/build-devcontainer-image.sh rename to container/run-ubuntu-container.sh index 65641c574..998b8c1cb 100755 --- a/.devcontainer/build-devcontainer-image.sh +++ b/container/run-ubuntu-container.sh @@ -16,10 +16,15 @@ # 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}/..") -IMAGE_TARGET="${1:-conan-dev}" + +CONTAINER_COMMAND_DEFAULT="/usr/sbin/sshd -D -e -f /etc/ssh/sshd_config_celix" +CONTAINER_COMMAND=${1:-${CONTAINER_COMMAND_DEFAULT}} # Check which container engine is available. # Check for podman first, because the 'podman-docker' package might be installed providing a dummy 'docker' command. @@ -29,5 +34,14 @@ else CONTAINER_ENGINE="docker" fi -cd "${SCRIPT_LOCATION}" -${CONTAINER_ENGINE} build -t apache/celix-${IMAGE_TARGET} -f Containerfile --target ${IMAGE_TARGET} . +# Start a container with all the Celix dependencies pre-installed +# --privileged to allow the unit tests to change thread priorities +# --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 +${CONTAINER_ENGINE} run -it --rm --privileged \ + --net=host \ + --volume "${CELIX_REPO_ROOT}":"${CELIX_REPO_ROOT}" \ + --workdir "${CELIX_REPO_ROOT}" \ + --security-opt label=disable \ + apache/celix-dev:ubuntu-latest bash -c "${CONTAINER_COMMAND}" diff --git a/.devcontainer/conan-container-debug-profile b/container/support-scripts/build-all.sh old mode 100644 new mode 100755 similarity index 72% rename from .devcontainer/conan-container-debug-profile rename to container/support-scripts/build-all.sh index c10d4ab7a..2e7500b2d --- a/.devcontainer/conan-container-debug-profile +++ b/container/support-scripts/build-all.sh @@ -1,3 +1,5 @@ +#!/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 @@ -5,9 +7,9 @@ # 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 @@ -15,12 +17,13 @@ # 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 +BUILD_TYPE=${1:-Debug} + +cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DCMAKE_INSTALL_PREFIX=../celix-install \ + -DBUILD_EXPERIMENTAL=ON \ + -DENABLE_TESTING=ON \ + -DRSA_JSON_RPC=ON \ + -DRSA_SHM=ON \ + -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON \ + .. diff --git a/documents/development/README.md b/documents/development/README.md index e1f4a99a2..cc13d3045 100644 --- a/documents/development/README.md +++ b/documents/development/README.md @@ -25,7 +25,7 @@ This document outlines the recommended coding conventions for Apache Celix devel formatting, comments, control structures, functions and error handling. Note that not all existing code adheres to these conventions. -New code should adhere to these conventions, and when possible, existing code should be updated to adhere to these +New code should adhere to these conventions and when possible, existing code should be updated to adhere to these conventions. ## Naming Conventions @@ -447,6 +447,7 @@ set(MY_LIB_PRIVATE_LIBS ...) add_library(my_lib SHARED ${MY_LIB_SOURCES}) target_link_libraries(my_lib PUBLIC ${MY_LIB_PUBLIC_LIBS} PRIVATE ${MY_LIB_PRIVATE_LIBS}) celix_target_hide_symbols(my_lib) +... if (ENABLE_TESTING) add_library(my_lib_cut STATIC ${MY_LIB_SOURCES}) diff --git a/examples/conan_test_package/CMakeLists.txt b/examples/conan_test_package/CMakeLists.txt index 5ba1b25e2..eb57342c5 100644 --- a/examples/conan_test_package/CMakeLists.txt +++ b/examples/conan_test_package/CMakeLists.txt @@ -21,19 +21,6 @@ set(CMAKE_CXX_STANDARD 17) find_package(Celix REQUIRED) -option(ENABLE_ADDRESS_SANITIZER "Enabled building with address sanitizer. Note for gcc libasan must be installed," OFF) -if (ENABLE_ADDRESS_SANITIZER) - if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer ${CMAKE_CXX_FLAGS}") - elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - set(CMAKE_C_FLAGS "-lasan -fsanitize=address -fno-omit-frame-pointer ${CMAKE_C_FLAGS}") - set(CMAKE_CXX_FLAGS "-lasan -fsanitize=address -fno-omit-frame-pointer ${CMAKE_CXX_FLAGS}") - else () - message(WARNING "Address sanitizer is not supported for ${CMAKE_C_COMPILER_ID}") - endif () -endif() - option(TEST_FRAMEWORK "Test Celix framework" OFF) if (TEST_FRAMEWORK) add_celix_bundle(hello VERSION 1.0.0 SOURCES hello_bundle.c) diff --git a/examples/conan_test_package/conanfile.py b/examples/conan_test_package/conanfile.py index 6db8716d1..50d4b50f2 100644 --- a/examples/conan_test_package/conanfile.py +++ b/examples/conan_test_package/conanfile.py @@ -26,7 +26,6 @@ class TestPackageConan(ConanFile): def build(self): cmake = CMake(self) - cmake.definitions["ENABLE_ADDRESS_SANITIZER"] = self.options["celix"].enable_address_sanitizer cmake.definitions["TEST_FRAMEWORK"] = self.options["celix"].build_framework cmake.definitions["TEST_HTTP_ADMIN"] = self.options["celix"].build_http_admin cmake.definitions["TEST_LOG_SERVICE"] = self.options["celix"].build_log_service diff --git a/examples/conan_test_package_v2/conanfile.py b/examples/conan_test_package_v2/conanfile.py index bb202185c..b757c2512 100644 --- a/examples/conan_test_package_v2/conanfile.py +++ b/examples/conan_test_package_v2/conanfile.py @@ -36,7 +36,6 @@ class TestPackageConan(ConanFile): def generate(self): tc = CMakeToolchain(self) celix_options = self.dependencies["celix"].options - tc.cache_variables["ENABLE_ADDRESS_SANITIZER"] = celix_options.enable_address_sanitizer tc.cache_variables["TEST_FRAMEWORK"] = celix_options.build_framework tc.cache_variables["TEST_HTTP_ADMIN"] = celix_options.build_http_admin tc.cache_variables["TEST_LOG_SERVICE"] = celix_options.build_log_service
