From 7ad27229b04c8dcf2f43908daf481aa2cf0dafd1 Mon Sep 17 00:00:00 2001 From: Leandro Belli Date: Mon, 22 Jan 2024 15:30:26 +0000 Subject: [PATCH] ci: adds gitlab-ci basic configuration It is added a basic structure for CI testing on GitlabCI. It is introduced two pipelines: - `daily-pipeline`: intended to be run periodically where all checks are performed. - `deployment-pipeline`: run a set of basic tests. Signed-off-by: Leandro Belli Change-Id: Ib11db1db682055b889a4fdfb3636a905a7df1280 --- .gitlab/.gitlab-ci.yml | 23 ++++++++++++ .gitlab/pipelines/daily-pipeline.yml | 42 +++++++++++++++++++++ .gitlab/pipelines/deployment-pipeline.yml | 46 +++++++++++++++++++++++ .gitlab/templates/build-test.yml | 40 ++++++++++++++++++++ .gitlab/templates/linting.yml | 33 ++++++++++++++++ .gitlab/templates/static-analysis.yml | 11 ++++++ .gitlab/templates/unit-test.yml | 29 ++++++++++++++ 7 files changed, 224 insertions(+) create mode 100644 .gitlab/.gitlab-ci.yml create mode 100644 .gitlab/pipelines/daily-pipeline.yml create mode 100644 .gitlab/pipelines/deployment-pipeline.yml create mode 100644 .gitlab/templates/build-test.yml create mode 100644 .gitlab/templates/linting.yml create mode 100644 .gitlab/templates/static-analysis.yml create mode 100644 .gitlab/templates/unit-test.yml diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml new file mode 100644 index 000000000..4eef0464c --- /dev/null +++ b/.gitlab/.gitlab-ci.yml @@ -0,0 +1,23 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +variables: + PIPELINE_TYPE: + value: "deployment-pipeline" + options: + - "deployment-pipeline" + - "daily-pipeline" + description: "The CI pipeline to run" + +include: + - local: .gitlab/pipelines/deployment-pipeline.yml + rules: + - if: $PIPELINE_TYPE == "deployment-pipeline" + + - local: .gitlab/pipelines/daily-pipeline.yml + rules: + - if: $PIPELINE_TYPE == "daily-pipeline" diff --git a/.gitlab/pipelines/daily-pipeline.yml b/.gitlab/pipelines/daily-pipeline.yml new file mode 100644 index 000000000..80c40a95b --- /dev/null +++ b/.gitlab/pipelines/daily-pipeline.yml @@ -0,0 +1,42 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +stages: + - linting + - static-analysis + - unit-testing + - build + +include: + - local: .gitlab/templates/linting.yml + - local: .gitlab/templates/static-analysis.yml + - local: .gitlab/templates/unit-test.yml + - local: .gitlab/templates/build-test.yml + +check-lint: + extends: .check-lint + stage: linting + allow_failure: true + +banned-api: + extends: .banned-api + stage: static-analysis + allow_failure: true + +check-fwk: + extends: .check-fwk + stage: unit-testing + allow_failure: true + +check-modules: + extends: .check-modules + stage: unit-testing + allow_failure: true + +build-products-all-log-levels: + extends: .build-products-all-log-levels + stage: build diff --git a/.gitlab/pipelines/deployment-pipeline.yml b/.gitlab/pipelines/deployment-pipeline.yml new file mode 100644 index 000000000..08af3795e --- /dev/null +++ b/.gitlab/pipelines/deployment-pipeline.yml @@ -0,0 +1,46 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +stages: + - linting + - static-analysis + - unit-testing + - build + +include: + - local: .gitlab/templates/linting.yml + - local: .gitlab/templates/static-analysis.yml + - local: .gitlab/templates/unit-test.yml + - local: .gitlab/templates/build-test.yml + +check-lint: + extends: .check-lint + stage: linting + +check-copyright: + extends: .check-copyright + stage: linting + +check-style: + extends: .check-style + stage: linting + +banned-api: + extends: .banned-api + stage: static-analysis + +check-fwk: + extends: .check-fwk + stage: unit-testing + +check-modules: + extends: .check-modules + stage: unit-testing + +build-products: + extends: .build-products + stage: build diff --git a/.gitlab/templates/build-test.yml b/.gitlab/templates/build-test.yml new file mode 100644 index 000000000..28d53e24a --- /dev/null +++ b/.gitlab/templates/build-test.yml @@ -0,0 +1,40 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +.build-products: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_DEPTH: 1 + before_script: + - | + if [ -z $BUILD_PRODUCTS_LOG_LEVEL ]; then + export LOG_LEVEL="" + else + export LOG_LEVEL="--log-level=$BUILD_PRODUCTS_LOG_LEVEL" + fi + script: + - | + python3 tools/check_build.py --build-output-dir ./build \ + ${LOG_LEVEL} + artifacts: + when: on_failure + expire_in: 2 days + paths: + - build/*.txt + +.build-products-all-log-levels: + extends: .build-products + parallel: + matrix: + - BUILD_PRODUCTS_LOG_LEVEL: + - DEBUG + - INFO + - WARN + - ERROR + - CRIT + - DISABLED diff --git a/.gitlab/templates/linting.yml b/.gitlab/templates/linting.yml new file mode 100644 index 000000000..7d1616253 --- /dev/null +++ b/.gitlab/templates/linting.yml @@ -0,0 +1,33 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +.check-lint: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - python3 tools/${CHECK_SCRIPT}.py + parallel: + matrix: + - CHECK_SCRIPT: + - check_doc + - check_pycodestyle + - check_spacing + - check_tabs + +.check-copyright: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - python3 tools/check_copyright.py -c "${CI_MERGE_REQUEST_DIFF_BASE_SHA}" + +.check-style: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - python3 tools/check_style.py -c "${CI_MERGE_REQUEST_DIFF_BASE_SHA}" + artifacts: + when: on_failure + expire_in: 2 days + paths: + - code-style.patch diff --git a/.gitlab/templates/static-analysis.yml b/.gitlab/templates/static-analysis.yml new file mode 100644 index 000000000..48f18aa6b --- /dev/null +++ b/.gitlab/templates/static-analysis.yml @@ -0,0 +1,11 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +.banned-api: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - python3 tools/check_api.py diff --git a/.gitlab/templates/unit-test.yml b/.gitlab/templates/unit-test.yml new file mode 100644 index 000000000..4ac82e64d --- /dev/null +++ b/.gitlab/templates/unit-test.yml @@ -0,0 +1,29 @@ +# +# Arm SCP/MCP Software +# Copyright (c) 2024, Arm Limited and Contributors. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +.check-fwk: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + script: + - python3 tools/check_framework.py --coverage + artifacts: + when: on_success + expire_in: 2 days + paths: + - build/module/test/scp_v2_fwk_test_coverage_filtered.info + +.check-modules: + image: ${CI_REGISTRY_IMAGE}/ci-base:latest + variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_DEPTH: 1 + script: + - python3 tools/check_module_utest.py --coverage + artifacts: + when: on_success + expire_in: 2 days + paths: + - build/module/test/scp_v2_unit_test_coverage_filtered.info