diff --git a/.github/workflows/containers.yml b/.github/workflows/containers.yml new file mode 100644 index 000000000..95b92edae --- /dev/null +++ b/.github/workflows/containers.yml @@ -0,0 +1,38 @@ +name: Celix development containers + +on: + push: + pull_request: + schedule: + - cron: '0 0 * * 0' # Weekly on Sunday at 00:00 UTC + +jobs: + container-build-ubuntu: + runs-on: ubuntu-22.04 + timeout-minutes: 120 + steps: + - name: Checkout source code + uses: actions/checkout@v3.3.0 + - name: Build container image + run: | + cd $GITHUB_WORKSPACE/container/ + ./build-ubuntu-container.sh + - name: Build Celix using container image + run: | + 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: | + cd $GITHUB_WORKSPACE/container/ + ./run-ubuntu-container.sh "cd build && ctest --output-on-failure" + + container-build-gitpod: + runs-on: ubuntu-22.04 + timeout-minutes: 120 + steps: + - name: Checkout source code + uses: actions/checkout@v3.3.0 + - name: Build container image + run: | + cd $GITHUB_WORKSPACE/container/ + docker build -t apache/celix-dev:gitpod-latest -f Containerfile.gitpod . diff --git a/container/Containerfile.gitpod b/container/Containerfile.gitpod index 7ac418c14..a9591d251 100644 --- a/container/Containerfile.gitpod +++ b/container/Containerfile.gitpod @@ -15,9 +15,6 @@ # specific language governing permissions and limitations # under the License. -# SSH credentials: -# root@password - FROM docker.io/gitpod/workspace-full:2023-10-06-16-22-14@sha256:76d3041cc7a2caa00d6f4610ace0e15009c361515f3d5d9ee6690e4019adcfd4 # Switch to root user to install dependencies and configure sshd diff --git a/container/README.md b/container/README.md index b958466ab..1d24de756 100644 --- a/container/README.md +++ b/container/README.md @@ -21,7 +21,7 @@ To always be able to develop on Celix with an up-to-date image, built the image cd # Start a local container with the SSH daemon running -./container/start-ubuntu-container.sh +./container/run-ubuntu-container.sh ``` Now connect to the container via the remote container option of your favoured IDE and start building/developing. @@ -35,22 +35,21 @@ When finished with development and testing, press `CTRL + \` to stop the SSH dae ### Start locally with only a bash shell -The start script allows passing of additional paramters, which will override the starting of the SSH daemon. +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 # Start a local container and open a bash shell -./container/start-ubuntu-container.sh bash +./container/run-ubuntu-container.sh bash # Build Apache Celix -mkdir celix-build -cd celix-build +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/container/build-ubuntu-container.sh b/container/build-ubuntu-container.sh index aafa8aa0d..457a5639c 100755 --- a/container/build-ubuntu-container.sh +++ b/container/build-ubuntu-container.sh @@ -32,4 +32,3 @@ fi cd "${SCRIPT_LOCATION}" ${CONTAINER_ENGINE} build -t apache/celix-dev:ubuntu-latest -f Containerfile.ubuntu . - diff --git a/container/start-ubuntu-container.sh b/container/run-ubuntu-container.sh similarity index 96% rename from container/start-ubuntu-container.sh rename to container/run-ubuntu-container.sh index 2df3dadef..998b8c1cb 100755 --- a/container/start-ubuntu-container.sh +++ b/container/run-ubuntu-container.sh @@ -44,5 +44,4 @@ ${CONTAINER_ENGINE} run -it --rm --privileged \ --volume "${CELIX_REPO_ROOT}":"${CELIX_REPO_ROOT}" \ --workdir "${CELIX_REPO_ROOT}" \ --security-opt label=disable \ - apache/celix-dev:ubuntu-latest ${CONTAINER_COMMAND} - + apache/celix-dev:ubuntu-latest bash -c "${CONTAINER_COMMAND}" diff --git a/container/support-scripts/build-all.sh b/container/support-scripts/build-all.sh index 16acf6dff..2e7500b2d 100755 --- a/container/support-scripts/build-all.sh +++ b/container/support-scripts/build-all.sh @@ -27,4 +27,3 @@ cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DRSA_SHM=ON \ -DRSA_REMOTE_SERVICE_ADMIN_SHM_V2=ON \ .. - diff --git a/libs/framework/src/service_registry.c b/libs/framework/src/service_registry.c index 4957214c3..467925bb2 100644 --- a/libs/framework/src/service_registry.c +++ b/libs/framework/src/service_registry.c @@ -677,37 +677,30 @@ size_t serviceRegistry_nrOfHooks(service_registry_pt registry) { } static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt registry, service_registration_pt registration, celix_array_list_t** out) { - celix_status_t status = CELIX_SUCCESS; celix_array_list_t* bundles = NULL; hash_map_iterator_pt iter; bundles = celix_arrayList_create(); - if (bundles) { - celixThreadRwlock_readLock(®istry->lock); - iter = hashMapIterator_create(registry->serviceReferences); - while (hashMapIterator_hasNext(iter)) { - hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); - bundle_pt registrationUser = hashMapEntry_getKey(entry); - hash_map_pt regMap = hashMapEntry_getValue(entry); - if (hashMap_containsKey(regMap, (void*)registration->serviceId)) { - celix_arrayList_add(bundles, registrationUser); - } - } - hashMapIterator_destroy(iter); - celixThreadRwlock_unlock(®istry->lock); - } else { - status = CELIX_ENOMEM; + if (bundles == NULL) { + return CELIX_ENOMEM; } - if (status == CELIX_SUCCESS) { - *out = bundles; - } else { - if (bundles != NULL) { - celix_arrayList_destroy(bundles); + celixThreadRwlock_readLock(®istry->lock); + iter = hashMapIterator_create(registry->serviceReferences); + while (hashMapIterator_hasNext(iter)) { + hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); + bundle_pt registrationUser = hashMapEntry_getKey(entry); + hash_map_pt regMap = hashMapEntry_getValue(entry); + if (hashMap_containsKey(regMap, (void*)registration->serviceId)) { + celix_arrayList_add(bundles, registrationUser); } } + hashMapIterator_destroy(iter); + celixThreadRwlock_unlock(®istry->lock); - return status; + *out = bundles; + + return CELIX_SUCCESS; } celix_status_t