aristanetworks / avd

Arista Validated Designs
https://avd.arista.com
Apache License 2.0
285 stars 202 forks source link

Feat(containers): switch to pyavd and editable install for container build #4087

Closed ankudinov closed 3 months ago

ankudinov commented 3 months ago

Change Summary

Change container build logic:

[!NOTE] There is no universal image build for Python 3.9 any more.

Component(s) name

container build workflow

github-actions[bot] commented 3 months ago

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4087
# Activate the virtual environment
source test-avd-pr-4087/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/ankudinov/avd.git@add_pyavd#subdirectory=python-avd" --force
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/ankudinov/avd.git#/ansible_collections/arista/avd/,add_pyavd --force
# Optional: Install AVD examples
cd test-avd-pr-4087
ansible-playbook arista.avd.install_examples
ankudinov commented 3 months ago

How to test

For testing purposes all images were pre-build on my fork.

Testing Universal Image

Find some AVD inventory to test and add following .devcontainer/devcontainer.json to the root of the repo:

{
    "image": "ghcr.io/ankudinov/avd/universal:python3.11-avd-add_pyavd"
}

Note: you can try other Python versions as well. Full list: 3.10, 3.11, 3.12. There is no universal image build for Python 3.9 any more.

Open the repository in VSCode with dev containers extensions installed, wait until the build finishes and run following tests:

Testing dev image, install from branch

Use the same repo and change devcontainer definition to:

{
    "image": "ghcr.io/ankudinov/avd/dev:python3.11",
    "containerEnv": {
        "AVD_GITHUB_REPO": "aristanetworks/avd",
        "AVD_BRANCH_NAME": "devel"
    },
    "postStartCommand": "/bin/entrypoint.sh true",
    "remoteUser": "avd"
}

Rebuild the container and confirm that build was successful. Rerun the tests listed above. Add the following test:

Testing dev image, install from workspace

Temporarily change line 3 of devcontainer.json in your fork of AVD repo (make sure it's up to date):

    "image": "ghcr.io/ankudinov/avd/dev:python3.11",

Rebuild container and run following tests:

sonarcloud[bot] commented 3 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud