Skip to content

Commit

Permalink
Externalize the script to test
Browse files Browse the repository at this point in the history
This makes it easier run the tests locally.
  • Loading branch information
ekohl authored and evgeni committed Jan 5, 2023
1 parent 0f64324 commit 1b7ce98
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 11 deletions.
12 changes: 1 addition & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,4 @@ jobs:
pip install -r requirements.txt
- name: Run tests
run: |
for d in theforeman.org; do
DIR="."
( cd $d && jenkins-jobs -l debug test -r $DIR )
( cd $d && jenkins-jobs test -r $DIR --config-xml -o output && find output -name config.xml -exec python ../jenkins-lint.py --xml {} + && rm -rf output )
done
for d in centos.org; do
DIR="jobs"
( cd $d && jenkins-jobs -l debug test -r $DIR )
( cd $d && jenkins-jobs test -r $DIR --config-xml -o output && find output -name config.xml -exec python ../jenkins-lint.py --xml {} + && rm -rf output )
done
./test
40 changes: 40 additions & 0 deletions test
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -e

LINT="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")/jenkins-lint.py")"

test_project() {
local project=$1

if [[ $project == "theforeman.org" ]] ; then
local dir="."
elif [[ $project == "centos.org" ]] ; then
local dir="jobs"
else
echo "Unknown project '${project}'"
exit 1
fi

(
cd "${project}"

jenkins-jobs -l debug test -r "${dir}"

local output="$(mktemp -d)"
trap "rm -rf '${output}'" EXIT

jenkins-jobs test -r "${dir}" --config-xml -o "${output}"
find "${output}" -name config.xml -exec "$LINT" --xml {} +
rm -rf "${output}"
)
}

PROJECT=$1

if [[ -z $PROJECT ]] ; then
test_project theforeman.org
test_project centos.org
else
test_project "${PROJECT}"
fi

0 comments on commit 1b7ce98

Please sign in to comment.