diff --git a/.ci/CI.Dockerfile b/.ci/CI.Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..6c06d665ee94b4b7b1662bcebb202d0fc2f5d8cf --- /dev/null +++ b/.ci/CI.Dockerfile @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its +# affiliates +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed 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 ubuntu:22.04 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ + apt-get install -y \ + make \ + git \ + gcc \ + g++ \ + python3.10 \ + python3-pip \ + python3.10-dev \ + python3.10-venv \ + unzip \ + curl \ + wget \ + gpg \ + libsndfile1 \ + sudo \ + telnet \ + && rm -rf /var/lib/apt/lists/* diff --git a/.ci/build_and_test.yml b/.ci/build_and_test.yml new file mode 100644 index 0000000000000000000000000000000000000000..5e6ae62b5cf361fcf165addf610b605f9f827064 --- /dev/null +++ b/.ci/build_and_test.yml @@ -0,0 +1,62 @@ +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited +# and/or its affiliates +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed 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. + +variables: + BUILD_LOG_LEVEL: "LOG_LEVEL_INFO" + EVAL_KIT_DIR: "$CI_PROJECT_DIR" + IMAGE: "$CI_REGISTRY_IMAGE:latest" + +build_and_test: + stage: build_and_test + tags: [$RUNNER_TAG] + image: $IMAGE + rules: + - if: $CI_COMMIT_BRANCH || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "web" + parallel: + matrix: + - TARGET_PLATFORM: native + CMAKE_BUILD_TYPE: [Debug, Release] + TOOLCHAIN_FILE: native-gcc + RUNNER_TAG: [arm64-shared, amd64-shared] + before_script: + - git submodule update --init --recursive + - python3 ./set_up_default_resources.py + script: + - echo "Building with PLATFORM=$TARGET_PLATFORM, TYPE=$CMAKE_BUILD_TYPE, TOOLCHAIN=$TOOLCHAIN_FILE" + - mkdir -p build-${TARGET_PLATFORM}-${CMAKE_BUILD_TYPE}-${TOOLCHAIN_FILE} + - cd build-${TARGET_PLATFORM}-${CMAKE_BUILD_TYPE}-${TOOLCHAIN_FILE} + - export PATH="$EVAL_KIT_DIR/resources_downloaded/env/bin:$PATH" + - cmake -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DTARGET_PLATFORM=${TARGET_PLATFORM} -DCMAKE_TOOLCHAIN_FILE=scripts/cmake/toolchains/${TOOLCHAIN_FILE}.cmake -DLOG_LEVEL=$BUILD_LOG_LEVEL .. + - make VERBOSE=1 -j1 + # Run tests + - | + fail=0 + for TEST in ./bin/*tests; do + TEST_NAME=$(basename $TEST) + RESULT_XML=${TEST_NAME}-result.xml + $TEST -r junit -o $RESULT_XML || fail=1 + done + if [ $fail = 1 ]; then + echo "One or more tests have failed to run. Check console log" + exit 1 + fi + artifacts: + paths: + - build-${TARGET_PLATFORM}-${CMAKE_BUILD_TYPE}-${TOOLCHAIN_FILE}/*.xml + reports: + junit: + - build-${TARGET_PLATFORM}-${CMAKE_BUILD_TYPE}-${TOOLCHAIN_FILE}/*.xml + expire_in: 2h diff --git a/.ci/buildah_build_and_push.yml b/.ci/buildah_build_and_push.yml new file mode 100644 index 0000000000000000000000000000000000000000..20749587e65c3a58bd2bb998dbaf9875d0edd6ae --- /dev/null +++ b/.ci/buildah_build_and_push.yml @@ -0,0 +1,65 @@ +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited +# and/or its affiliates +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed 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. + +variables: + STORAGE_DRIVER: vfs + BUILDAH_FORMAT: docker + IMAGE_TAG: "$CI_COMMIT_SHORT_SHA" + PUSH_LATEST: false + +.default_buildah: + image: $CI_REGISTRY_IMAGE/buildah-stable:latest + stage: buildah_build_and_push + before_script: + - echo "$CI_REGISTRY_PASSWORD" | buildah login -u "$CI_REGISTRY_USER" --password-stdin $CI_REGISTRY + rules: + - changes: [CI.Dockerfile] + if: $CI_COMMIT_BRANCH == "main" || $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "web" + when: always + +build-amd64: + extends: .default_buildah + tags: [amd64-shared] + script: + - buildah build --format=$BUILDAH_FORMAT --storage-driver=$STORAGE_DRIVER --platform=linux/amd64 -f .ci/CI.Dockerfile -t $CI_REGISTRY_IMAGE:amd64-$CI_COMMIT_SHORT_SHA . + - buildah push $CI_REGISTRY_IMAGE:amd64-$CI_COMMIT_SHORT_SHA + +build-arm64: + extends: .default_buildah + tags: [arm64-shared] + script: + - buildah build --format=$BUILDAH_FORMAT --storage-driver=$STORAGE_DRIVER --platform=linux/arm64/v8 -f .ci/CI.Dockerfile -t $CI_REGISTRY_IMAGE:arm64-$CI_COMMIT_SHORT_SHA . + - buildah push $CI_REGISTRY_IMAGE:arm64-$CI_COMMIT_SHORT_SHA + +create_manifest: + extends: .default_buildah + needs: ["build-amd64", "build-arm64"] + tags: [amd64-shared] + script: + - buildah manifest create $CI_REGISTRY_IMAGE:$IMAGE_TAG + - buildah manifest add $CI_REGISTRY_IMAGE:$IMAGE_TAG docker://$CI_REGISTRY_IMAGE:amd64-$CI_COMMIT_SHORT_SHA + - buildah manifest add $CI_REGISTRY_IMAGE:$IMAGE_TAG docker://$CI_REGISTRY_IMAGE:arm64-$CI_COMMIT_SHORT_SHA + - buildah manifest push --all $CI_REGISTRY_IMAGE:$IMAGE_TAG + # Only push 'latest' manifest on main branch, skip for merge requests + - | + if [[ "$CI_COMMIT_BRANCH" == "main" || "$PUSH_LATEST" == "true" ]]; then + buildah manifest create $CI_REGISTRY_IMAGE:latest + buildah manifest add $CI_REGISTRY_IMAGE:latest docker://$CI_REGISTRY_IMAGE:amd64-$CI_COMMIT_SHORT_SHA + buildah manifest add $CI_REGISTRY_IMAGE:latest docker://$CI_REGISTRY_IMAGE:arm64-$CI_COMMIT_SHORT_SHA + buildah manifest push --all $CI_REGISTRY_IMAGE:latest + else + echo "Not main branch, skipping 'latest' manifest push." + fi diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000000000000000000000000000000000000..aa4cf680dea27b9535f8935f02538ea4b6c652e8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited +# and/or its affiliates +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed 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. + +stages: + - buildah_build_and_push + - build_and_test + +include: + - local: '.ci/buildah_build_and_push.yml' + - local: '.ci/build_and_test.yml'