From 5f89007052ffabe29fb65960634197378328da21 Mon Sep 17 00:00:00 2001 From: Marcin Stolarek Date: Tue, 1 Feb 2022 15:42:54 +0100 Subject: [PATCH 1/3] Add basic testing of run command without --dry --- .circleci/config.yml | 4 +++- etc/hooks/setup_work_dir.sh | 17 +++++++++++++++++ tests/02-checkrun.sh | 31 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100755 etc/hooks/setup_work_dir.sh create mode 100755 tests/02-checkrun.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e67a252..1bbbfd9a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -38,7 +38,9 @@ jobs: 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. diff --git a/etc/hooks/setup_work_dir.sh b/etc/hooks/setup_work_dir.sh new file mode 100755 index 00000000..8b5c8b19 --- /dev/null +++ b/etc/hooks/setup_work_dir.sh @@ -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 diff --git a/tests/02-checkrun.sh b/tests/02-checkrun.sh new file mode 100755 index 00000000..94b6da62 --- /dev/null +++ b/tests/02-checkrun.sh @@ -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" + From fcfdc46344f368e7827d71983e3052c307bcc3b3 Mon Sep 17 00:00:00 2001 From: Marcin Stolarek Date: Tue, 1 Feb 2022 15:49:47 +0100 Subject: [PATCH 2/3] Skip no longer needed part of circle CI Comment-out (maybe temporary) dnf update in CircleCI We need to make it shorter to prevent running out of free plan seconds --- .circleci/config.yml | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1bbbfd9a..3c06725e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,30 +9,16 @@ 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 From 3d9216ec65d753c5b56871908a9092b6a8b6061b Mon Sep 17 00:00:00 2001 From: Marcin Stolarek Date: Tue, 1 Feb 2022 17:13:21 +0100 Subject: [PATCH 3/3] github/actions - limit pylint to 3.10 (reduce minutes used) Run it only on pull request to main --- .github/workflows/pylint.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 5d1a719a..f133aa7c 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -1,9 +1,6 @@ name: Pylint on: - push: - branches: - - '*' pull_request: branches: - main @@ -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 }}