Skip to content

Commit 5bea845

Browse files
feat: add ros backend tests (#75)
Co-authored-by: Hofer-Julian <[email protected]>
1 parent 75f1f4f commit 5bea845

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+42209
-218
lines changed

.github/workflows/CI.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,8 @@ jobs:
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242

43-
- name: Setup binary permissions
44-
run: chmod a+x artifacts/pixi*
45-
4643
- name: Run integration tests
4744
run: pixi run --locked test-slow
48-
env:
49-
PIXI_BIN_DIR: ${{ github.workspace }}/artifacts
50-
BUILD_BACKENDS_BIN_DIR: ${{ github.workspace }}/artifacts
5145

5246
test-windows-x86_64:
5347
timeout-minutes: 10
@@ -78,9 +72,6 @@ jobs:
7872
- name: Run integration tests
7973
run: pixi run --locked test-slow
8074
working-directory: ${{ env.PIXI_WORKSPACE }}
81-
env:
82-
PIXI_BIN_DIR: ${{ env.PIXI_WORKSPACE }}/artifacts
83-
BUILD_BACKENDS_BIN_DIR: ${{ env.PIXI_WORKSPACE }}/artifacts
8475

8576
test-macos-aarch64:
8677
timeout-minutes: 10
@@ -100,11 +91,5 @@ jobs:
10091
env:
10192
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10293

103-
- name: Setup binary permissions
104-
run: chmod a+x artifacts/pixi*
105-
10694
- name: Run integration tests
10795
run: pixi run --locked test-slow
108-
env:
109-
PIXI_BIN_DIR: ${{ github.workspace }}/artifacts
110-
BUILD_BACKENDS_BIN_DIR: ${{ github.workspace }}/artifacts

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ If you prefer to use local checkouts, create a `.env` file with the paths to you
2525

2626
```shell
2727
PIXI_REPO="/path/to/pixi-repository"
28-
BUILD_BACKENDS_REPO="/path/to/pixi-build-backends-repository"
29-
3028
PIXI_BIN_DIR="${PIXI_REPO}/target/pixi/release"
31-
BUILD_BACKENDS_BIN_DIR="${BUILD_BACKENDS_REPO}/target/pixi/release"
29+
30+
BUILD_BACKENDS_REPO="/path/to/pixi-build-backends-repository"
3231
```
3332

3433
Then build the binaries with:

mypy.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[mypy]
22
strict = True
3-
exclude = tests/data/pypi-indexes
3+
exclude = tests/data/pypi-indexes|.*setup\.py
44
files = tests,scripts

scripts/build-repos.py

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,28 @@ class PixiBuildError(Exception):
3535
pass
3636

3737

38+
class PixiChannelError(Exception):
39+
"""Raised when creating the testsuite channel fails."""
40+
41+
pass
42+
43+
3844
def run_command(
39-
cmd: list[str], cwd: Path | None = None, capture_output: bool = True
45+
cmd: list[str],
46+
cwd: Path | None = None,
47+
capture_output: bool = True,
48+
env: dict[str, str] | None = None,
4049
) -> tuple[int, str, str]:
4150
"""Run a command and return exit code, stdout, and stderr."""
42-
result = subprocess.run(cmd, cwd=cwd, capture_output=capture_output, text=True)
51+
result = subprocess.run(cmd, cwd=cwd, capture_output=capture_output, text=True, env=env)
4352
return result.returncode, result.stdout, result.stderr
4453

4554

55+
def executable_name(base: str) -> str:
56+
"""Return the platform specific executable name."""
57+
return f"{base}.exe" if sys.platform.startswith("win") else base
58+
59+
4660
def is_git_worktree(path: Path) -> bool:
4761
"""Check if the given path is inside a git work tree (repo or worktree)."""
4862
if not path.exists() or not path.is_dir():
@@ -89,6 +103,30 @@ def build_executables(repo_path: Path) -> None:
89103
raise PixiBuildError(error_msg)
90104

91105

106+
def create_channel(repo_path: Path, project_root: Path) -> None:
107+
"""Create the local testsuite channel and move it into this repository."""
108+
channel_source = repo_path / "artifacts-channel"
109+
110+
print("📦 Creating channel")
111+
returncode, stdout, stderr = run_command(["pixi", "run", "create-channel"], cwd=repo_path)
112+
113+
if returncode != 0:
114+
error_msg = "Failed to create testsuite channel"
115+
if stderr:
116+
error_msg += f": {stderr}"
117+
if stdout:
118+
error_msg += f" (Output: {stdout})"
119+
raise PixiChannelError(error_msg)
120+
121+
if not channel_source.exists():
122+
raise PixiChannelError(
123+
f"Expected channel directory '{channel_source}' was not created. "
124+
"Verify that 'pixi run create-channel' completed successfully."
125+
)
126+
127+
print("✅ Testsuite channel ready at source repo")
128+
129+
92130
def process_repository(repo_path: Path, repo_name: str) -> None:
93131
"""Process a single repository: verify, pull if on main, and build."""
94132
print(f"\n{'=' * 60}")
@@ -112,14 +150,12 @@ def process_repository(repo_path: Path, repo_name: str) -> None:
112150
else:
113151
print("⚠️ Could not determine current branch")
114152

115-
# Run pixi build
116-
build_executables(repo_path)
117-
118153

119154
def main() -> None:
120155
"""Main function to process repositories."""
121156
# Load environment variables from .env file
122-
env_file = Path(__file__).parent.parent / ".env"
157+
project_root = Path(__file__).parent.parent
158+
env_file = project_root / ".env"
123159
if env_file.exists():
124160
load_dotenv(env_file, override=True)
125161
print(f"✅ Loaded environment variables from {env_file}")
@@ -150,12 +186,14 @@ def main() -> None:
150186

151187
try:
152188
process_repository(pixi_repo_path, "PIXI_REPO")
189+
build_executables(pixi_repo_path)
153190
except Exception as e:
154191
print(f"❌ Error processing PIXI_REPO: {e}")
155192
success = False
156193

157194
try:
158195
process_repository(build_backends_repo_path, "BUILD_BACKENDS_REPO")
196+
create_channel(build_backends_repo_path, project_root)
159197
except Exception as e:
160198
print(f"❌ Error processing BUILD_BACKENDS_REPO: {e}")
161199
success = False

scripts/download-artifacts.py

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -139,48 +139,27 @@ def download_and_extract_artifact(
139139
console.print(f"[green]Successfully downloaded pixi binary to: {final_path}")
140140

141141
elif repo == "prefix-dev/pixi-build-backends":
142-
# Extract all pixi-build-* executables
143-
backend_executables = []
144-
is_windows = sys.platform.startswith("win")
145-
142+
# Find the pixi binary
143+
is_channel = None
146144
for file_name in file_list:
147-
base_name = Path(file_name).name
148-
if base_name.startswith("pixi-build-"):
149-
# On Windows, expect .exe extension; on others, no extension
150-
if is_windows and base_name.endswith(".exe"):
151-
backend_executables.append(file_name)
152-
elif not is_windows and not base_name.endswith(".exe") and "." not in base_name:
153-
backend_executables.append(file_name)
154-
155-
if not backend_executables:
156-
console.print("[red]Could not find any pixi-build-* executables in archive")
157-
raise FileNotFoundError(
158-
f"Could not find any pixi-build-* executables in archive. Archive contents: {file_list}"
159-
)
160-
161-
console.print(f"[blue]Found {len(backend_executables)} backend executable(s)")
162-
163-
# Extract all executables
164-
for executable in backend_executables:
165-
final_path = output_dir / Path(executable).name
166-
if final_path.exists():
167-
if final_path.is_dir():
168-
shutil.rmtree(final_path)
169-
else:
170-
final_path.unlink()
171-
172-
zip_ref.extract(executable, output_dir)
173-
extracted_path = output_dir / executable
145+
if file_name.endswith("repodata.json"):
146+
is_channel = True
147+
break
174148

175-
if extracted_path != final_path:
176-
extracted_path.rename(final_path)
149+
if not is_channel:
150+
console.print("[red]Could not locate a channel directory inside the artifact.")
151+
raise FileNotFoundError("Could not locate a channel directory inside the artifact.")
177152

178-
# Make executable on Unix systems
179-
if not sys.platform.startswith("win"):
180-
final_path.chmod(0o755)
153+
console.print("[blue]Detected backend channel artifact")
154+
final_channel_path = output_dir / "pixi-build-backends"
155+
if final_channel_path.exists():
156+
console.print(f"[yellow]Removing existing channel at {final_channel_path}")
157+
shutil.rmtree(final_channel_path)
181158

182-
console.print(f"[green]Extracted executable: {final_path}")
159+
final_channel_path.parent.mkdir(parents=True, exist_ok=True)
160+
zip_ref.extractall(final_channel_path)
183161

162+
console.print(f"[green]Channel is ready at: {final_channel_path}")
184163
else:
185164
raise ValueError(f"Unsupported repository: {repo}")
186165

0 commit comments

Comments
 (0)