Skip to content
Snippets Groups Projects
Commit 0f7ef6cd authored by Lorenzo Pagliai's avatar Lorenzo Pagliai
Browse files

[PRE-BUILD] Introduce common preliminary job for repo init and sync

* Right now each build job perform the same action of initialising repo.
This approach is time and resource consuming, so we introduce a
'repo_checkout' job to perform repo init and sync actions.
* The output of this job is stored as GitLab CI cache and pulled by each
build job in the build stage.
* Minor fixes in build setup configuration.
parent d7308515
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,7 @@ include: ...@@ -15,6 +15,7 @@ include:
# Stages # Stages
#------------ #------------
stages: stages:
- pre-build
- build - build
- deploy - deploy
- changelog - changelog
...@@ -28,18 +29,11 @@ stages: ...@@ -28,18 +29,11 @@ stages:
variables: variables:
MASTER_BRANCH: {{ MASTER_BRANCH }} MASTER_BRANCH: {{ MASTER_BRANCH }}
build:pass: # --------------------------------------------------------------------------------------
stage: build # Stage: pre-build
tags: # --------------------------------------------------------------------------------------
- infrastructure repo_checkout:
needs: [] extends: .repo_checkout
timeout: 2m
image: {{ CI_IMAGE_PYTHON }}
script:
- printenv
- echo "Build successful"
- echo "This is the value of the MANUAL_BUILD variable '${MANUAL_BUILD}'"
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# Stage: changelog # Stage: changelog
......
...@@ -14,6 +14,16 @@ workflow: ...@@ -14,6 +14,16 @@ workflow:
- chown -R :clea-os /var/cache/clea-os_* - chown -R :clea-os /var/cache/clea-os_*
- chsh -s /bin/bash $NEWUS - chsh -s /bin/bash $NEWUS
- su $NEWUS - su $NEWUS
- export BASEDIR=$PWD
- export EULA=1
- BUILD_BRANCH=${MASTER_BRANCH}
- |
if [ ${CI_PIPELINE_SOURCE} == "parent_pipeline" ]; then
BUILD_BRANCH="${CI_COMMIT_REF_NAME}"
fi
if [ ! -z ${CI_COMMIT_TAG} ]; then
BUILD_BRANCH="refs/tags/${CI_COMMIT_TAG}"
fi
.initSSH: &initSSH .initSSH: &initSSH
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
...@@ -25,15 +35,50 @@ workflow: ...@@ -25,15 +35,50 @@ workflow:
- chmod 600 ~/.ssh/id_rsa - chmod 600 ~/.ssh/id_rsa
# ----------------------------------- # -----------------------------------
# Stage: build # Stage: pre-build
# ----------------------------------- # -----------------------------------
.build:
# 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: extends:
- .infrastructure - .infrastructure
rules: &build_rule rules: &build_rule
- if: $MANUAL_BUILD == "true" - if: $MANUAL_BUILD == "true"
when: manual when: manual
- when: always - when: always
stage: pre-build
tags:
- pre-yocto_build
image:
name: ${CI_IMAGE_YOCTO}
entrypoint: [""]
before_script:
- *initENV
script:
- echo "Perform repo checkout"
- cd ${CI_PROJECT_DIR}
- |
su secous -c "
mkdir repo_checkout
cd repo_checkout
sh ../.gitlab-ci/scripts/build_setup.sh $GITBOT_TOKEN $CI_REPOSITORY_URL $BUILD_BRANCH
"
cache:
- key: ${CI_PIPELINE_ID}-${CI_JOB_NAME}
policy: push
paths:
- ${CI_PROJECT_DIR}/repo_checkout
allow_failure: true
# -----------------------------------
# Stage: build
# -----------------------------------
.build:
extends:
- .infrastructure
rules:
- *build_rule
stage: build stage: build
timeout: 6h timeout: 6h
tags: tags:
...@@ -41,24 +86,18 @@ workflow: ...@@ -41,24 +86,18 @@ workflow:
image: image:
name: ${CI_IMAGE_YOCTO} name: ${CI_IMAGE_YOCTO}
entrypoint: [""] entrypoint: [""]
cache: {} cache: &cache
# Get prepared repo from cache
- key: ${CI_PIPELINE_ID}-repo_checkout
policy: pull
paths:
- ${CI_PROJECT_DIR}/repo_checkout
needs: ["repo_checkout"]
retry: 2 retry: 2
before_script: before_script:
- *initENV - *initENV
script: script:
# init repository and generate configuration files for bitbake
# checkout
- export BASEDIR=$PWD
- export EULA=1
- BUILD_BRANCH=${MASTER_BRANCH}
- | - |
if [ ${CI_PIPELINE_SOURCE} == "parent_pipeline" ]; then
BUILD_BRANCH="${CI_COMMIT_REF_NAME}"
fi
if [ ! -z ${CI_COMMIT_TAG} ]; then
BUILD_BRANCH="refs/tags/${CI_COMMIT_TAG}"
fi
echo "This is the manifest repository URL used for the build: ${CI_REPOSITORY_URL}" echo "This is the manifest repository URL used for the build: ${CI_REPOSITORY_URL}"
echo "This is the manifest branch used for the build: ${BUILD_BRANCH}" echo "This is the manifest branch used for the build: ${BUILD_BRANCH}"
echo "This is the board for which the build will be performed: ${BOARD}" echo "This is the board for which the build will be performed: ${BOARD}"
...@@ -66,7 +105,7 @@ workflow: ...@@ -66,7 +105,7 @@ workflow:
echo "This is the image name will be assigned to software artifacts: ${IMAGE_NAME}" echo "This is the image name will be assigned to software artifacts: ${IMAGE_NAME}"
- | - |
su secous -c " su secous -c "
sh .gitlab-ci/scripts/build_setup.sh $GITBOT_TOKEN $CI_REPOSITORY_URL $BUILD_BRANCH $DEFCONFIG_FILE $RECIPE_NAME mv repo_checkout/* . && mv repo_checkout/.repo .
git -C .repo/manifests rev-parse --short HEAD > $BASEDIR/commit_sha.txt git -C .repo/manifests rev-parse --short HEAD > $BASEDIR/commit_sha.txt
. ./seco-setup.sh -d ${DEFCONFIG_FILE}; . ./seco-setup.sh -d ${DEFCONFIG_FILE};
. ./seco-setup.sh -c; . ./seco-setup.sh -c;
......
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
GITBOT_TOKEN=$1 GITBOT_TOKEN=$1
CI_REPOSITORY_URL=$2 CI_REPOSITORY_URL=$2
BUILD_BRANCH=$3 BUILD_BRANCH=$3
DEFCONFIG_FILE=$4
RECIPE_NAME=$5
git config --global url.https://github.com/.insteadOf git://github.com/ git config --global url.https://github.com/.insteadOf git://github.com/
git config --global url.https://gitlab-ci-token:${GITBOT_TOKEN}@git.seco.com/.insteadOf https://git.seco.com/ git config --global url.https://gitlab-ci-token:${GITBOT_TOKEN}@git.seco.com/.insteadOf https://git.seco.com/
...@@ -14,7 +12,7 @@ repo sync -j$(nproc) --fetch-submodules --no-clone-bundle ...@@ -14,7 +12,7 @@ repo sync -j$(nproc) --fetch-submodules --no-clone-bundle
RECIPES="u-boot-seco-rk linux-seco-rk u-boot-seco-imx linux-seco-imx imx-mkimage u-boot-seco-mtk linux-seco-mtk" RECIPES="u-boot-seco-rk linux-seco-rk u-boot-seco-imx linux-seco-imx imx-mkimage u-boot-seco-mtk linux-seco-mtk"
for str in $RECIPES; do for str in $RECIPES; do
if echo "$BUILD_BRANCH" | grep -q "$str"; then if echo "$BUILD_BRANCH" | grep -q "$str"; then
filename=$(find layers/meta-seco-imx layers/meta-seco-rk -name "*$str*" -type f -exec grep -l "SRCBRANCH = " {} \;) filename=$(find layers/meta-seco/meta-seco-imx layers/meta-seco/meta-seco-rk layers/meta-seco/meta-seco-mtk layers/meta-seco/meta-seco-qcom -name "*$str*" -type f -exec grep -l "SRCBRANCH = " {} \;)
echo $filename echo $filename
RECIPE_BRANCH=$(echo "$BUILD_BRANCH" | sed "s|.*$str/||"i | sed 's/\/into.*//') RECIPE_BRANCH=$(echo "$BUILD_BRANCH" | sed "s|.*$str/||"i | sed 's/\/into.*//')
sed -i "s/\(SRCBRANCH = \).*/\1\"$(echo "$RECIPE_BRANCH" | sed 's/[\/&]/\\&/g')\"/" $filename sed -i "s/\(SRCBRANCH = \).*/\1\"$(echo "$RECIPE_BRANCH" | sed 's/[\/&]/\\&/g')\"/" $filename
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment