From 9fd45accb1dd52dde6984f49ca5820aa7c4d3366 Mon Sep 17 00:00:00 2001 From: Shivani-gslab Date: Mon, 7 Apr 2025 16:15:13 +0530 Subject: [PATCH 1/6] CI: Remove the molecule action usage from pull-request-management workflow --- .github/molecule-runner.sh | 50 ++++++++ .github/requirements-ci-dev.txt | 2 + .github/workflows/pull-request-management.yml | 114 ++++++++---------- 3 files changed, 100 insertions(+), 66 deletions(-) create mode 100644 .github/molecule-runner.sh diff --git a/.github/molecule-runner.sh b/.github/molecule-runner.sh new file mode 100644 index 00000000000..8906162faf9 --- /dev/null +++ b/.github/molecule-runner.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# +# Purpose: Molecule runner for github-action +# Author: @titom73 +# Date: 2020-12-16 +# Version: 1.1 +# License: APACHE +# -------------------------------------- + +echo "Script running from ${PWD}" + +# Set default values +INPUT_CHECK_GIT="${INPUT_CHECK_GIT:-true}" +INPUT_CHECK_GIT_ENFORCED="${INPUT_CHECK_GIT_ENFORCED:-true}" + +echo "INPUT_CHECK_GIT: $INPUT_CHECK_GIT" +echo "INPUT_CHECK_GIT_ENFORCED: $INPUT_CHECK_GIT_ENFORCED" + +if [ ${INPUT_CHECK_GIT} = "true" ]; then + git config core.fileMode false + echo " * Run Git Verifier because CHECK_GIT is set to ${INPUT_CHECK_GIT}" + # if git diff-index --quiet HEAD --; then + GIT_STATUS="$(git status --porcelain)" + if [ "$?" -ne "0" ]; then + echo "'git status --porcelain' failed to run - something is wrong" + exit 1 + fi + if [ -n "$GIT_STATUS" ]; then + # Some changes + echo 'Some changes' + echo '------------' + git --no-pager status --short + echo '' + echo 'Diffs are:' + echo '------------' + git --no-pager diff + if [ ${INPUT_CHECK_GIT_ENFORCED} = "true" ]; then + exit 1 + else + exit 0 + fi + else + # No Changes + echo ' - No change found after running Molecule' + exit 0 + fi + exit 0 +else + echo " * Git verifier skipped as not set to true" +fi diff --git a/.github/requirements-ci-dev.txt b/.github/requirements-ci-dev.txt index 9f5ac3b2eae..9a20bf489c1 100644 --- a/.github/requirements-ci-dev.txt +++ b/.github/requirements-ci-dev.txt @@ -1,3 +1,5 @@ # Installing PyAVD from source. # The package path below is relative to the repo root and will only work if the pip install is executed from there. ./python-avd[ansible-collection] +molecule>=6.0 +molecule-plugins[docker]>=23.4.0 diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index 0b0c6b700fe..5b2c1c0df29 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -149,17 +149,14 @@ jobs: if: needs.file-changes.outputs.config_gen == 'true' steps: - uses: actions/checkout@v4 - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: "ansible_collections/arista/avd" - molecule_command: "test" - molecule_args: "--scenario-name ${{ matrix.avd_scenario }}" - pip_file: .github/requirements-ci-dev.txt - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -180,17 +177,14 @@ jobs: if: needs.file-changes.outputs.dhcp == 'true' steps: - uses: actions/checkout@v4 - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: "ansible_collections/arista/avd" - molecule_command: "test" - molecule_args: "--scenario-name ${{ matrix.avd_scenario }}" - pip_file: .github/requirements-ci-dev.txt - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -249,17 +243,14 @@ jobs: uv pip compile .github/requirements-ci-dev.txt --resolution=lowest-direct > ${{ matrix.pip_requirements }} cat ${{ matrix.pip_requirements }} if: matrix.pip_requirements == 'tmp-requirements-minimum.txt' - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: "ansible_collections/arista/avd" - molecule_command: "test" - molecule_args: "--scenario-name ${{ matrix.avd_scenario }}" - pip_file: ${{ matrix.pip_requirements }} - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -285,17 +276,14 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: "ansible_collections/arista/avd" - molecule_command: "test" - molecule_args: "--scenario-name ${{ matrix.avd_scenario }}" - pip_file: .github/requirements-ci-dev.txt - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -321,17 +309,14 @@ jobs: if: needs.file-changes.outputs.eos_design == 'true' || needs.file-changes.outputs.anta_runner == 'true' steps: - uses: actions/checkout@v4 - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: 'ansible_collections/arista/avd' - molecule_command: 'test' - molecule_args: '--scenario-name ${{ matrix.avd_scenario }}' - pip_file: .github/requirements-ci-dev.txt - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # ----------------------------------- # # EOS Validate State MOLECULE @@ -353,17 +338,14 @@ jobs: if: needs.file-changes.outputs.eos_design == 'true' || needs.file-changes.outputs.validate_state == 'true' steps: - uses: actions/checkout@v4 - - name: Run molecule action - uses: arista-netdevops-community/action-molecule-avd@v1.8.1 - with: - molecule_parentdir: "ansible_collections/arista/avd" - molecule_command: "test" - molecule_args: "--scenario-name ${{ matrix.avd_scenario }}" - pip_file: .github/requirements-ci-dev.txt - galaxy_file: "ansible_collections/arista/avd/collections.yml" - ansible: ${{ matrix.ansible_version }} - check_git: true - check_git_enforced: true + - name: Run molecule test + run: | + pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + cd ansible_collections/arista/avd + molecule test --scenario-name ${{ matrix.avd_scenario }} + - name: Check GIT status + run: | + .github/molecule-runner.sh # ----------------------------------- # # Ansible tests From f8e73db93e0189607f9f228b39082701b9b26516 Mon Sep 17 00:00:00 2001 From: Shivani-gslab Date: Mon, 7 Apr 2025 16:25:57 +0530 Subject: [PATCH 2/6] Remove upgrade from ansible-version --- .github/workflows/pull-request-management.yml | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index 5b2c1c0df29..e5cda7d55f1 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -140,7 +140,7 @@ jobs: - "eos_cli_config_gen_deprecated_vars" - "eos_cli_config_gen_negative_unit_tests" ansible_version: - - "ansible-core<2.19.0 --upgrade" + - "ansible-core<2.19.0" # Also test minimum ansible version for one scenario. include: - avd_scenario: "eos_cli_config_gen" @@ -151,7 +151,7 @@ jobs: - uses: actions/checkout@v4 - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status @@ -172,14 +172,14 @@ jobs: fail-fast: true matrix: avd_scenario: ["dhcp_configuration", "dhcp_provisioning"] - ansible_version: ["ansible-core<2.19.0 --upgrade"] + ansible_version: ["ansible-core<2.19.0"] needs: [file-changes] if: needs.file-changes.outputs.dhcp == 'true' steps: - uses: actions/checkout@v4 - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status @@ -219,19 +219,19 @@ jobs: - "example-cv-pathfinder" ansible_version: # Testing all scenario with 2.16.x, due to bug with in 2.17.0 with and the way we test eos_designs_negative_unit_tests https://github.com/ansible/ansible/issues/83292 - - "ansible-core>=2.16.0,<2.17.0 --upgrade" + - "ansible-core>=2.16.0,<2.17.0" pip_requirements: - ".github/requirements-ci-dev.txt" # Also test minimum ansible version for one scenario. include: - avd_scenario: "eos_designs_unit_tests" - ansible_version: "ansible-core==2.16.0 --upgrade" + ansible_version: "ansible-core==2.16.0" pip_requirements: ".github/requirements-ci-dev.txt" - avd_scenario: "eos_designs_unit_tests" - ansible_version: "ansible-core<2.18.0 --upgrade" + ansible_version: "ansible-core<2.18.0" pip_requirements: ".github/requirements-ci-dev.txt" - avd_scenario: "eos_designs_unit_tests" - ansible_version: "ansible-core<2.19.0 --upgrade" + ansible_version: "ansible-core<2.19.0" pip_requirements: ".github/requirements-ci-dev.txt" needs: [file-changes] if: needs.file-changes.outputs.eos_design == 'true' || needs.file-changes.outputs.config_gen == 'true' @@ -245,7 +245,7 @@ jobs: if: matrix.pip_requirements == 'tmp-requirements-minimum.txt' - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status @@ -267,7 +267,7 @@ jobs: avd_scenario: - "eos_config_deploy_cvp" ansible_version: - - "ansible-core<2.19.0 --upgrade" + - "ansible-core<2.19.0" include: - avd_scenario: "eos_config_deploy_cvp" ansible_version: "ansible-core==2.16.0" @@ -278,7 +278,7 @@ jobs: - uses: actions/checkout@v4 - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status @@ -301,7 +301,7 @@ jobs: avd_scenario: - 'anta_runner' ansible_version: - - 'ansible-core<2.19.0 --upgrade' + - 'ansible-core<2.19.0' include: - avd_scenario: 'anta_runner' ansible_version: 'ansible-core==2.16.0' @@ -311,7 +311,7 @@ jobs: - uses: actions/checkout@v4 - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status @@ -330,7 +330,7 @@ jobs: avd_scenario: - "eos_validate_state" ansible_version: - - "ansible-core<2.19.0 --upgrade" + - "ansible-core<2.19.0" include: - avd_scenario: "eos_validate_state" ansible_version: "ansible-core==2.16.0" @@ -340,7 +340,7 @@ jobs: - uses: actions/checkout@v4 - name: Run molecule test run: | - pip install ${{ matrix.ansible_version}} -r .github/requirements-ci-dev.txt + pip install "${{ matrix.ansible_version}}" -r .github/requirements-ci-dev.txt cd ansible_collections/arista/avd molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status From db859c0e0d6553dab0d30f2a2abad5914286e1ee Mon Sep 17 00:00:00 2001 From: Shivani-gslab Date: Mon, 7 Apr 2025 17:23:51 +0530 Subject: [PATCH 3/6] Fix the permission issue for molecule-runner.sh --- .github/molecule-runner.sh | 3 --- .github/workflows/pull-request-management.yml | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/molecule-runner.sh b/.github/molecule-runner.sh index 8906162faf9..64a7995674e 100644 --- a/.github/molecule-runner.sh +++ b/.github/molecule-runner.sh @@ -13,9 +13,6 @@ echo "Script running from ${PWD}" INPUT_CHECK_GIT="${INPUT_CHECK_GIT:-true}" INPUT_CHECK_GIT_ENFORCED="${INPUT_CHECK_GIT_ENFORCED:-true}" -echo "INPUT_CHECK_GIT: $INPUT_CHECK_GIT" -echo "INPUT_CHECK_GIT_ENFORCED: $INPUT_CHECK_GIT_ENFORCED" - if [ ${INPUT_CHECK_GIT} = "true" ]; then git config core.fileMode false echo " * Run Git Verifier because CHECK_GIT is set to ${INPUT_CHECK_GIT}" diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index e5cda7d55f1..6677788d48d 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -156,7 +156,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -184,7 +184,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -250,7 +250,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -283,7 +283,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -316,7 +316,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # ----------------------------------- # # EOS Validate State MOLECULE @@ -345,7 +345,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - .github/molecule-runner.sh + sh .github/molecule-runner.sh # ----------------------------------- # # Ansible tests From c1269099e5b1fce3a47327072642971fed29b9fe Mon Sep 17 00:00:00 2001 From: Shivani-gslab Date: Mon, 7 Apr 2025 19:06:21 +0530 Subject: [PATCH 4/6] Rename molecule-runner.sh -> check-git-status.sh --- .github/{molecule-runner.sh => check-git-status.sh} | 0 .github/workflows/pull-request-management.yml | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) rename .github/{molecule-runner.sh => check-git-status.sh} (100%) diff --git a/.github/molecule-runner.sh b/.github/check-git-status.sh similarity index 100% rename from .github/molecule-runner.sh rename to .github/check-git-status.sh diff --git a/.github/workflows/pull-request-management.yml b/.github/workflows/pull-request-management.yml index 6677788d48d..6ea40909d0c 100644 --- a/.github/workflows/pull-request-management.yml +++ b/.github/workflows/pull-request-management.yml @@ -156,7 +156,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -184,7 +184,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -250,7 +250,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -283,7 +283,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # - uses: actions/upload-artifact@v4 # with: # name: molecule-${{ matrix.avd_scenario }}-artifacts @@ -316,7 +316,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # ----------------------------------- # # EOS Validate State MOLECULE @@ -345,7 +345,7 @@ jobs: molecule test --scenario-name ${{ matrix.avd_scenario }} - name: Check GIT status run: | - sh .github/molecule-runner.sh + sh .github/check-git-status.sh # ----------------------------------- # # Ansible tests From 16223cfad68edc7a603bbb4397a3c8ca683ebc41 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Mon, 7 Apr 2025 16:11:56 +0200 Subject: [PATCH 5/6] test new workflow --- .../molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg b/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg index 721b8bfb584..c9dcdeaff4e 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg @@ -6,6 +6,8 @@ vlan internal order ascending range 1006 1199 ! transceiver qsfp default-mode 4x10G ! +test changing artifacts will fail ci +! service routing protocols model multi-agent ! hostname BGP-LEAF2 From eacf7ad82cb467f70714ab84b51129723218a379 Mon Sep 17 00:00:00 2001 From: Claus Holbech Date: Mon, 7 Apr 2025 16:16:06 +0200 Subject: [PATCH 6/6] undo test new workflow --- .../molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg b/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg index c9dcdeaff4e..721b8bfb584 100644 --- a/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg +++ b/ansible_collections/arista/avd/molecule/eos_designs-l2ls/intended/configs/BGP-LEAF2.cfg @@ -6,8 +6,6 @@ vlan internal order ascending range 1006 1199 ! transceiver qsfp default-mode 4x10G ! -test changing artifacts will fail ci -! service routing protocols model multi-agent ! hostname BGP-LEAF2