@@ -15,13 +15,13 @@ function check_requirements { # check_requirements <sketchdir> <sdkconfig_path>
1515 local requirements
1616 local requirements_or
1717
18- if [ ! -f " $sdkconfig_path " ] || [ ! -f " $sketchdir /ci.json " ]; then
19- echo " WARNING: sdkconfig or ci.json not found. Assuming requirements are met." 1>&2
18+ if [ ! -f " $sdkconfig_path " ] || [ ! -f " $sketchdir /ci.yml " ]; then
19+ echo " WARNING: sdkconfig or ci.yml not found. Assuming requirements are met." 1>&2
2020 # Return 1 on error to force the sketch to be built and fail. This way the
2121 # CI will fail and the user will know that the sketch has a problem.
2222 else
2323 # Check if the sketch requires any configuration options (AND)
24- requirements=$( jq -r ' .requires[]? // empty ' " $sketchdir /ci.json " )
24+ requirements=$( yq eval ' .requires[]' " $sketchdir /ci.yml " 2> /dev/null )
2525 if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
2626 for requirement in $requirements ; do
2727 requirement=$( echo " $requirement " | xargs)
@@ -33,7 +33,7 @@ function check_requirements { # check_requirements <sketchdir> <sdkconfig_path>
3333 fi
3434
3535 # Check if the sketch requires any configuration options (OR)
36- requirements_or=$( jq -r ' .requires_any[]? // empty ' " $sketchdir /ci.json " )
36+ requirements_or=$( yq eval ' .requires_any[]' " $sketchdir /ci.yml " 2> /dev/null )
3737 if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
3838 local found=false
3939 for requirement in $requirements_or ; do
@@ -122,13 +122,13 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
122122 # precedence. Note that the following logic also falls to the default
123123 # parameters if no arguments were passed and no file was found.
124124
125- if [ -z " $options " ] && [ -f " $sketchdir " /ci.json ]; then
125+ if [ -z " $options " ] && [ -f " $sketchdir " /ci.yml ]; then
126126 # The config file could contain multiple FQBNs for one chip. If
127127 # that's the case we build one time for every FQBN.
128128
129- len=$( jq -r --arg target " $target " ' .fqbn[$ target] | length' " $sketchdir " /ci.json )
129+ len=$( yq eval " .fqbn. ${ target} | length" " $sketchdir " /ci.yml 2> /dev/null || echo 0 )
130130 if [ " $len " -gt 0 ]; then
131- fqbn=$( jq -r --arg target " $target " ' .fqbn[$ target] | sort' " $sketchdir " /ci.json )
131+ fqbn=$( yq eval " .fqbn. ${ target} | sort | @json " " $sketchdir " /ci.yml )
132132 fi
133133 fi
134134
@@ -138,8 +138,8 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
138138
139139 len=1
140140
141- if [ -f " $sketchdir " /ci.json ]; then
142- fqbn_append=$( jq -r ' .fqbn_append' " $sketchdir " /ci.json )
141+ if [ -f " $sketchdir " /ci.yml ]; then
142+ fqbn_append=$( yq eval ' .fqbn_append' " $sketchdir " /ci.yml 2> /dev/null )
143143 if [ " $fqbn_append " == " null" ]; then
144144 fqbn_append=" "
145145 fi
@@ -229,9 +229,9 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
229229 sketchname=$( basename " $sketchdir " )
230230 local has_requirements
231231
232- if [ -f " $sketchdir " /ci.json ]; then
232+ if [ -f " $sketchdir " /ci.yml ]; then
233233 # If the target is listed as false, skip the sketch. Otherwise, include it.
234- is_target=$( jq -r --arg target " $target " ' .targets[$ target] ' " $sketchdir " /ci.json )
234+ is_target=$( yq eval " .targets. ${ target} " " $sketchdir " /ci.yml 2> /dev/null )
235235 if [[ " $is_target " == " false" ]]; then
236236 echo " Skipping $sketchname for target $target "
237237 exit 0
@@ -244,7 +244,7 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
244244 fi
245245 fi
246246
247- # Install libraries from ci.json if they exist
247+ # Install libraries from ci.yml if they exist
248248 install_libs -ai " $ide_path " -s " $sketchdir "
249249 install_result=$?
250250 if [ $install_result -ne 0 ]; then
@@ -394,9 +394,9 @@ function count_sketches { # count_sketches <path> [target] [ignore-requirements]
394394
395395 if [[ " $sketchdirname .ino" != " $sketchname " ]]; then
396396 continue
397- elif [[ -n $target ]] && [[ -f $sketchdir /ci.json ]]; then
397+ elif [[ -n $target ]] && [[ -f $sketchdir /ci.yml ]]; then
398398 # If the target is listed as false, skip the sketch. Otherwise, include it.
399- is_target=$( jq -r --arg target " $target " ' .targets[$ target] ' " $sketchdir " /ci.json )
399+ is_target=$( yq eval " .targets. ${ target} " " $sketchdir " /ci.yml 2> /dev/null )
400400 if [[ " $is_target " == " false" ]]; then
401401 continue
402402 fi
@@ -637,38 +637,38 @@ function install_libs { # install_libs <ide_path> <sketchdir> [-v]
637637 return 1
638638 fi
639639
640- if [ ! -f " $sketchdir /ci.json " ]; then
641- [ " $verbose " = true ] && echo " No ci.json found in $sketchdir , skipping library installation"
640+ if [ ! -f " $sketchdir /ci.yml " ]; then
641+ [ " $verbose " = true ] && echo " No ci.yml found in $sketchdir , skipping library installation"
642642 return 0
643643 fi
644- if ! jq -e . " $sketchdir /ci.json " > /dev/null 2>&1 ; then
645- echo " ERROR: $sketchdir /ci.json is not valid JSON " >&2
644+ if ! yq eval ' . ' " $sketchdir /ci.yml " > /dev/null 2>&1 ; then
645+ echo " ERROR: $sketchdir /ci.yml is not valid YAML " >&2
646646 return 1
647647 fi
648648
649649 local libs_type
650- libs_type=$( jq -r ' .libs | type' " $sketchdir /ci.json " 2> /dev/null)
650+ libs_type=$( yq eval ' .libs | type' " $sketchdir /ci.yml " 2> /dev/null)
651651 if [ -z " $libs_type " ] || [ " $libs_type " = " null" ]; then
652- [ " $verbose " = true ] && echo " No libs field found in ci.json , skipping library installation"
652+ [ " $verbose " = true ] && echo " No libs field found in ci.yml , skipping library installation"
653653 return 0
654- elif [ " $libs_type " != " array " ]; then
655- echo " ERROR: libs field in ci.json must be an array, found: $libs_type " >&2
654+ elif [ " $libs_type " != " !!seq " ]; then
655+ echo " ERROR: libs field in ci.yml must be an array, found: $libs_type " >&2
656656 return 1
657657 fi
658658
659659 local libs_count
660- libs_count=$( jq -r ' .libs | length' " $sketchdir /ci.json " 2> /dev/null)
660+ libs_count=$( yq eval ' .libs | length' " $sketchdir /ci.yml " 2> /dev/null)
661661 if [ " $libs_count " -eq 0 ]; then
662- [ " $verbose " = true ] && echo " libs array is empty in ci.json , skipping library installation"
662+ [ " $verbose " = true ] && echo " libs array is empty in ci.yml , skipping library installation"
663663 return 0
664664 fi
665665
666- echo " Installing $libs_count libraries from $sketchdir /ci.json "
666+ echo " Installing $libs_count libraries from $sketchdir /ci.yml "
667667
668668 local needs_unsafe=false
669669 local original_unsafe_setting=" "
670670 local libs
671- libs=$( jq -r ' .libs[]? // empty ' " $sketchdir /ci.json " )
671+ libs=$( yq eval ' .libs[]' " $sketchdir /ci.yml " 2> /dev/null )
672672
673673 # Detect any git-like URL (GitHub/GitLab/Bitbucket/self-hosted/ssh)
674674 for lib in $libs ; do
@@ -749,7 +749,7 @@ Available commands:
749749 build: Build a sketch.
750750 chunk_build: Build a chunk of sketches.
751751 check_requirements: Check if target meets sketch requirements.
752- install_libs: Install libraries from ci.json file.
752+ install_libs: Install libraries from ci.yml file.
753753"
754754
755755cmd=$1
0 commit comments