Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion agent/builder.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
from __future__ import annotations

import os
import shlex
import shutil
import subprocess
import tarfile
import tempfile
import time
import contextlib
import warnings
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from subprocess import Popen
from typing import TYPE_CHECKING, Dict, List, TypedDict

import docker
import jinja2
import semantic_version as sv

from agent.base import Base
from agent.build_utils.validations import check_python_syntax, get_package_manager_files
from agent.exceptions import AgentException, RegistryDownException
from agent.job import Job, Step, job, step
from agent.utils import is_registry_healthy

Check failure on line 26 in agent/builder.py

View workflow job for this annotation

GitHub Actions / Lint and Format

ruff (I001)

agent/builder.py:1:1: I001 Import block is un-sorted or un-formatted help: Organize imports

if TYPE_CHECKING:
from typing import Literal
Expand Down Expand Up @@ -361,7 +361,10 @@
actual += ".0"

sv_actual = sv.Version(actual)
sv_expected = sv.SimpleSpec(expected)
try:
sv_expected = sv.SimpleSpec(expected)
except ValueError:
sv_expected = sv.NpmSpec(expected)

return sv_actual in sv_expected

Expand Down
32 changes: 32 additions & 0 deletions agent/tests/test_builder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from __future__ import annotations

import unittest


class TestCheckVersion(unittest.TestCase):
def test_check_version(self):
from agent.builder import ValidationManager

cases = [
# python requires-python (SimpleSpec syntax)
("3.11.0", ">=3.10", True),
("3.9.0", ">=3.10", False),
("3.11", ">=3.10,<3.13", True),
("3.13", ">=3.10,<3.13", False),
# node engines (npm syntax)
("18.16.0", ">=18", True),
("16.20.0", ">=18", False),
("18.16.0", "^18.0.0", True),
("20.1.0", "^18.0.0", False),
("18.16.0", ">=18 <21", True),
("22.0.0", ">=18 <21", False),
("18.16.0", "18.x", True),
("20.0.0", "18.x", False),
("20.0.0", "20 || 22", True),
("21.0.0", "20 || 22", False),
("18.16.0", "*", True),
]

for actual, expected, want in cases:
with self.subTest(actual=actual, expected=expected):
self.assertEqual(ValidationManager.check_version(actual, expected), want)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ mariadb-binlog-indexer==0.0.19
mariadb-table-usage==0.0.3
psutil==7.0.0
tomli==2.4.1
semantic-version==2.10.0
semantic-version==2.10.0
Loading