From aed7c0c53c299a1c7a1d49f0dcd2ce1cf75240b4 Mon Sep 17 00:00:00 2001 From: Deeptanshu Sekhri Date: Fri, 25 Jul 2025 08:34:40 +0100 Subject: [PATCH] refactor(ci): extract inline job scripts into ci/scripts/ directory Move all `script:` blocks from `.gitlab-ci.yml` into individual executable files under `ci/scripts/`, improving maintainability and readability. Signed-off-by: Deeptanshu Sekhri --- .gitlab-ci.yml | 19 ++++--------------- ci/scripts/build.sh | 13 +++++++++++++ ci/scripts/lint.sh | 15 +++++++++++++++ ci/scripts/test_cli.sh | 15 +++++++++++++++ ci/scripts/test_python_api.sh | 15 +++++++++++++++ 5 files changed, 62 insertions(+), 15 deletions(-) create mode 100755 ci/scripts/build.sh create mode 100755 ci/scripts/lint.sh create mode 100755 ci/scripts/test_cli.sh create mode 100755 ci/scripts/test_python_api.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10ef71a..d1060fe 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -92,9 +92,7 @@ lint: before_script: - mkdir -p "$PRE_COMMIT_HOME" script: - - 'echo "Running Lint Stage: verifying code formatting and hygiene"' - - 'echo "User: $(whoami), UID: $(id -u)"' - - pre-commit run --config .pre-commit-config.yaml --all-files + - bash ci/scripts/lint.sh # Build stage: produce Python wheel build: @@ -110,10 +108,7 @@ build: image: $IMAGE tags: *runner-tags script: - - 'echo "Running Build Stage: starting build for OS = $OS"' - - bazel version - - echo "Building Python wheel" - - python -m build --wheel + - bash ci/scripts/build.sh cache: - <<: *global_cache - key: "$CI_PIPELINE_ID" @@ -124,10 +119,7 @@ build: test-cli: <<: *test-template script: - - 'echo "Running Test-CLI Stage: installing wheel and running tests on OS = $OS"' - - python -m pip install dist/*.whl - - echo "Executing pytest" - - python -m pytest -v tests/test_cli.py --log-cli-level=DEBUG --junit-xml=junit-cli-${OS}.xml + - bash ci/scripts/test_cli.sh artifacts: when: always expire_in: 7 days @@ -140,10 +132,7 @@ test-cli: test-python-api: <<: *test-template script: - - 'echo "Running Test-Python-API Stage: installing wheel and running tests on OS = $OS"' - - python -m pip install dist/*.whl - - echo "Executing pytest" - - python -m pytest tests/test_python_api.py -v --log-cli-level=DEBUG --junit-xml=junit-python-api-${OS}.xml + - bash ci/scripts/test_python_api.sh artifacts: when: always expire_in: 7 days diff --git a/ci/scripts/build.sh b/ci/scripts/build.sh new file mode 100755 index 0000000..c35cecf --- /dev/null +++ b/ci/scripts/build.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# +set -euo pipefail + +echo "Running Build Stage: starting build for OS = $OS" +bazel version + +echo "Building Python wheel" +python -m build --wheel diff --git a/ci/scripts/lint.sh b/ci/scripts/lint.sh new file mode 100755 index 0000000..1631889 --- /dev/null +++ b/ci/scripts/lint.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# +set -euo pipefail + +# Ensure pre-commit cache directory exists +mkdir -p "$PRE_COMMIT_HOME" + +echo "Running Lint Stage: verifying code formatting and hygiene" +echo "User: $(whoami), UID: $(id -u)" + +pre-commit run --config .pre-commit-config.yaml --all-files diff --git a/ci/scripts/test_cli.sh b/ci/scripts/test_cli.sh new file mode 100755 index 0000000..1af8daf --- /dev/null +++ b/ci/scripts/test_cli.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# +set -euo pipefail + +echo "Running Test CLI Stage: installing wheel and running tests on OS = $OS" +python -m pip install dist/*.whl + +echo "Executing pytest" +python -m pytest -v tests/test_cli.py \ + --log-cli-level=DEBUG \ + --junit-xml=junit-cli-${OS}.xml diff --git a/ci/scripts/test_python_api.sh b/ci/scripts/test_python_api.sh new file mode 100755 index 0000000..d230661 --- /dev/null +++ b/ci/scripts/test_python_api.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# +# SPDX-FileCopyrightText: Copyright 2025 Arm Limited and/or its affiliates +# +# SPDX-License-Identifier: Apache-2.0 +# +set -euo pipefail + +echo "Running Test-Python-API Stage: installing wheel and running tests on OS = $OS" +python -m pip install dist/*.whl + +echo "Executing pytest" +python -m pytest tests/test_python_api.py \ + -v --log-cli-level=DEBUG \ + --junit-xml=junit-python-api-${OS}.xml -- GitLab