diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e3caa33c8..02122458a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -52,29 +52,11 @@ jobs: sudo chown -R ${USER} /var/lib/jenkins cd jenkins-scripts/dsl WRITE_JOB_LOG=1 java -jar tools/jobdsl.jar *.dsl - - name: Checks for abichecker jobs + - name: Checks for DSL Code if: steps.dsl_check.outputs.run_job == 'true' run: | cd jenkins-scripts/dsl - main=$(grep 'main' *-abichecker-*.xml || true) - if [[ -n ${main} ]]; then - echo "Found a main branch in an abichecker job:" - echo "${main}" - echo "Main branches are not target of abichecking. Fix the code." - exit 1 - fi - # Filter out the previous auto jobs - mkdir /tmp/abichecker_filtered_jobs - cp *-abichecker-*.xml /tmp/abichecker_filtered_jobs - cd /tmp/abichecker_filtered_jobs - rm *ubuntu_auto*.xml - repeated=$(grep '\' *-abichecker-*.xml | awk '{ print $2 }' | sort | uniq -d) - if [[ -n ${repeated} ]]; then - echo "Found a duplicate in an abichecker branch:" - echo "${repeated}" - echo "please exclude one of the versions in the yaml file to reduce the server workload" - exit 1 - fi + ./dsl_checks.bash - name: Export XML generated configuration for diff if: steps.dsl_check.outputs.run_job == 'true' run: | diff --git a/jenkins-scripts/dsl/dsl_checks.bash b/jenkins-scripts/dsl/dsl_checks.bash new file mode 100755 index 000000000..b87f9bd91 --- /dev/null +++ b/jenkins-scripts/dsl/dsl_checks.bash @@ -0,0 +1,34 @@ +#!/bin/bash -e +# +if [[ -z $(ls -- *.xml) ]]; then + echo "No .xml file founds. Generate them using:" + echo "https://github.com/gazebo-tooling/release-tools/blob/master/jenkins-scripts/README.md#L11" +fi + +not_null=$(grep 'null' -- *.xml || true) +if [[ -n ${not_null} ]]; then + echo "Found a null value in a configuration file:" + echo "${not_null}" + echo "Probably a problem in the code" + exit 1 +fi + +main=$(grep 'main' -- *-abichecker-*.xml || true) +if [[ -n ${main} ]]; then + echo "Found a main branch in an abichecker job:" + echo "${main}" + echo "Main branches are not target of abichecking. Fix the code." + exit 1 +fi + +# Filter out the previous auto jobs +filtered_dir=$(mktemp -d) +cp -- *-abichecker-*.xml "${filtered_dir}" +rm -f "${filtered_dir}"/*-ubuntu_auto*.xml +repeated=$(grep '\' "${filtered_dir}"/*-abichecker-*.xml | awk '{ print $2 }' | sort | uniq -d) +if [[ -n ${repeated} ]]; then + echo "Found a duplicate in an abichecker branch:" + echo "${repeated}" + echo "please exclude one of the versions in the yaml file to reduce the server workload" + exit 1 +fi