xref: /openbmc/qemu/.gitlab-ci.d/opensbi.yml (revision ab0c7fb2)
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    # Scheduled runs on mainline don't get pipelines except for the special Coverity job
28    - if: '$CI_PROJECT_NAMESPACE == $QEMU_CI_UPSTREAM && $CI_PIPELINE_SOURCE == "schedule"'
29      when: never
30
31    # Run if any files affecting the build output are touched
32    - changes:
33        - .gitlab-ci.d/opensbi.yml
34        - .gitlab-ci.d/opensbi/Dockerfile
35        - roms/opensbi/*
36      when: on_success
37
38    # Run if the branch/tag starts with 'opensbi'
39    - if: '$CI_COMMIT_REF_NAME =~ /^opensbi/'
40      when: on_success
41
42    # Run if the last commit msg contains 'OpenSBI' (case insensitive)
43    - if: '$CI_COMMIT_MESSAGE =~ /opensbi/i'
44      when: on_success
45
46docker-opensbi:
47  extends: .opensbi_job_rules
48  stage: containers
49  image: docker:latest
50  services:
51    - docker:dind
52  variables:
53    GIT_DEPTH: 3
54    IMAGE_TAG: $CI_REGISTRY_IMAGE:opensbi-cross-build
55  before_script:
56    - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
57    - until docker info; do sleep 1; done
58  script:
59    - docker pull $IMAGE_TAG || true
60    - docker build --cache-from $IMAGE_TAG --tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
61                                           --tag $IMAGE_TAG .gitlab-ci.d/opensbi
62    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
63    - docker push $IMAGE_TAG
64
65build-opensbi:
66  extends: .opensbi_job_rules
67  stage: build
68  needs: ['docker-opensbi']
69  artifacts:
70    when: on_success
71    paths: # 'artifacts.zip' will contains the following files:
72      - pc-bios/opensbi-riscv32-generic-fw_dynamic.bin
73      - pc-bios/opensbi-riscv64-generic-fw_dynamic.bin
74      - opensbi32-generic-stdout.log
75      - opensbi32-generic-stderr.log
76      - opensbi64-generic-stdout.log
77      - opensbi64-generic-stderr.log
78  image: $CI_REGISTRY_IMAGE:opensbi-cross-build
79  variables:
80    GIT_DEPTH: 3
81  script: # Clone the required submodules and build OpenSBI
82    - git submodule update --init roms/opensbi
83    - export JOBS=$(($(getconf _NPROCESSORS_ONLN) + 1))
84    - echo "=== Using ${JOBS} simultaneous jobs ==="
85    - make -j${JOBS} -C roms/opensbi clean
86    - make -j${JOBS} -C roms opensbi32-generic 2>&1 1>opensbi32-generic-stdout.log | tee -a opensbi32-generic-stderr.log >&2
87    - make -j${JOBS} -C roms/opensbi clean
88    - make -j${JOBS} -C roms opensbi64-generic 2>&1 1>opensbi64-generic-stdout.log | tee -a opensbi64-generic-stderr.log >&2
89