diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index 225b7a4a..8c3aebac 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -13,7 +13,26 @@ env: QUAY_USER: ansible+eda_gha jobs: + build-and-test-image: + if: github.repository == 'ansible/ansible-rulebook' + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Build local image + run: docker build -t localhost/ansible-rulebook:test . + + - name: Run tests + run: > + docker run --rm -u 0 localhost/ansible-rulebook:test bash -c ' + pip install -r requirements_test.txt && + pytest -m "e2e" -n auto' + build-and-push-image: + needs: build-and-test-image + if: github.repository == 'ansible/ansible-rulebook' runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f642b698..783dfd4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,15 +4,9 @@ on: push: branches: - "main" - paths-ignore: - - "docs/**" - - "*.md" pull_request: branches: - "main" - paths-ignore: - - "docs/**" - - "*.md" workflow_dispatch: jobs: diff --git a/docs/actions.rst b/docs/actions.rst index 68c403c7..f11d1e2f 100644 --- a/docs/actions.rst +++ b/docs/actions.rst @@ -62,6 +62,9 @@ Run an Ansible playbook. * - json_mode - Boolean, sends the playbook events data to the stdout as json strings as they are processed by ansible-runner - No + * - copy_files + - Boolean, copy the local playbook file to the ansible-runner project directory, this is not needed if you are running a playbook from an ansible collection. + - No run_module @@ -96,6 +99,21 @@ Run an Ansible module * - extra_vars - Additional vars to be passed into the playbook as extra vars. - No + * - json_mode + - Boolean, sends the playbook events data to the stdout as json strings as they are processed by ansible-runner + - No + * - set_facts + - Boolean, the artifacts from the module execution are inserted back into the rule set as facts + - No + * - post_events + - Boolean, the artifacts from the module execution are inserted back into the rule set as events + - No + * - ruleset + - The name of the ruleset to post the event or assert the fact to, default is current rule set. + - No + * - var_root + - If the event is a deeply nested dictionary, the var_root can specify the key name whose value should replace the matching event value. The var_root can take a dictionary to account for data when we have multiple matching events. + - No run_job_template **************** @@ -312,6 +330,9 @@ retract_fact * - ruleset - The name of the rule set to retract the fact, default is the current rule set name - No + * - partial + - The fact being requested to retracted is partial and doesn't have all the keys. Default is true + - No Example: diff --git a/tests/e2e/test_match_multiple_rules.py b/tests/e2e/test_match_multiple_rules.py index fbe5c7aa..2627bd25 100644 --- a/tests/e2e/test_match_multiple_rules.py +++ b/tests/e2e/test_match_multiple_rules.py @@ -23,12 +23,12 @@ async def test_match_multiple_rules(): and send the event messages to a websocket server """ # variables - host = "localhost" + host = "127.0.0.1" endpoint = "/api/ws2" proc_id = "42" port = 31415 rulebook = utils.BASE_DATA_PATH / "rulebooks/test_match_multiple_rules.yml" - websocket_address = f"ws://localhost:{port}{endpoint}" + websocket_address = f"ws://127.0.0.1:{port}{endpoint}" cmd = utils.Command( rulebook=rulebook, websocket=websocket_address, diff --git a/tests/e2e/test_non_alpha_keys.py b/tests/e2e/test_non_alpha_keys.py index 1c0b0b65..e0cb48be 100644 --- a/tests/e2e/test_non_alpha_keys.py +++ b/tests/e2e/test_non_alpha_keys.py @@ -23,12 +23,12 @@ async def test_non_alpha_numeric_keys(): and send the event messages to a websocket server """ # variables - host = "localhost" + host = "127.0.0.1" endpoint = "/api/ws2" proc_id = "42" port = 31415 rulebook = utils.EXAMPLES_PATH / "82_non_alpha_keys.yml" - websocket_address = f"ws://localhost:{port}{endpoint}" + websocket_address = f"ws://127.0.0.1:{port}{endpoint}" cmd = utils.Command( rulebook=rulebook, websocket=websocket_address, diff --git a/tests/e2e/test_run_module_output.py b/tests/e2e/test_run_module_output.py index 9a7048ac..710072e5 100644 --- a/tests/e2e/test_run_module_output.py +++ b/tests/e2e/test_run_module_output.py @@ -23,12 +23,12 @@ async def test_run_module_output(): run_module and then used in a condition """ # variables - host = "localhost" + host = "127.0.0.1" endpoint = "/api/ws2" proc_id = "42" port = 31415 rulebook = utils.EXAMPLES_PATH / "29_run_module.yml" - websocket_address = f"ws://localhost:{port}{endpoint}" + websocket_address = f"ws://127.0.0.1:{port}{endpoint}" cmd = utils.Command( rulebook=rulebook, websocket=websocket_address, diff --git a/tests/e2e/test_websocket.py b/tests/e2e/test_websocket.py index f64b9b6f..cd71b85d 100644 --- a/tests/e2e/test_websocket.py +++ b/tests/e2e/test_websocket.py @@ -22,14 +22,14 @@ async def test_websocket_messages(): send event messages to a websocket server """ # variables - host = "localhost" + host = "127.0.0.1" endpoint = "/api/ws2" proc_id = "42" port = 31415 rulebook = ( utils.BASE_DATA_PATH / "rulebooks/websockets/test_websocket_range.yml" ) - websocket_address = f"ws://localhost:{port}{endpoint}" + websocket_address = f"ws://127.0.0.1:{port}{endpoint}" cmd = utils.Command( rulebook=rulebook, websocket=websocket_address,