Skip to content

[ci] Fetch latest version of dependencies #2873

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

Merged
merged 3 commits into from
Jul 2, 2025
Merged

Conversation

VietND96
Copy link
Member

@VietND96 VietND96 commented Jul 2, 2025

User description

Thanks for contributing to the Docker-Selenium project!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines, applied for this repository.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes #2804

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Replace hardcoded dependency versions with dynamic latest version fetching

  • Add system requirements documentation section

  • Improve CI setup script maintainability


Changes diagram

flowchart LR
  A["Hardcoded Versions"] --> B["Dynamic Version Fetching"]
  B --> C["Latest Releases API"]
  D["Missing Documentation"] --> E["System Requirements Section"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
chart_setup_env.sh
Dynamic dependency version fetching implementation             

tests/charts/make/chart_setup_env.sh

  • Replace hardcoded versions with dynamic fetching using GitHub API
  • Add conditional check for DOCKER_COMPOSE_VERSION environment variable
  • Update version fetching for Docker Compose, CRI-CTL, CRI-Dockerd,
    CNI-Plugins, Helm, and chart-testing
  • Use consistent curl command pattern for all version fetches
  • +8/-6     
    Documentation
    README.md
    Add system requirements documentation                                       

    README.md

  • Add new "System Recommendations" section to table of contents
  • Document minimum required versions for Docker Engine, Docker Compose,
    Docker Buildx, and Kubernetes
  • +7/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    qodo-merge-pro bot commented Jul 2, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Wrong Repository

    The CRI_DOCKERD_VERSION is fetching from the wrong repository (cri-tools instead of cri-dockerd). This will cause the installation to fail as it's using the wrong version number for a different project.

    CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/kubernetes-sigs/cri-tools/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
    curl -fsSL -o cri-dockerd.tgz https://github.com/Mirantis/cri-dockerd/releases/download/v$CRI_DOCKERD_VERSION/cri-dockerd-$CRI_DOCKERD_VERSION.$(dpkg --print-architecture).tgz
    Error Handling

    The curl commands for fetching latest versions lack proper error handling. If the GitHub API is unavailable or returns unexpected responses, the script will continue with empty or malformed version strings, potentially causing installation failures.

        DOCKER_COMPOSE_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/docker/compose/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
    fi
    curl -fsSL -o ./docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-$(uname -m)"
    chmod +x ./docker-compose
    sudo mv ./docker-compose /usr/libexec/docker/cli-plugins
    docker compose version
    echo "==============================="
    echo "Install Docker SBOMs plugin"
    curl -sSfL https://raw.githubusercontent.com/docker/sbom-cli-plugin/main/install.sh | sh -s --
    docker sbom --version
    echo "==============================="
    if [ "${CLUSTER}" = "kind" ]; then
        echo "Installing kind for AMD64 / ARM64"
        curl -fsSL -o ./kind https://kind.sigs.k8s.io/dl/latest/kind-linux-$(dpkg --print-architecture)
        chmod +x ./kind
        sudo cp -frp ./kind /usr/local/bin/kind
        sudo ln -sf /usr/local/bin/kind /usr/bin/kind
        rm -rf kind
        kind version
        echo "==============================="
    elif [ "${CLUSTER}" = "minikube" ]; then
        echo "Installing additional dependencies for running Minikube on none driver CRI-dockerd"
        echo "==============================="
        echo "Installing conntrack"
        sudo apt-get install -yq conntrack
        echo "==============================="
        echo "Installing Minikube"
        curl -sLO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-$(dpkg --print-architecture)
        sudo install minikube-linux-$(dpkg --print-architecture) /usr/local/bin/minikube
        minikube version
        rm -rf minikube-linux-$(dpkg --print-architecture)
        echo "==============================="
        echo "Installing Go"
        GO_VERSION="1.24.0"
        curl -sLO https://go.dev/dl/go$GO_VERSION.linux-$(dpkg --print-architecture).tar.gz
        tar -xvf go$GO_VERSION.linux-$(dpkg --print-architecture).tar.gz -C /tmp
        rm -rf go$GO_VERSION.linux-$(dpkg --print-architecture).tar.gz*
        sudo rm -rf /usr/local/go
        sudo mv /tmp/go /usr/local
        export GOROOT=/usr/local/go
        export GOPATH=$HOME/go
        export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
        source $HOME/.profile || source $HOME/.bashrc
        go version
        echo "==============================="
        echo "Installing CRI-CTL (CLI for CRI-compatible container runtimes)"
        CRICTL_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/kubernetes-sigs/cri-tools/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
        curl -fsSL -o crictl.tar.gz https://github.com/kubernetes-sigs/cri-tools/releases/download/$CRICTL_VERSION/crictl-$CRICTL_VERSION-linux-$(dpkg --print-architecture).tar.gz
        sudo tar -xf crictl.tar.gz -C /usr/local/bin
        rm -rf crictl.tar.gz
        crictl --version || true
        echo "==============================="
        echo "Installing CRI-Dockerd"
        CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/kubernetes-sigs/cri-tools/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
        curl -fsSL -o cri-dockerd.tgz https://github.com/Mirantis/cri-dockerd/releases/download/v$CRI_DOCKERD_VERSION/cri-dockerd-$CRI_DOCKERD_VERSION.$(dpkg --print-architecture).tgz
        sudo tar -xf cri-dockerd.tgz -C /tmp
        sudo mv /tmp/cri-dockerd/cri-dockerd /usr/local/bin/cri-dockerd
        sudo chmod +x /usr/local/bin/cri-dockerd
        rm -rf cri-dockerd.tgz cri-dockerd /tmp/cri-dockerd
        git clone -q https://github.com/Mirantis/cri-dockerd.git --branch v$CRI_DOCKERD_VERSION --single-branch -c advice.detachedHead=false
        sudo mkdir -p /etc/systemd/system
        sudo cp -a -f cri-dockerd/packaging/systemd/* /etc/systemd/system
        sudo sed -i -e 's,/usr/bin/cri-dockerd,/usr/local/bin/cri-dockerd,' /etc/systemd/system/cri-docker.service
        sudo systemctl daemon-reload
        sudo systemctl enable cri-docker.service
        sudo systemctl enable cri-docker.socket
        sudo systemctl status --no-pager cri-docker.socket || true
        rm -rf cri-dockerd
        cri-dockerd --version
        echo "==============================="
        echo "Installing CNI-Plugins (Container Network Interface)"
        CNI_PLUGIN_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/containernetworking/plugins/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
        CNI_PLUGIN_TAR="cni-plugins-linux-$(dpkg --print-architecture)-$CNI_PLUGIN_VERSION.tgz"
        CNI_PLUGIN_INSTALL_DIR="/opt/cni/bin"
        curl -sLO "https://github.com/containernetworking/plugins/releases/download/$CNI_PLUGIN_VERSION/$CNI_PLUGIN_TAR"
        sudo mkdir -p "$CNI_PLUGIN_INSTALL_DIR"
        sudo tar -xf "$CNI_PLUGIN_TAR" -C "$CNI_PLUGIN_INSTALL_DIR"
        rm -rf "$CNI_PLUGIN_TAR"
        echo "==============================="
    fi
    
    echo "Installing kubectl for AMD64 / ARM64"
    curl -fsSL -o ./kubectl "https://dl.k8s.io/release/${KUBERNETES_VERSION}/bin/linux/$(dpkg --print-architecture)/kubectl"
    chmod +x ./kubectl
    sudo cp -frp ./kubectl /usr/local/bin/kubectl
    sudo ln -sf /usr/local/bin/kubectl /usr/bin/kubectl
    rm -rf kubectl
    kubectl version --client
    echo "==============================="
    
    echo "Installing Helm for AMD64 / ARM64"
    if [ "${HELM_VERSION}" = "latest" ]; then
        HELM_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/helm/helm/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
    fi
    curl -fsSL -o helm.tar.gz https://get.helm.sh/helm-${HELM_VERSION}-linux-$(dpkg --print-architecture).tar.gz
    mkdir -p helm
    tar -xf helm.tar.gz --strip-components 1 -C helm
    sudo cp -frp helm/helm /usr/local/bin/helm
    sudo ln -sf /usr/local/bin/helm /usr/bin/helm
    rm -rf helm.tar.gz helm
    helm version
    echo "==============================="
    
    echo "Installing chart-testing for AMD64 / ARM64"
    CHART_TESTING_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/helm/chart-testing/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"

    Copy link
    Contributor

    qodo-merge-pro bot commented Jul 2, 2025

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Fix incorrect repository URL
    Suggestion Impact:The suggestion was directly implemented - the repository URL in the curl command was changed from kubernetes-sigs/cri-tools to Mirantis/cri-dockerd

    code diff:

    -    CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/kubernetes-sigs/cri-tools/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
    +    CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/Mirantis/cri-dockerd/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"

    The CRI-Dockerd version is being fetched from the wrong repository. It should
    fetch from the Mirantis/cri-dockerd repository instead of
    kubernetes-sigs/cri-tools.

    tests/charts/make/chart_setup_env.sh [113]

    -CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/kubernetes-sigs/cri-tools/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"
    +CRI_DOCKERD_VERSION="$(curl -s -L -o /dev/null -w '%{url_effective}\n' https://github.com/Mirantis/cri-dockerd/releases/latest | sed -E 's#.*/tag/(v[0-9.]+).*#\1#')"

    [Suggestion processed]

    Suggestion importance[1-10]: 10

    __

    Why: The suggestion correctly identifies that the version for CRI-Dockerd is fetched from the wrong repository (kubernetes-sigs/cri-tools instead of Mirantis/cri-dockerd), which would cause the script to fail.

    High
    Fix version prefix handling

    The download URL construction is inconsistent with the version format. Since the
    version already includes 'v' prefix from the API response, adding another 'v'
    creates an invalid URL.

    tests/charts/make/chart_setup_env.sh [114]

    -curl -fsSL -o cri-dockerd.tgz https://github.com/Mirantis/cri-dockerd/releases/download/v$CRI_DOCKERD_VERSION/cri-dockerd-$CRI_DOCKERD_VERSION.$(dpkg --print-architecture).tgz
    +curl -fsSL -o cri-dockerd.tgz https://github.com/Mirantis/cri-dockerd/releases/download/$CRI_DOCKERD_VERSION/cri-dockerd-${CRI_DOCKERD_VERSION#v}.$(dpkg --print-architecture).tgz
    • Apply / Chat
    Suggestion importance[1-10]: 10

    __

    Why: The suggestion correctly identifies a bug in the download URL construction where an extra 'v' is prepended to the version tag, and it also fixes the version format in the filename, preventing a download failure.

    High
    • Update

    @VietND96 VietND96 force-pushed the update-deps-version branch from 4829ef1 to 15fc02d Compare July 2, 2025 01:36
    Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
    @VietND96 VietND96 force-pushed the update-deps-version branch from 15fc02d to fb7266e Compare July 2, 2025 01:42
    @VietND96 VietND96 merged commit 2fb7b95 into trunk Jul 2, 2025
    28 checks passed
    @VietND96 VietND96 deleted the update-deps-version branch July 2, 2025 06:07
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    [🐛 Bug]: selenium/standalone-chrome:4.31.0 container fails to save downloaded files (works on 4.30.0)
    1 participant