Skip to content

Commit

Permalink
Move github actions dsl checks to a script (#1042)
Browse files Browse the repository at this point in the history
* Move github actions dsl checks to a script
* Added a check for null values

---------

Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero authored Oct 17, 2023
1 parent 5894221 commit 304a148
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
22 changes: 2 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<branch>main</branch>' *-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 '\<branch>' *-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: |
Expand Down
34 changes: 34 additions & 0 deletions jenkins-scripts/dsl/dsl_checks.bash
Original file line number Diff line number Diff line change
@@ -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 '<branch>main</branch>' -- *-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 '\<branch>' "${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

0 comments on commit 304a148

Please sign in to comment.