Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add basic testing of run command without --dry #18

Merged
merged 3 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,24 @@ jobs:
docker:
- image: almalinux
steps:
- run:
command: dnf update -y
# - run:
# command: dnf update -y
- run:
command: dnf install -y epel-release
- run:
command: dnf install -y ansible python3 python3-pip
- run:
command: python3 -V
- run:
command: ansible-playbook --version
- run:
command: dnf repoquery -l python3-pip
- checkout
- run:
command: "pwd && ls"
- run:
name: "Install ansible-deploy"
command: "pip3.6 install ."
- run:
command: "pip3.6 install pylint"
- run:
command: "pylint --rcfile=./tests/pylintrc $(find ./ -name '*.py')"
- run:
command: "cat $(which ansible-deploy)"
- run:
name: "Copy configuration files"
command: cp -r ./etc /etc/ansible-deploy
- run:
name: "Run shell script for argument parsing"
command: ./tests/01-test_argument_parsing.sh
command: |
./tests/01-test_argument_parsing.sh
./tests/02-checkrun.sh

install_and_exec:
# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Pylint

on:
push:
branches:
- '*'
pull_request:
branches:
- main
Expand All @@ -13,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.8", "3.9", "3.10"]
python-version: ["3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
17 changes: 17 additions & 0 deletions etc/hooks/setup_work_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -l

cat << END > ./runBinTrue.yaml
- hosts: all
connection: "local"
tasks:
- name: "Run /bin/true"
shell: "/bin/true"
END

cat << END > ./test_infra1_inv.yaml
localhost
END

cat << END > ./prod_infra1_inv.yaml
localhost
END
31 changes: 31 additions & 0 deletions tests/02-checkrun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -l

check_output_fail() {
CMD=$1
EXPTEXT=$2

eval "$CMD |& grep '$EXPTEXT'"
if [ $? -eq 0 ]
then
echo "OK: '${CMD} returned ${EXPTEXT}'"
else
echo "FAILED: '${CMD}' didn't return '${EXPTEXT}'"
exit 1
fi
}

check_run_ok() {
CMD=$1
$CMD
if [ $? -ne 0 ]
then
echo "FAILED: ${CMD}"
exit 1
else
echo "OK"
fi
}

#Check wrong combinations
check_run_ok "ansible-deploy run -t task_exec_bin_true -s prod -i testInfra"