Skip to content
Snippets Groups Projects
Commit bd7e9366 authored by Andrii Sosiuk's avatar Andrii Sosiuk
Browse files

YT-65 We perform a repository checkout in the manifest project for each build job.

  Each pipeline builds code for multiple MACHINES.
  This results in multiple downloads from each repository in the manifest.
  Occasionally, certain repositories may fail to fetch data.
  To avoid fetching the same data repeatedly for each build job in the pipeline,
  the `repo_checkout` stage is added.
  In this stage, the repo tool prepares the repository structure once
  and stores it in the cache.
  Subsequent build jobs use the pre-fetched data from the cache.
parent de29fa3e
Branches
No related tags found
1 merge request!410YT-65 Find proxy solution for repo checkout
...@@ -30,6 +30,9 @@ variables: ...@@ -30,6 +30,9 @@ variables:
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: Infrastructure # Stage: Infrastructure
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
repo_checkout:
extends: .repo_checkout
changelog: changelog:
extends: .changelog extends: .changelog
...@@ -39,6 +42,8 @@ build-version: ...@@ -39,6 +42,8 @@ build-version:
# We have to set a machine, even if it is not actually needed for what the job does, # We have to set a machine, even if it is not actually needed for what the job does,
# so we just choose the first. # so we just choose the first.
MACHINE: {{ MACHINES.split(' ')[0] }} MACHINE: {{ MACHINES.split(' ')[0] }}
needs:
- repo_checkout
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
...@@ -67,6 +72,8 @@ build-{{ machine }}: ...@@ -67,6 +72,8 @@ build-{{ machine }}:
variables: variables:
BITBAKE_TASK: build BITBAKE_TASK: build
MACHINE: {{ machine }} MACHINE: {{ machine }}
needs:
- repo_checkout
{% else %} {% else %}
......
...@@ -9,11 +9,12 @@ workflow: ...@@ -9,11 +9,12 @@ workflow:
# Scripts # Scripts
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
.docker_check: &docker_check .docker_check: &docker_check
# Check if the build folder is empty. Sometimes the docker volume for the build is not # heck if the build folder does not contain outdated data.
# removed afterwards (e.g. in case of a timeout), then a follow-up build might fail. # Sometimes the docker volume for the build is not removed afterwards
# (e.g. in case of a timeout), then a follow-up build might fail.
- |- - |-
if [ "$(ls -A)" ]; then if [ "$(ls -A | grep -v repo_checkout)" ]; then
echo "ERROR: Build folder is not empty. This might be the case because the" \ echo "ERROR: Build folder is not clear. This might be the case because the" \
"docker volume has not been removed in a previous job. Please check" \ "docker volume has not been removed in a previous job. Please check" \
"the docker container \"$CI_JOB_IMAGE\" on the GitLab runner" \ "the docker container \"$CI_JOB_IMAGE\" on the GitLab runner" \
"\"$CI_RUNNER_SHORT_TOKEN\" ($CI_RUNNER_DESCRIPTION) and remove any" \ "\"$CI_RUNNER_SHORT_TOKEN\" ($CI_RUNNER_DESCRIPTION) and remove any" \
...@@ -95,14 +96,6 @@ workflow: ...@@ -95,14 +96,6 @@ workflow:
done <<< "${GITLAB_PRIVATE_TOKEN}"; done <<< "${GITLAB_PRIVATE_TOKEN}";
IFS=$original_ifs; IFS=$original_ifs;
.repo_checkout: &repo_checkout
- echo "Perform repo checkout"
- cd ${CI_PROJECT_DIR}
- repo init --submodules -u ${CI_REPOSITORY_URL}
-b refs/pipelines/${CI_PIPELINE_ID} -m ${MANIFEST_FILE}
- repo sync --detach --current-branch --force-remove-dirty
--optimized-fetch --force-sync
.collect_srcrevs: &collect_srcrevs .collect_srcrevs: &collect_srcrevs
# write all package AUTOREVS to file # write all package AUTOREVS to file
- |- - |-
...@@ -146,6 +139,13 @@ workflow: ...@@ -146,6 +139,13 @@ workflow:
fi fi
.setup_build: &setup_build .setup_build: &setup_build
- cd ${CI_PROJECT_DIR}
- |
if [ -d repo_checkout ]; then
echo "Unpack repo from chached rirectory"
find repo_checkout -mindepth 1 -maxdepth 1 -exec mv -t . {} +
rm -r repo_checkout
fi
- echo "Build configuration MACHINE=${MACHINE} - echo "Build configuration MACHINE=${MACHINE}
DISTRO=${YOCTO_DISTRO} IMAGE=${YOCTO_IMAGE}" DISTRO=${YOCTO_DISTRO} IMAGE=${YOCTO_IMAGE}"
- echo "Using build dir ${BUILD_PATH}" - echo "Using build dir ${BUILD_PATH}"
...@@ -182,9 +182,53 @@ workflow: ...@@ -182,9 +182,53 @@ workflow:
- echo "MACHINE=${MACHINE}" >> build.env - echo "MACHINE=${MACHINE}" >> build.env
- echo "SUPPORTED_HARDWARE='${SUPPORTED_HARDWARE}'" >> build.env - echo "SUPPORTED_HARDWARE='${SUPPORTED_HARDWARE}'" >> build.env
.build_image:
image:
name: "${CI_IMAGE_YOCTO}"
# Override entrypoint so we can pass --id to set the UID and GID for the
# user that is created in the container. This is a feature of the
# crops/poky images. See poky-entry.py for details.
entrypoint:
- "/usr/bin/distro-entry.sh"
- "/usr/bin/dumb-init"
- "--"
- "/usr/bin/poky-entry.py"
- "--id=118:998"
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: Infrastructure # Stage: Infrastructure
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Checkout the repository and store it in the cache to use cached data
# instead of fetching it from Git for each build job.
.repo_checkout:
extends:
- .build_image
stage: Infrastructure
tags:
- builds
variables:
GIT_STRATEGY: none
MANIFEST_FILE: "default.xml"
before_script:
- *docker_check
- *setup_ssh
- *setup_git_credentials
script:
- echo "Perform repo checkout"
- cd ${CI_PROJECT_DIR}
- mkdir repo_checkout
- cd repo_checkout
- repo init --submodules -u ${CI_REPOSITORY_URL}
-b refs/pipelines/${CI_PIPELINE_ID} -m ${MANIFEST_FILE}
- repo sync --detach --current-branch --force-remove-dirty
--optimized-fetch --force-sync
cache:
- key: ${CI_PIPELINE_ID}-${CI_JOB_NAME}
policy: push
paths:
- ${CI_PROJECT_DIR}/repo_checkout
.changelog: .changelog:
extends: .infrastructure extends: .infrastructure
script: script:
...@@ -208,10 +252,10 @@ workflow: ...@@ -208,10 +252,10 @@ workflow:
- .build_yocto - .build_yocto
stage: Infrastructure stage: Infrastructure
tags: tags:
- infrastructure - builds
needs: [] needs: []
rules: rules:
- when: always - when: on_success
variables: variables:
# RELEASE_VERSION_EXPRESSION and RELEASE_NAME_EXPRESSION are eval'ed and then saved # RELEASE_VERSION_EXPRESSION and RELEASE_NAME_EXPRESSION are eval'ed and then saved
# as RELEASE_VERSION and RELEASE_NAME to version.env, so we can use deferred # as RELEASE_VERSION and RELEASE_NAME to version.env, so we can use deferred
...@@ -234,32 +278,27 @@ workflow: ...@@ -234,32 +278,27 @@ workflow:
reports: reports:
dotenv: version.env dotenv: version.env
paths: [] paths: []
cache: [] cache: &cache
# Get prepared repo from cache
- key: ${CI_PIPELINE_ID}-repo_checkout
policy: pull
paths:
- ${CI_PROJECT_DIR}/repo_checkout
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: build # Stage: build
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
.buildbase: .buildbase:
extends:
- .build_image
stage: Build stage: Build
tags: tags:
- ${BUILD_RUNNER_TAG} - ${BUILD_RUNNER_TAG}
timeout: 8h timeout: 8h
interruptible: true interruptible: true
image:
name: "${CI_IMAGE_YOCTO}"
# Override entrypoint so we can pass --id to set the UID and GID for the
# user that is created in the container. This is a feature of the
# crops/poky images. See poky-entry.py for details.
entrypoint:
- "/usr/bin/distro-entry.sh"
- "/usr/bin/dumb-init"
- "--"
- "/usr/bin/poky-entry.py"
- "--id=118:998"
variables: variables:
BUILD_RUNNER_TAG: "builds" BUILD_RUNNER_TAG: "builds"
MANUAL_BUILD: "false" MANUAL_BUILD: "false"
MANIFEST_FILE: "default.xml"
rules: rules:
- if: $MANUAL_BUILD == "true" - if: $MANUAL_BUILD == "true"
when: manual when: manual
...@@ -279,6 +318,11 @@ workflow: ...@@ -279,6 +318,11 @@ workflow:
- build-*/tmp/deploy/licenses/**/license.manifest - build-*/tmp/deploy/licenses/**/license.manifest
- build.env - build.env
cache: &cache cache: &cache
# Get prepared repo from cache
- key: ${CI_PIPELINE_ID}-repo_checkout
policy: pull
paths:
- ${CI_PROJECT_DIR}/repo_checkout
# Cache the build artifacts for subsequent stages in the same pipeline # Cache the build artifacts for subsequent stages in the same pipeline
- key: ${CI_PIPELINE_ID}-${CI_JOB_NAME} - key: ${CI_PIPELINE_ID}-${CI_JOB_NAME}
policy: push policy: push
...@@ -302,7 +346,6 @@ workflow: ...@@ -302,7 +346,6 @@ workflow:
- *docker_check - *docker_check
- *setup_ssh - *setup_ssh
- *setup_git_credentials - *setup_git_credentials
- *repo_checkout
- *setup_build - *setup_build
script: script:
- *run_build - *run_build
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment