From 7056e803c678b330ff787b4a3588de7222a6e4dc Mon Sep 17 00:00:00 2001 From: Priyam Sahoo <42550351+priyamsahoo@users.noreply.github.com> Date: Thu, 6 Oct 2022 15:36:07 +0530 Subject: [PATCH] Update ansible-lint and version and e2e-tests to support changes the changes (#643) * update tests to support changes for ansible-lint * make yaml parsing exception less verbose * add feature to display ansible-lint version before running e2e tests * update pip packages for test-setup * update test to support ansible-lint version 6.8.0b3 --- .config/requirements.in | 2 +- .config/requirements.txt | 4 ++-- src/features/utils/applyFileInspectionForKeywords.ts | 2 +- .../testFixtures/diagnostics/ansible/without_ee/1.yml | 2 +- test/testRunner.ts | 11 +++++++++++ .../diagnostics/testAnsibleWithoutEE.test.ts | 3 ++- .../testScripts/diagnostics/testYamlWithoutEE.test.ts | 2 +- tools/test-setup.sh | 2 +- 8 files changed, 20 insertions(+), 8 deletions(-) diff --git a/.config/requirements.in b/.config/requirements.in index b6e8c4280..2b2cadd9e 100644 --- a/.config/requirements.in +++ b/.config/requirements.in @@ -1,5 +1,5 @@ ansible-core>=2.13 -ansible-lint>=6.2.2 +ansible-lint>=6.8.0.dev0 mypy # used by vscode pip-tools>=6.6.2 pre-commit>=2.19 diff --git a/.config/requirements.txt b/.config/requirements.txt index 8aa771f46..2c350586e 100644 --- a/.config/requirements.txt +++ b/.config/requirements.txt @@ -1,6 +1,6 @@ ansible-compat==2.2.1 ansible-core==2.13.4 -ansible-lint==6.3.0 +ansible-lint==6.8.0b3 attrs==21.4.0 bracex==2.3.post1 cffi==1.15.0 @@ -14,7 +14,7 @@ filelock==3.7.1 identify==2.5.1 iniconfig==1.1.1 jinja2==3.1.2 -jsonschema==4.6.0 +jsonschema==4.16.0 markupsafe==2.1.1 mypy==0.961 mypy-extensions==0.4.3 diff --git a/src/features/utils/applyFileInspectionForKeywords.ts b/src/features/utils/applyFileInspectionForKeywords.ts index cc870c681..a1b32de40 100644 --- a/src/features/utils/applyFileInspectionForKeywords.ts +++ b/src/features/utils/applyFileInspectionForKeywords.ts @@ -36,6 +36,6 @@ export async function applyFileInspectionForKeywords( } } } catch (err) { - console.error(err); + console.error("Error loading yaml file"); } } diff --git a/test/testFixtures/diagnostics/ansible/without_ee/1.yml b/test/testFixtures/diagnostics/ansible/without_ee/1.yml index 1d02aba0f..b68cd618e 100644 --- a/test/testFixtures/diagnostics/ansible/without_ee/1.yml +++ b/test/testFixtures/diagnostics/ansible/without_ee/1.yml @@ -1,4 +1,4 @@ -- name: play name +- name: Play name hosts: localhost tasks: - ansible.builtin.debug: diff --git a/test/testRunner.ts b/test/testRunner.ts index aa52ad31a..f217063ff 100644 --- a/test/testRunner.ts +++ b/test/testRunner.ts @@ -13,6 +13,17 @@ export const ANSIBLE_COLLECTIONS_FIXTURES_BASE_PATH = path.resolve( "common", "collections" ); +const PRETEST_ERR_RC = 2; + +// display ansible-lint version and exit testing if ansible-lint is absent +const command = "ansible-lint --version"; +try { + const result = cp.execSync(command); + console.info(`Detected: ${result}`); +} catch (e) { + console.error(`error: test requisites not met, '${command}' returned ${e}`); + process.exit(PRETEST_ERR_RC); +} async function main(): Promise { try { diff --git a/test/testScripts/diagnostics/testAnsibleWithoutEE.test.ts b/test/testScripts/diagnostics/testAnsibleWithoutEE.test.ts index d50cc860b..2295fb024 100644 --- a/test/testScripts/diagnostics/testAnsibleWithoutEE.test.ts +++ b/test/testScripts/diagnostics/testAnsibleWithoutEE.test.ts @@ -47,7 +47,8 @@ export function testDiagnosticsAnsibleWithoutEE(): void { await testDiagnostics(docUri2, [ { severity: 0, - message: "Ansible syntax check failed", + message: + "Unexpected error code 4 from execution of: ansible-playbook --syntax-check", range: new vscode.Range( new vscode.Position(0, 0), new vscode.Position(0, integer.MAX_VALUE) diff --git a/test/testScripts/diagnostics/testYamlWithoutEE.test.ts b/test/testScripts/diagnostics/testYamlWithoutEE.test.ts index 540bf7949..0c1dc5b30 100644 --- a/test/testScripts/diagnostics/testYamlWithoutEE.test.ts +++ b/test/testScripts/diagnostics/testYamlWithoutEE.test.ts @@ -25,7 +25,7 @@ export function testDiagnosticsYAMLWithoutEE(): void { await testDiagnostics(docUri1, [ { severity: 0, - message: "Ansible syntax check failed", + message: "Failed to load YAML file", range: new vscode.Range( new vscode.Position(0, 0), new vscode.Position(0, integer.MAX_VALUE) diff --git a/tools/test-setup.sh b/tools/test-setup.sh index 1f021ca64..4c45b84e6 100755 --- a/tools/test-setup.sh +++ b/tools/test-setup.sh @@ -169,7 +169,7 @@ fi python3 -m pip install -q -U pip if [[ $(uname || true) != MINGW* ]]; then # if we are not on pure Windows - python3 -m pip install -q \ + python3 -m pip install \ -c .config/requirements.txt -r .config/requirements.in fi