From 0bafbfed7bd7dc5caa937ed455b225e40aea2002 Mon Sep 17 00:00:00 2001 From: Lup Yuen Lee Date: Tue, 15 Oct 2024 16:05:55 +0800 Subject: [PATCH] CI: Validate all defconfig files before running any builds Currently, CI Build Jobs will validate the `defconfig` file just before compiling the NuttX Target (like `rv-virt:nsh`). This means that the Build Job might run for a while, before hitting a `defconfig` error and failing much later. This PR updates the CI Workflow `build.yml` to validate all `defconfig` files before running any builds. This means that errors in the `defconfig` files will be flagged earlier. And the Build Job will terminate (with an error) before any build begins. This behaviour is helpful for resolving CI Build Issues quickly. The code is derived from `tools/testbuild.sh`. The enhancement was suggested here: https://github.com/apache/nuttx/issues/14259 --- .github/workflows/build.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index de802ef83f79a..4eb7ffe0968fa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -181,6 +181,37 @@ jobs: export ARTIFACTDIR=`pwd`/buildartifacts git config --global --add safe.directory /github/workspace/sources/nuttx git config --global --add safe.directory /github/workspace/sources/apps + + # Validate the defconfig files + cp -r sources/nuttx sources/nuttx-validate + pushd sources/nuttx-validate + testfile=tools/ci/testlist/${{matrix.boards}}.dat + echo Validating targets in $testfile + testlist=`grep -v -E "^(-|#)|^[C|c][M|m][A|a][K|k][E|e]" $testfile || true` + for line in $testlist; do + firstch=${line:0:1} + if [ "X$firstch" == "X/" ]; then + dir=`echo $line | cut -d',' -f1` + list=`find boards$dir -name defconfig | cut -d'/' -f4,6` + for config in ${list}; do + echo ./tools/refresh.sh --silent $config + if ! ./tools/refresh.sh --silent $config; then + echo Error: $config:1:1: error: $config is configured incorrectly. To fix it, run '"'tools/refresh.sh $config'"' + fail=1 + fi + done + fi + done + popd + rm -rf sources/nuttx-validate + + # Quit if the defconfig validation failed + if [[ "$fail" == "1" ]]; then + echo Error: $testfile:1:1: error: Quitting, defconfig validation failed for $testfile + exit 1 + fi + + # Build the targets cd sources/nuttx/tools/ci if [ "X${{matrix.boards}}" = "Xcodechecker" ]; then ./cibuild.sh -c -A -N -R --codechecker testlist/${{matrix.boards}}.dat @@ -385,4 +416,4 @@ jobs: with: name: msvc-builds path: buildartifacts/ - continue-on-error: true \ No newline at end of file + continue-on-error: true