qemu/.gitlab-ci.d/opensbi.yml
<<
>>
Prefs
   1# All jobs needing docker-opensbi must use the same rules it uses.
   2.opensbi_job_rules:
   3  rules:
   4    # Forks don't get pipelines unless QEMU_CI=1 or QEMU_CI=2 is set
   5    - if: '$QEMU_CI != "1" && $QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
   6      when: never
   7
   8    # In forks, if QEMU_CI=1 is set, then create manual job
   9    # if any files affecting the build output are touched
  10    - if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project"'
  11      changes:
  12        - .gitlab-ci.d/opensbi.yml
  13        - .gitlab-ci.d/opensbi/Dockerfile
  14        - roms/opensbi/*
  15      when: manual
  16
  17    # In forks, if QEMU_CI=1 is set, then create manual job
  18    # if the branch/tag starts with 'opensbi'
  19    - if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_REF_NAME =~ /^opensbi/'
  20      when: manual
  21
  22    # In forks, if QEMU_CI=1 is set, then create manual job
  23    # if the last commit msg contains 'OpenSBI' (case insensitive)
  24    - if: '$QEMU_CI == "1" && $CI_PROJECT_NAMESPACE != "qemu-project" && $CI_COMMIT_MESSAGE =~ /opensbi/i'
  25      when: manual
  26
  27    # Run if any files affecting the build output are touched
  28    - changes:
  29        - .gitlab-ci.d/opensbi.yml
  30        - .gitlab-ci.d/opensbi/Dockerfile
  31        - roms/opensbi/*
  32      when: on_success
  33
  34    # Run if the branch/tag starts with 'opensbi'
  35    - if: '$CI_COMMIT_REF_NAME =~ /^opensbi/'
  36      when: on_success
  37
  38    # Run if the last commit msg contains 'OpenSBI' (case insensitive)
  39    - if: '$CI_COMMIT_MESSAGE =~ /opensbi/i'
  40      when: on_success
  41
  42docker-opensbi:
  43  extends: .opensbi_job_rules
  44  stage: containers
  45  image: docker:stable
  46  services:
  47    - docker:stable-dind
  48  variables:
  49    GIT_DEPTH: 3
  50    IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build
  51    # We don't use TLS
  52    DOCKER_HOST: tcp://docker:2375
  53    DOCKER_TLS_CERTDIR: ""
  54  before_script:
  55    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  56  script:
  57    - docker pull $IMAGE_TAG || true
  58    - docker build --cache-from $IMAGE_TAG --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
  59                                           --tag $IMAGE_TAG .gitlab-ci.d/opensbi
  60    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
  61    - docker push $IMAGE_TAG
  62
  63build-opensbi:
  64  extends: .opensbi_job_rules
  65  stage: build
  66  needs: ['docker-opensbi']
  67  artifacts:
  68    paths: # 'artifacts.zip' will contains the following files:
  69      - pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
  70      - pc-bios/opensbi-riscv64-generic-fw_dynamic.bin
  71      - opensbi32-generic-stdout.log
  72      - opensbi32-generic-stderr.log
  73      - opensbi64-generic-stdout.log
  74      - opensbi64-generic-stderr.log
  75  image: $CI_REGISTRY_IMAGE:opensbi-cross-build
  76  variables:
  77    GIT_DEPTH: 3
  78  script: # Clone the required submodules and build OpenSBI
  79    - git submodule update --init roms/opensbi
  80    - export JOBS=$(($(getconf _NPROCESSORS_ONLN) + 1))
  81    - echo "=== Using ${JOBS} simultaneous jobs ==="
  82    - make -j${JOBS} -C roms/opensbi clean
  83    - make -j${JOBS} -C roms opensbi32-generic 2>&1 1>opensbi32-generic-stdout.log | tee -a opensbi32-generic-stderr.log >&2
  84    - make -j${JOBS} -C roms/opensbi clean
  85    - make -j${JOBS} -C roms opensbi64-generic 2>&1 1>opensbi64-generic-stdout.log | tee -a opensbi64-generic-stderr.log >&2
  86