Skip to content

Commit b4cfce1

Browse files
committed
add: remote build command
1 parent 05b66a6 commit b4cfce1

File tree

9 files changed

+364
-4
lines changed

9 files changed

+364
-4
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,51 @@ jobs:
5050
- name: Test requirements-checker with --setup
5151
run: |
5252
cargo run -- requirements-checker --setup
53-
continue-on-error: false
53+
continue-on-error: false
54+
55+
build-commands-test:
56+
runs-on: ubuntu-latest
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Setup Rust toolchain
62+
uses: actions-rust-lang/setup-rust-toolchain@v1
63+
64+
- name: Build
65+
run: cargo build
66+
67+
- name: Set up Docker Buildx
68+
uses: docker/setup-buildx-action@v3
69+
70+
- name: Build Docker builder image
71+
run: docker build -t foc-localnet-builder ./docker
72+
73+
- name: Verify Docker image was built
74+
run: docker images foc-localnet-builder
75+
76+
- name: Test build command with invalid path (should fail gracefully)
77+
run: |
78+
if ./target/debug/foc-localnet build lotus /nonexistent/path 2>&1; then
79+
echo "Expected command to fail with nonexistent path"
80+
exit 1
81+
fi
82+
83+
- name: Test Lotus build command (with timeout to avoid long builds)
84+
run: |
85+
# Test the build command with a timeout to avoid excessive CI time
86+
# This will test the cloning and Docker setup without full build
87+
timeout 600 ./target/debug/foc-localnet build lotus || echo "Build timed out or failed as expected"
88+
89+
- name: Test Curio build command (with timeout to avoid long builds)
90+
run: |
91+
# Test the build command with a timeout to avoid excessive CI time
92+
# This will test the cloning and Docker setup without full build
93+
timeout 600 ./target/debug/foc-localnet build curio || echo "Build timed out or failed as expected"
94+
95+
- name: Check if any output was generated
96+
run: |
97+
echo "Contents of test-output directory:"
98+
ls -la test-output/ || echo "No output directory found"
99+
echo "Contents of ~/.foc-localnet/bin/ if it exists:"
100+
ls -la ~/.foc-localnet/bin/ 2>/dev/null || echo "Default output directory not found"

Cargo.lock

Lines changed: 83 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ serde = { version = "1.0", features = ["derive"] }
1212
toml = "0.8"
1313
crossterm = "0.27"
1414
dirs = "5.0"
15-
chrono = { version = "0.4", features = ["serde"] }
15+
chrono = { version = "0.4", features = ["serde"] }
16+
tempfile = "3.0"

docker/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
FROM ubuntu:22.04
2+
3+
# Install system dependencies
4+
RUN apt-get update && apt-get install -y \
5+
mesa-opencl-icd \
6+
ocl-icd-opencl-dev \
7+
gcc \
8+
git \
9+
bzr \
10+
jq \
11+
pkg-config \
12+
curl \
13+
clang \
14+
build-essential \
15+
hwloc \
16+
libhwloc-dev \
17+
wget \
18+
ca-certificates \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Install Go 1.24.7
22+
RUN wget -c https://golang.org/dl/go1.24.7.linux-amd64.tar.gz -O - | tar -xz -C /usr/local
23+
ENV PATH=$PATH:/usr/local/go/bin
24+
25+
# Install Rust (for building proofs if needed)
26+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
27+
ENV PATH=$PATH:/root/.cargo/bin
28+
29+
# Set working directory
30+
WORKDIR /workspace
31+
32+
# Default command
33+
CMD ["/bin/bash"]

src/cli.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,30 @@ pub enum Commands {
2929
#[arg(long)]
3030
setup: bool,
3131
},
32+
/// Build Filecoin projects in a container
33+
Build {
34+
#[command(subcommand)]
35+
build_command: BuildCommands,
36+
},
37+
}
38+
39+
/// Build subcommands
40+
#[derive(Subcommand)]
41+
pub enum BuildCommands {
42+
/// Build Lotus (lotus and lotus-miner)
43+
Lotus {
44+
/// Path to the Lotus source directory (optional, will clone if not provided)
45+
path: Option<String>,
46+
/// Output directory for built binaries
47+
#[arg(long)]
48+
output_dir: Option<String>,
49+
},
50+
/// Build Curio
51+
Curio {
52+
/// Path to the Curio source directory (optional, will clone if not provided)
53+
path: Option<String>,
54+
/// Output directory for built binaries
55+
#[arg(long)]
56+
output_dir: Option<String>,
57+
},
3258
}

0 commit comments

Comments
 (0)