Skip to content

CI: Remove the molecule action usage from pull-request-management workflow #14

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: devel
Choose a base branch
from
47 changes: 47 additions & 0 deletions .github/check-git-status.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/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}"

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
2 changes: 2 additions & 0 deletions .github/requirements-ci-dev.txt
Original file line number Diff line number Diff line change
@@ -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
132 changes: 57 additions & 75 deletions .github/workflows/pull-request-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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/[email protected]
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: |
sh .github/check-git-status.sh
# - uses: actions/upload-artifact@v4
# with:
# name: molecule-${{ matrix.avd_scenario }}-artifacts
Expand All @@ -175,22 +172,19 @@ 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 action
uses: arista-netdevops-community/[email protected]
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: |
sh .github/check-git-status.sh
# - uses: actions/upload-artifact@v4
# with:
# name: molecule-${{ matrix.avd_scenario }}-artifacts
Expand Down Expand Up @@ -225,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'
Expand All @@ -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/[email protected]
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: |
sh .github/check-git-status.sh
# - uses: actions/upload-artifact@v4
# with:
# name: molecule-${{ matrix.avd_scenario }}-artifacts
Expand All @@ -276,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"
Expand All @@ -285,17 +276,14 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Run molecule action
uses: arista-netdevops-community/[email protected]
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: |
sh .github/check-git-status.sh
# - uses: actions/upload-artifact@v4
# with:
# name: molecule-${{ matrix.avd_scenario }}-artifacts
Expand All @@ -313,25 +301,22 @@ 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'
needs: [ file-changes ]
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/[email protected]
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: |
sh .github/check-git-status.sh

# ----------------------------------- #
# EOS Validate State MOLECULE
Expand All @@ -345,25 +330,22 @@ 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"
needs: [file-changes]
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/[email protected]
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: |
sh .github/check-git-status.sh

# ----------------------------------- #
# Ansible tests
Expand Down