diff --git a/.ci/build_and_test.yml b/.ci/build_and_test.yml index 5e6ae62b5cf361fcf165addf610b605f9f827064..eab1ff45a46dbe2e93849291350abffa8d07f646 100644 --- a/.ci/build_and_test.yml +++ b/.ci/build_and_test.yml @@ -18,6 +18,8 @@ variables: BUILD_LOG_LEVEL: "LOG_LEVEL_INFO" EVAL_KIT_DIR: "$CI_PROJECT_DIR" IMAGE: "$CI_REGISTRY_IMAGE:latest" + PACKAGE_NAME: "resources_downloaded" + PACKAGE_VERSION: "latest" build_and_test: stage: build_and_test @@ -33,12 +35,29 @@ build_and_test: RUNNER_TAG: [arm64-shared, amd64-shared] before_script: - git submodule update --init --recursive + - | + echo "Downloading resources $PACKAGE_NAME/$PACKAGE_VERSION" + # Resolve latest if needed + VERSION="$PACKAGE_VERSION" + if [ "$VERSION" = "latest" ]; then + echo "Resolving 'latest' version from registry..." + # List all versions, sort by created_at, pick most recent + VERSION=$(curl -sS --header "JOB-TOKEN: $CI_JOB_TOKEN" \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages?package_type=generic&package_name=${PACKAGE_NAME}" \ + | jq -r 'sort_by(.created_at) | reverse | .[0].version') + echo "Latest resolved to version: $VERSION" + fi + + curl --header "JOB-TOKEN: $CI_JOB_TOKEN" \ + --output $PACKAGE_NAME.tar.gz \ + "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/${PACKAGE_NAME}/${VERSION}/${PACKAGE_NAME}.tar.gz" + tar -xzf $PACKAGE_NAME.tar.gz - 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" + - export PATH="$EVAL_KIT_DIR/$PACKAGE_NAME/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 diff --git a/.ci/upload_resources.yml b/.ci/upload_resources.yml new file mode 100644 index 0000000000000000000000000000000000000000..ce073c477979137dd81234244b5a6c4903f01ae4 --- /dev/null +++ b/.ci/upload_resources.yml @@ -0,0 +1,48 @@ +# 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: + PACKAGE_NAME: "resources_downloaded" + PACKAGE_VERSION: "$CI_COMMIT_SHORT_SHA" + API_URL: "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}" + TKN: "JOB-TOKEN: $CI_JOB_TOKEN" + INCLUDE_UPLOAD_RESOURCES: "false" + +upload_resources: + stage: upload_resources + image: $CI_REGISTRY_IMAGE:latest + tags: + - amd64-shared + before_script: + - git submodule update --init --recursive + - python3 ./set_up_default_resources.py --skip-vela --downloads-dir $PACKAGE_NAME + - tar -czvf $PACKAGE_NAME.tar.gz $PACKAGE_NAME + script: | + set -euo pipefail + + file="$PACKAGE_NAME.tar.gz" + upload_url="$API_URL/packages/generic/$PACKAGE_NAME/$CI_COMMIT_SHORT_SHA/$file?select=package_file" + curl -H "$TKN" -T "$file" "$upload_url" + rules: + # If scheduled pipeline, run automatically + - if: '$CI_PIPELINE_SOURCE == "schedule"' + when: always + # If Web UI, make manual + - if: '$CI_PIPELINE_SOURCE == "web" && $INCLUDE_UPLOAD_RESOURCES == "true"' + when: always + allow_failure: true + # Otherwise, don't run + - when: never diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index aa4cf680dea27b9535f8935f02538ea4b6c652e8..3e19de72c572cbf5d551c260ae452dc75cdf9dda 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -15,9 +15,11 @@ # limitations under the License. stages: + - upload_resources - buildah_build_and_push - build_and_test include: + - local: '.ci/upload_resources.yml' - local: '.ci/buildah_build_and_push.yml' - local: '.ci/build_and_test.yml'