Signed-off-by: Jon Mason jon.mason@arm.com --- .gitlab-ci.yml | 78 +++++++++++++++++++++++++++++++++++++++++++++++ ci/check-warnings | 19 ++++++++++++ ci/jobs-to-kas | 16 ++++++++++ ci/logging.yml | 13 ++++++++ ci/update-repos | 40 ++++++++++++++++++++++++ 5 files changed, 166 insertions(+) create mode 100644 .gitlab-ci.yml create mode 100755 ci/check-warnings create mode 100755 ci/jobs-to-kas create mode 100644 ci/logging.yml create mode 100755 ci/update-repos
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 000000000000..8be7d551454a --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,78 @@ +image: ghcr.io/siemens/kas/kas:3.2 + +variables: + CPU_REQUEST: "" + DEFAULT_TAG: "" + # These are needed as the k8s executor doesn't respect the container + # entrypoint by default + FF_USE_LEGACY_KUBERNETES_EXECUTION_STRATEGY: 0 + FF_KUBERNETES_HONOR_ENTRYPOINT: 1 + +stages: + - prep + - build + +# Common job fragment to get a worker ready +.setup: + tags: + - $DEFAULT_TAG + stage: build + interruptible: true + variables: + KAS_WORK_DIR: $CI_PROJECT_DIR/work + KAS_REPO_REF_DIR: $CI_BUILDS_DIR/persist/repos + SSTATE_DIR: $CI_BUILDS_DIR/persist/sstate + DL_DIR: $CI_BUILDS_DIR/persist/downloads + BB_LOGCONFIG: $CI_PROJECT_DIR/ci/logging.yml + before_script: + - echo KAS_WORK_DIR = $KAS_WORK_DIR + - echo SSTATE_DIR = $SSTATE_DIR + - echo DL_DIR = $DL_DIR + - rm -rf $KAS_WORK_DIR + - mkdir --verbose --parents $KAS_WORK_DIR $KAS_REPO_REF_DIR $SSTATE_DIR $DL_DIR + - sudo apt-get update && sudo apt install -y libtinfo5 + +# Generalised fragment to do a Kas build +.build: + extends: .setup + variables: + KUBERNETES_CPU_REQUEST: $CPU_REQUEST + script: + - KASFILES=$(./ci/jobs-to-kas "$CI_JOB_NAME") + - kas shell --update --force-checkout $KASFILES -c 'cat conf/*.conf' + - kas build $KASFILES + - ./ci/check-warnings $KAS_WORK_DIR/build/warnings.log + artifacts: + name: "logs" + when: on_failure + paths: + - $CI_PROJECT_DIR/work/build/tmp/work*/**/temp/log.do_*.* + +# +# Prep stage, update repositories once +# +update-repos: + extends: .setup + stage: prep + script: + - flock --verbose --timeout 60 $KAS_REPO_REF_DIR ./ci/update-repos + +check-layers: + extends: .setup + coverage: '/Coverage: \d+/' + script: + - kas shell --update --force-checkout kas/base.yml --command \ + "yocto-check-layer-wrapper $CI_PROJECT_DIR -n --dependency $KAS_WORK_DIR/meta-arm/meta-arm $KAS_WORK_DIR/meta-arm/meta-arm-toolchain" + +# +# Build stage, the actual build jobs +# + +morello-bsp: + extends: .build + +morello-linux-glibc: + extends: .build + +morello-linux-musl: + extends: .build diff --git a/ci/check-warnings b/ci/check-warnings new file mode 100755 index 000000000000..9d080103b50b --- /dev/null +++ b/ci/check-warnings @@ -0,0 +1,19 @@ +#! /bin/bash + +# Expects the path to a log file as $1, and if this file has any content +# then display the contents and exit with an error code. + +set -e -u + +LOGFILE=$1 + +LINES=$(grep --invert-match "relocations in .text" $LOGFILE | wc -l) +if test "$LINES" -ne 0; then + echo ============================== + echo The build had warnings/errors: + echo ============================== + cat $LOGFILE + exit 1 +fi + +exit 0 diff --git a/ci/jobs-to-kas b/ci/jobs-to-kas new file mode 100755 index 000000000000..95df56c74a76 --- /dev/null +++ b/ci/jobs-to-kas @@ -0,0 +1,16 @@ +#! /bin/bash + +# This script is expecting an input of machine name, optionally followed by a +# colon and a list of one or more parameters separated by commas between +# brackets. For example, the following are acceptable: +# qemu-x86 +# qemu-cortex-m3: [testimage] +# qemu-cortex-a53: [zephyr-toolchain, testimage] +# +# Turn this list into a series of yml files separated by colons to pass to kas + +set -e -u + +FILES="kas/$(echo $1 | cut -d ':' -f 1).yml" + +echo $FILES diff --git a/ci/logging.yml b/ci/logging.yml new file mode 100644 index 000000000000..3af10295f8f3 --- /dev/null +++ b/ci/logging.yml @@ -0,0 +1,13 @@ +# Python logging configuration to write all warnings to a separate file +version: 1 + +handlers: + warnings: + class: logging.FileHandler + level: WARNING + filename: warnings.log + formatter: BitBake.logfileFormatter + +loggers: + BitBake: + handlers: [warnings] diff --git a/ci/update-repos b/ci/update-repos new file mode 100755 index 000000000000..fa638aad2efb --- /dev/null +++ b/ci/update-repos @@ -0,0 +1,40 @@ +#! /usr/bin/env python3 + +# Update clones of the repositories we need in KAS_REPO_REF_DIR to speed up fetches + +import sys +import os +import subprocess +import pathlib + +def repo_shortname(url): + # Taken from Kas (Repo.__getattr__) to ensure the logic is right + from urllib.parse import urlparse + url = urlparse(url) + return ('{url.netloc}{url.path}' + .format(url=url) + .replace('@', '.') + .replace(':', '.') + .replace('/', '.') + .replace('*', '.')) + +repositories = ( + "https://git.yoctoproject.org/git/poky", + "https://git.openembedded.org/meta-openembedded", +) + +if __name__ == "__main__": + if "KAS_REPO_REF_DIR" not in os.environ: + print("KAS_REPO_REF_DIR needs to be set") + sys.exit(1) + + base_repodir = pathlib.Path(os.environ["KAS_REPO_REF_DIR"]) + + for repo in repositories: + repodir = base_repodir / repo_shortname(repo) + if repodir.exists(): + print("Updating %s..." % repo) + subprocess.run(["git", "-C", repodir, "fetch"], check=True) + else: + print("Cloning %s..." % repo) + subprocess.run(["git", "clone", "--bare", repo, repodir], check=True)