[Buildroot] [PATCH v4 2/3] .gitlab-ci.yml: prepare to reuse scripts

Ricardo Martincoski ricardo.martincoski at gmail.com
Mon Apr 8 03:22:54 UTC 2019


Use local variables to pass the name of the defconfig to build or
runtime test to run.
This change allows upcoming new jobs to reuse those scripts.

Signed-off-by: Ricardo Martincoski <ricardo.martincoski at gmail.com>
Cc: Arnout Vandecappelle <arnout at mind.be>
Cc: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
Changes v3 -> v4:
  - rebase after removing one patch from the series;

Changes v2 -> v3:
  - new patch, trying to make the review/testing easier;

For test purposes I created a commit that makes all defconfigs and
runtime tests to echo the command that would be called instead of
actually calling it and then I asked Gitlab CI to run:
 - only the check-* jobs:
https://gitlab.com/RicardoMartincoski/buildroot/pipelines/55632102
 - all defconfigs and all check-* jobs:
https://gitlab.com/RicardoMartincoski/buildroot/pipelines/55632126
 - all runtime tests and all check-* jobs:
https://gitlab.com/RicardoMartincoski/buildroot/pipelines/55632153
 - all jobs (using a tag):
https://gitlab.com/RicardoMartincoski/buildroot/pipelines/55632193
---
 .gitlab-ci.yml    | 23 ++++++++++++++++-------
 .gitlab-ci.yml.in | 23 ++++++++++++++++-------
 2 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 58166364ad..44fdb94f65 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -36,8 +36,8 @@ check-package:
 
 .defconfig_script:
     script:
-        - echo 'Configure Buildroot'
-        - make ${CI_JOB_NAME}
+        - echo "Configure Buildroot for ${DEFCONFIG_NAME}"
+        - make ${DEFCONFIG_NAME}
         - echo 'Build buildroot'
         - |
             make > >(tee build.log |grep '>>>') 2>&1 || {
@@ -54,6 +54,8 @@ check-package:
         - triggers
         - tags
         - /-defconfigs$/
+    before_script:
+        - DEFCONFIG_NAME=${CI_JOB_NAME}
     artifacts:
         when: always
         expire_in: 2 weeks
@@ -65,18 +67,25 @@ check-package:
             - output/build/packages-file-list.txt
             - output/build/*/.config
 
+.runtime_test_script:
+    # Keep build directories so the rootfs can be an artifact of the job. The
+    # runner will clean up those files for us.
+    # Multiply every emulator timeout by 10 to avoid sporadic failures in
+    # elastic runners.
+    script:
+        - echo "Starting runtime test ${TEST_CASE_NAME}"
+        - ./support/testing/run-tests -o test-output/ -d test-dl/ -k --timeout-multiplier 10 ${TEST_CASE_NAME}
+
 .runtime_test:
+    extends: .runtime_test_script
     # Running the runtime tests for every push is too much, so limit to
     # explicit triggers through the API.
     only:
         - triggers
         - tags
         - /-runtime-tests$/
-    # Keep build directories so the rootfs can be an artifact of the job. The
-    # runner will clean up those files for us.
-    # Multiply every emulator timeout by 10 to avoid sporadic failures in
-    # elastic runners.
-    script: ./support/testing/run-tests -o test-output/ -d test-dl/ -k --timeout-multiplier 10 ${CI_JOB_NAME}
+    before_script:
+        - TEST_CASE_NAME=${CI_JOB_NAME}
     artifacts:
         when: always
         expire_in: 2 weeks
diff --git a/.gitlab-ci.yml.in b/.gitlab-ci.yml.in
index f519338d63..0b4c65b258 100644
--- a/.gitlab-ci.yml.in
+++ b/.gitlab-ci.yml.in
@@ -36,8 +36,8 @@ check-package:
 
 .defconfig_script:
     script:
-        - echo 'Configure Buildroot'
-        - make ${CI_JOB_NAME}
+        - echo "Configure Buildroot for ${DEFCONFIG_NAME}"
+        - make ${DEFCONFIG_NAME}
         - echo 'Build buildroot'
         - |
             make > >(tee build.log |grep '>>>') 2>&1 || {
@@ -54,6 +54,8 @@ check-package:
         - triggers
         - tags
         - /-defconfigs$/
+    before_script:
+        - DEFCONFIG_NAME=${CI_JOB_NAME}
     artifacts:
         when: always
         expire_in: 2 weeks
@@ -65,18 +67,25 @@ check-package:
             - output/build/packages-file-list.txt
             - output/build/*/.config
 
+.runtime_test_script:
+    # Keep build directories so the rootfs can be an artifact of the job. The
+    # runner will clean up those files for us.
+    # Multiply every emulator timeout by 10 to avoid sporadic failures in
+    # elastic runners.
+    script:
+        - echo "Starting runtime test ${TEST_CASE_NAME}"
+        - ./support/testing/run-tests -o test-output/ -d test-dl/ -k --timeout-multiplier 10 ${TEST_CASE_NAME}
+
 .runtime_test:
+    extends: .runtime_test_script
     # Running the runtime tests for every push is too much, so limit to
     # explicit triggers through the API.
     only:
         - triggers
         - tags
         - /-runtime-tests$/
-    # Keep build directories so the rootfs can be an artifact of the job. The
-    # runner will clean up those files for us.
-    # Multiply every emulator timeout by 10 to avoid sporadic failures in
-    # elastic runners.
-    script: ./support/testing/run-tests -o test-output/ -d test-dl/ -k --timeout-multiplier 10 ${CI_JOB_NAME}
+    before_script:
+        - TEST_CASE_NAME=${CI_JOB_NAME}
     artifacts:
         when: always
         expire_in: 2 weeks
-- 
2.17.1



More information about the buildroot mailing list