Skip to content

Commit fecbc4d

Browse files
committed
Move Go, Julia, Python check/test from CLI to Justfile recipes
1 parent 59560a7 commit fecbc4d

6 files changed

Lines changed: 88 additions & 875 deletions

File tree

Justfile

Lines changed: 66 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ list-deps: check-cli
7474
[group('build')]
7575
build profile="debug": check-cli setup-quiet sync-deps build-selene
7676
{{pecos}} python build --profile {{profile}}
77-
@command -v julia >/dev/null 2>&1 && {{pecos}} julia build --profile {{profile}} || true
78-
@command -v go >/dev/null 2>&1 && {{pecos}} go build --profile {{profile}} || true
77+
@command -v julia >/dev/null 2>&1 && just julia-build {{profile}} || true
78+
@command -v go >/dev/null 2>&1 && just go-build {{profile}} || true
7979

8080
# Build PECOS without dependency setup or sync
8181
[group('build')]
@@ -93,9 +93,15 @@ build-cuda profile="debug": check-cli setup-quiet
9393

9494
# Run Python tests (core)
9595
[group('test')]
96-
pytest:
97-
uv run pytest python/pecos-rslib/tests -m "not performance and not numpy"
98-
uv run pytest python/quantum-pecos/tests -m "not optional_dependency and not numpy"
96+
pytest *args:
97+
#!/usr/bin/env bash
98+
set -euo pipefail
99+
if [ -n "{{args}}" ]; then
100+
uv run pytest {{args}}
101+
else
102+
uv run pytest python/pecos-rslib/tests -m "not performance and not numpy"
103+
uv run pytest python/quantum-pecos/tests -m "not optional_dependency and not numpy"
104+
fi
99105
100106
# Run Rust tests (CUDA-aware, release mode)
101107
[group('test')]
@@ -109,13 +115,13 @@ test: rstest-all pytest-all
109115
set -euo pipefail
110116
if command -v julia >/dev/null 2>&1; then
111117
echo "Julia detected, running Julia tests..."
112-
{{pecos}} julia test
118+
just julia-test
113119
else
114120
echo "Julia not detected, skipping Julia tests"
115121
fi
116122
if command -v go >/dev/null 2>&1; then
117123
echo "Go detected, running Go tests..."
118-
{{pecos}} go test
124+
just go-test
119125
else
120126
echo "Go not detected, skipping Go tests"
121127
fi
@@ -139,16 +145,16 @@ lint: fmt clippy
139145
140146
if command -v julia >/dev/null 2>&1; then
141147
echo "Julia detected, running Julia formatting check and linting..."
142-
{{pecos}} julia fmt --check
143-
{{pecos}} julia lint
148+
just julia-fmt-check
149+
just julia-lint
144150
else
145151
echo "Julia not detected, skipping Julia linting"
146152
fi
147153
148154
if command -v go >/dev/null 2>&1; then
149155
echo "Go detected, running Go formatting check and linting..."
150-
test -z "$(gofmt -l go/pecos)" || (gofmt -l go/pecos && exit 1)
151-
cd go/pecos && go vet ./...
156+
just go-fmt-check
157+
just go-lint
152158
else
153159
echo "Go not detected, skipping Go linting"
154160
fi
@@ -167,13 +173,13 @@ lint-fix:
167173
echo ""
168174
if command -v julia >/dev/null 2>&1; then
169175
echo "Fixing Julia formatting..."
170-
{{pecos}} julia fmt
176+
just julia-fmt
171177
else
172178
echo "Julia not detected, skipping Julia formatting"
173179
fi
174180
if command -v go >/dev/null 2>&1; then
175181
echo "Fixing Go formatting..."
176-
gofmt -w go/pecos
182+
just go-fmt
177183
else
178184
echo "Go not detected, skipping Go formatting"
179185
fi
@@ -281,42 +287,71 @@ check-cuda: check-cli
281287

282288
# Build Julia FFI library
283289
[group('julia')]
284-
julia-build profile="release": check-cli
285-
{{pecos}} julia build --profile {{profile}}
290+
julia-build profile="release" rustflags="":
291+
#!/usr/bin/env bash
292+
set -euo pipefail
293+
if [ -n "{{rustflags}}" ]; then
294+
export RUSTFLAGS="${RUSTFLAGS:-} {{rustflags}}"
295+
fi
296+
case "{{profile}}" in
297+
native) cargo build --profile native -p pecos-julia-ffi ;;
298+
release) cargo build --release -p pecos-julia-ffi ;;
299+
dev|debug) cargo build -p pecos-julia-ffi ;;
300+
*) echo "Unknown profile: {{profile}}"; exit 1 ;;
301+
esac
286302
287303
# Run Julia tests
288304
[group('julia')]
289-
julia-test: check-cli
290-
{{pecos}} julia test
305+
julia-test: (julia-build "release")
306+
cd julia/PECOS.jl && julia --project=. -e 'using Pkg; Pkg.instantiate(); include("test/runtests.jl")'
291307

292308
# Format Julia code
293309
[group('julia')]
294-
julia-format: check-cli
295-
{{pecos}} julia fmt
310+
julia-fmt:
311+
#!/usr/bin/env bash
312+
set -euo pipefail
313+
julia -e 'using Pkg; Pkg.activate(); haskey(Pkg.project().dependencies, "JuliaFormatter") || Pkg.add("JuliaFormatter")'
314+
cd julia/PECOS.jl && julia -e 'using JuliaFormatter; format("."; verbose=true)'
296315
297316
# Check Julia code formatting
298317
[group('julia')]
299-
julia-format-check: check-cli
300-
{{pecos}} julia fmt --check
318+
julia-fmt-check:
319+
#!/usr/bin/env bash
320+
set -euo pipefail
321+
julia -e 'using Pkg; Pkg.activate(); haskey(Pkg.project().dependencies, "JuliaFormatter") || Pkg.add("JuliaFormatter")'
322+
cd julia/PECOS.jl && julia -e 'using JuliaFormatter; format("."; verbose=false, overwrite=false) || (println("Run just julia-fmt to fix."); exit(1))'
301323
302324
# Run Aqua.jl quality checks
303325
[group('julia')]
304-
julia-lint: check-cli
305-
{{pecos}} julia lint
326+
julia-lint: (julia-build "release")
327+
cd julia/PECOS.jl && julia --project=. test/aqua_tests.jl
306328

307329
# =============================================================================
308330
# Go Bindings
309331
# =============================================================================
310332

311333
# Build Go FFI library
312334
[group('go')]
313-
go-build profile="release": check-cli
314-
{{pecos}} go build --profile {{profile}}
335+
go-build profile="release" rustflags="":
336+
#!/usr/bin/env bash
337+
set -euo pipefail
338+
if [ -n "{{rustflags}}" ]; then
339+
export RUSTFLAGS="${RUSTFLAGS:-} {{rustflags}}"
340+
fi
341+
case "{{profile}}" in
342+
native) cargo build --profile native -p pecos-go-ffi ;;
343+
release) cargo build --release -p pecos-go-ffi ;;
344+
dev|debug) cargo build -p pecos-go-ffi ;;
345+
*) echo "Unknown profile: {{profile}}"; exit 1 ;;
346+
esac
315347
316348
# Run Go tests
317349
[group('go')]
318-
go-test: check-cli
319-
{{pecos}} go test
350+
go-test: (go-build "release")
351+
#!/usr/bin/env bash
352+
set -euo pipefail
353+
export LD_LIBRARY_PATH="$(pwd)/target/release:${LD_LIBRARY_PATH:-}"
354+
cd go/pecos && go test -v
320355
321356
# Format Go code
322357
[group('go')]
@@ -394,7 +429,7 @@ test-all: rstest-all pytest-all
394429
set -euo pipefail
395430
if command -v julia >/dev/null 2>&1; then
396431
echo "Julia detected, running Julia tests..."
397-
{{pecos}} julia test
432+
just julia-test
398433
else
399434
echo ""
400435
echo "WARNING: Julia is not installed. Skipping Julia tests."
@@ -403,7 +438,7 @@ test-all: rstest-all pytest-all
403438
fi
404439
if command -v go >/dev/null 2>&1; then
405440
echo "Go detected, running Go tests..."
406-
{{pecos}} go test
441+
just go-test
407442
else
408443
echo ""
409444
echo "WARNING: Go is not installed. Skipping Go tests."
@@ -610,11 +645,7 @@ docs-test-legacy:
610645

611646
# Julia/Go extras
612647
[private]
613-
julia-build-debug:
614-
{{pecos}} julia build --profile debug
615-
616-
[private]
617-
julia-examples: julia-build-debug
648+
julia-examples: (julia-build "debug")
618649
#!/usr/bin/env bash
619650
set -euo pipefail
620651
if command -v julia >/dev/null 2>&1; then
@@ -633,8 +664,7 @@ julia-clean:
633664
rm -f julia/PECOS.jl/Manifest.toml julia/PECOS.jl/dev/PECOS_julia_jll/Manifest.toml || true
634665

635666
[private]
636-
go-build-debug:
637-
{{pecos}} go build --profile debug
667+
go-build-debug: (go-build "debug")
638668

639669
[private]
640670
go-info:

crates/pecos/src/bin/cli.rs

Lines changed: 0 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ pub mod cuda_cmd;
1111
pub mod cuquantum_cmd;
1212
pub mod docs_cmd;
1313
pub mod features_cmd;
14-
pub mod go_cmd;
1514
pub mod gpu_cmd;
1615
pub mod info;
1716
pub mod install_cmd;
18-
pub mod julia_cmd;
1917
pub mod list;
2018
pub mod llvm_cmd;
2119
pub mod manifest_cmd;
@@ -96,13 +94,6 @@ pub enum RustCommands {
9694

9795
#[derive(Subcommand, Clone)]
9896
pub enum PythonCommands {
99-
/// Check if Python/uv is available
100-
Check {
101-
/// Suppress output (exit code only)
102-
#[arg(short, long)]
103-
quiet: bool,
104-
},
105-
10697
/// Build pecos-rslib and quantum-pecos
10798
///
10899
/// Uses maturin to build the Rust library and installs quantum-pecos
@@ -120,25 +111,6 @@ pub enum PythonCommands {
120111
#[arg(long)]
121112
cuda: bool,
122113
},
123-
124-
/// Run Python tests with pytest
125-
Test {
126-
/// Pytest markers to filter tests (e.g., "not slow")
127-
#[arg(short, long)]
128-
markers: Option<String>,
129-
130-
/// Increase verbosity (-v, -vv)
131-
#[arg(short, long, action = clap::ArgAction::Count)]
132-
verbose: u8,
133-
134-
/// Run Selene plugin tests instead of core tests
135-
#[arg(long)]
136-
selene: bool,
137-
138-
/// Run NumPy/SciPy compatibility tests
139-
#[arg(long)]
140-
numpy: bool,
141-
},
142114
}
143115

144116
// ============================================================================
@@ -231,82 +203,6 @@ pub enum GpuCommands {
231203
},
232204
}
233205

234-
// ============================================================================
235-
// Julia Commands
236-
// ============================================================================
237-
238-
#[derive(Subcommand, Clone)]
239-
pub enum JuliaCommands {
240-
/// Check if Julia is available
241-
Check {
242-
/// Suppress output (exit code only)
243-
#[arg(short, long)]
244-
quiet: bool,
245-
},
246-
247-
/// Build Julia FFI library
248-
Build {
249-
/// Build profile (dev/debug, release, native)
250-
#[arg(long, default_value = "dev")]
251-
profile: String,
252-
253-
/// Additional RUSTFLAGS (e.g., "-C target-cpu=native")
254-
#[arg(long)]
255-
rustflags: Option<String>,
256-
},
257-
258-
/// Run Julia tests
259-
Test,
260-
261-
/// Format Julia code
262-
Fmt {
263-
/// Check formatting without modifying files
264-
#[arg(long)]
265-
check: bool,
266-
},
267-
268-
/// Run Julia linting (Aqua.jl)
269-
Lint,
270-
}
271-
272-
// ============================================================================
273-
// Go Commands
274-
// ============================================================================
275-
276-
#[derive(Subcommand, Clone)]
277-
pub enum GoCommands {
278-
/// Check if Go is available
279-
Check {
280-
/// Suppress output (exit code only)
281-
#[arg(short, long)]
282-
quiet: bool,
283-
},
284-
285-
/// Build Go FFI library
286-
Build {
287-
/// Build profile (dev/debug, release, native)
288-
#[arg(long, default_value = "dev")]
289-
profile: String,
290-
291-
/// Additional RUSTFLAGS (e.g., "-C target-cpu=native")
292-
#[arg(long)]
293-
rustflags: Option<String>,
294-
},
295-
296-
/// Run Go tests
297-
Test,
298-
299-
/// Format Go code
300-
Fmt {
301-
/// Check formatting without modifying files
302-
#[arg(long)]
303-
check: bool,
304-
},
305-
306-
/// Run Go linting (go vet)
307-
Lint,
308-
}
309-
310206
// ============================================================================
311207
// Selene Commands
312208
// ============================================================================
@@ -507,24 +403,6 @@ pub fn run_gpu(command: &GpuCommands) -> pecos_build::Result<()> {
507403
gpu_cmd::run(command)
508404
}
509405

510-
/// Run a Julia subcommand
511-
///
512-
/// # Errors
513-
///
514-
/// Returns an error if the subcommand fails.
515-
pub fn run_julia(command: &JuliaCommands) -> pecos_build::Result<()> {
516-
julia_cmd::run(command)
517-
}
518-
519-
/// Run a Go subcommand
520-
///
521-
/// # Errors
522-
///
523-
/// Returns an error if the subcommand fails.
524-
pub fn run_go(command: &GoCommands) -> pecos_build::Result<()> {
525-
go_cmd::run(command)
526-
}
527-
528406
/// Run a Selene subcommand
529407
///
530408
/// # Errors

0 commit comments

Comments
 (0)