aboutsummaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: 67e20f432844760c0ada4cc0bc0992fd689afe59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# SPDX-License-Identifier: GPL-2.0+

variables:
  DEFAULT_TAG: ""
  MIRROR_DOCKER: docker.io

default:
  tags:
    - ${DEFAULT_TAG}

# Grab our configured image.  The source for this is found
# in the u-boot tree at tools/docker/Dockerfile
image: ${MIRROR_DOCKER}/trini/u-boot-gitlab-ci-runner:jammy-20230624-20Jul2023

# We run some tests in different order, to catch some failures quicker.
stages:
  - testsuites

.buildman_and_testpy_template: &buildman_and_testpy_dfn
  stage: test.py
  retry: 2 # QEMU may be too slow, etc.
  before_script:
    # Clone uboot-test-hooks
    - git config --global --add safe.directory "${CI_PROJECT_DIR}"
    - git clone --depth=1 https://source.denx.de/u-boot/u-boot-test-hooks /tmp/uboot-test-hooks
    - ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
    - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
    - grub-mkimage --prefix="" -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
    - grub-mkimage --prefix="" -o ~/grub_x64.efi -O x86_64-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
    - if [[ "${TEST_PY_BD}" == "qemu-riscv32_spl" ]]; then
        wget -O - https://github.com/riscv-software-src/opensbi/releases/download/v1.2/opensbi-1.2-rv-bin.tar.xz | tar -C /tmp -xJ;
        export OPENSBI=/tmp/opensbi-1.2-rv-bin/share/opensbi/ilp32/generic/firmware/fw_dynamic.bin;
      fi
    - if [[ "${TEST_PY_BD}" == "qemu-riscv64_spl" ]] || [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then
        wget -O - https://github.com/riscv-software-src/opensbi/releases/download/v1.2/opensbi-1.2-rv-bin.tar.xz | tar -C /tmp -xJ;
        export OPENSBI=/tmp/opensbi-1.2-rv-bin/share/opensbi/lp64/generic/firmware/fw_dynamic.bin;
      fi

  after_script:
    - cp -v /tmp/${TEST_PY_BD}/*.{html,css} .
    - rm -rf /tmp/uboot-test-hooks /tmp/venv
  script:
    # If we've been asked to use clang only do one configuration.
    - export UBOOT_TRAVIS_BUILD_DIR=/tmp/${TEST_PY_BD}
    - echo BUILD_ENV ${BUILD_ENV}
    - if [ -n "${BUILD_ENV}" ]; then
        export ${BUILD_ENV};
      fi
    - tools/buildman/buildman -o ${UBOOT_TRAVIS_BUILD_DIR} -w -E -W -e
        --board ${TEST_PY_BD} ${OVERRIDE}
    - cp ~/grub_x86.efi $UBOOT_TRAVIS_BUILD_DIR/
    - cp ~/grub_x64.efi $UBOOT_TRAVIS_BUILD_DIR/
    - cp /opt/grub/grubriscv64.efi $UBOOT_TRAVIS_BUILD_DIR/grub_riscv64.efi
    - cp /opt/grub/grubaa64.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm64.efi
    - cp /opt/grub/grubarm.efi $UBOOT_TRAVIS_BUILD_DIR/grub_arm.efi
    # create sdcard / spi-nor images for sifive unleashed using genimage
    - if [[ "${TEST_PY_BD}" == "sifive_unleashed" ]]; then
        mkdir -p root;
        cp ${UBOOT_TRAVIS_BUILD_DIR}/spl/u-boot-spl.bin .;
        cp ${UBOOT_TRAVIS_BUILD_DIR}/u-boot.itb .;
        rm -rf tmp;
        genimage --inputpath . --config board/sifive/unleashed/genimage_sdcard.cfg;
        cp images/sdcard.img ${UBOOT_TRAVIS_BUILD_DIR}/;
        rm -rf tmp;
        genimage --inputpath . --config board/sifive/unleashed/genimage_spi-nor.cfg;
        cp images/spi-nor.img ${UBOOT_TRAVIS_BUILD_DIR}/;
      fi
    - if [[ "${TEST_PY_BD}" == "coreboot" ]]; then
        wget -O -
          "https://drive.google.com/uc?id=1x6nrtWIyIRPLS2cQBwYTnT2TbOI8UjmM&export=download" |
          xz -dc >${UBOOT_TRAVIS_BUILD_DIR}/coreboot.rom;
        wget -O -
          "https://drive.google.com/uc?id=149Cz-5SZXHNKpi9xg6R_5XITWohu348y&export=download" >
          cbfstool;
        chmod a+x cbfstool;
        ./cbfstool ${UBOOT_TRAVIS_BUILD_DIR}/coreboot.rom add-flat-binary -f ${UBOOT_TRAVIS_BUILD_DIR}/u-boot.bin -n fallback/payload -c LZMA -l 0x1110000 -e 0x1110000;
      fi
    - virtualenv -p /usr/bin/python3 /tmp/venv
    - . /tmp/venv/bin/activate
    - pip install -r test/py/requirements.txt
    # "${var:+"-k $var"}" expands to "" if $var is empty, "-k $var" if not
    - export PATH=/opt/qemu/bin:/tmp/uboot-test-hooks/bin:${PATH};
      export PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci;
      ./test/py/test.py -ra --bd ${TEST_PY_BD} ${TEST_PY_ID}
        ${TEST_PY_TEST_SPEC:+"-k ${TEST_PY_TEST_SPEC}"}
        --build-dir "$UBOOT_TRAVIS_BUILD_DIR"
  artifacts:
    when: always
    paths:
      - "*.html"
      - "*.css"
    expire_in: 1 week

Run binman, buildman, dtoc, Kconfig and patman testsuites:
  stage: testsuites
  script:
    - git config --global user.name "GitLab CI Runner";
      git config --global user.email trini@konsulko.com;
      git config --global --add safe.directory "${CI_PROJECT_DIR}";
      export USER=gitlab;
      virtualenv -p /usr/bin/python3 /tmp/venv;
      . /tmp/venv/bin/activate;
      pip install -r test/py/requirements.txt;
      pip install -r tools/buildman/requirements.txt;
      export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only;
      export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt";
      export PATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc:${PATH}";
      set +e;
      ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
        --board tools-only;
      set -e;
      ./tools/binman/binman --toolpath ${UBOOT_TRAVIS_BUILD_DIR}/tools test;
      ./tools/buildman/buildman -t;
      ./tools/dtoc/dtoc -t;
      ./tools/patman/patman test;
      make testconfig

# Check for any pylint regressions
Run pylint:
  stage: testsuites
  script:
    - git config --global --add safe.directory "${CI_PROJECT_DIR}"
    - pip install -r test/py/requirements.txt
    - pip install -r tools/buildman/requirements.txt
    - pip install asteval pylint==2.12.2 pyopenssl
    - export PATH=${PATH}:~/.local/bin
    - echo "[MASTER]" >> .pylintrc
    - echo "load-plugins=pylint.extensions.docparams" >> .pylintrc
    - export UBOOT_TRAVIS_BUILD_DIR=/tmp/tools-only
    - set +e
    - ./tools/buildman/buildman -T0 -o ${UBOOT_TRAVIS_BUILD_DIR} -w
        --board tools-only
    - set -e
    - pylint --version
    - export PYTHONPATH="${UBOOT_TRAVIS_BUILD_DIR}/scripts/dtc/pylibfdt"
    - make pylint_err