Skip to content

Commit 91cb3bc

Browse files
committed
Add GitHub Actions CI/CD with multi-platform builds and test improvements
This commit adds comprehensive CI/CD infrastructure with cross-platform builds, test suite optimization, and improved cross-platform compatibility. CI/CD Infrastructure: - GitHub Actions workflow with 3 jobs: checks, tests, build - Multi-platform build matrix (8 variants): * Linux x86_64 (SIMD, with/without OpenCL) * Linux ARM64 (cross-compilation) * Windows x86_64 (SIMD) * macOS x86_64 (SIMD, with/without OpenCL) * macOS ARM64 (with/without OpenCL) - Artifacts: pocx_miner, pocx_plotter, pocx_verifier, pocx_mockchain - Caching for cargo registry, index, and build artifacts Cross-Platform Improvements: - Replace sys-info and raw-cpuid with sysinfo crate for universal CPU detection - Add platform guards for x86 SIMD feature detection - Fix ARM platform compatibility issues - Add bundled SQLite support (libsqlite3-sys) for pocx_mockchain * Eliminates system SQLite dependency on Windows/Linux/macOS * Enables cross-platform builds without external dependencies Test Suite Optimization: - Removed 24 "testing theater" tests saving ~45-60s per run - Deleted entire test files: * pocx_address/tests/integration_tests.rs (3 tests - cargo invocations) * pocx_miner/tests/property_tests.rs (10 tests - stdlib validation) - Optimized remaining integration tests: * pocx_plotter: 15→7 tests, 5.8s→0.37s (93% faster) * pocx_miner: 10→7 tests, 36s→30s (17% faster) * pocx_verifier: 8→4 tests, ~15s→0.59s (96% faster) - Fixed large file test issues: * Convert tests to use AccessType::Dummy instead of creating 1GB files * Fixes CI failures on memory-constrained runners - Optimized test binaries: * Pre-build binaries once instead of recompiling for each test Validation Improvements: - Add compression limit validation (max 6, exponential CPU load) - Add warps limit validation (max 1M) - Add CPU threads limit validation (max 128) Technical Details: - OpenCL: Auto-install ocl-icd-opencl-dev on Linux, use system framework on macOS - SQLite: Bundled with ~30s compile overhead, ~1-2MB binary size increase - ARM: Conditional SIMD compilation, graceful fallback for non-x86 platforms
1 parent 71e429d commit 91cb3bc

File tree

16 files changed

+588
-801
lines changed

16 files changed

+588
-801
lines changed

.github/workflows/ci.yml

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master, ci-integration ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
RUST_BACKTRACE: 1
12+
13+
jobs:
14+
# Quick checks on Linux
15+
checks:
16+
name: Checks (Format, Lint, Security)
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Install Rust nightly
22+
uses: dtolnay/rust-toolchain@nightly
23+
with:
24+
components: rustfmt, clippy
25+
26+
- name: Cache cargo registry
27+
uses: actions/cache@v4
28+
with:
29+
path: ~/.cargo/registry
30+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
31+
32+
- name: Cache cargo index
33+
uses: actions/cache@v4
34+
with:
35+
path: ~/.cargo/git
36+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
37+
38+
- name: Cache target directory
39+
uses: actions/cache@v4
40+
with:
41+
path: target
42+
key: ${{ runner.os }}-target-checks-${{ hashFiles('**/Cargo.lock') }}
43+
44+
- name: Check formatting
45+
run: cargo fmt --all -- --check
46+
47+
- name: Run clippy
48+
run: cargo clippy --workspace --all-targets -- -D warnings
49+
50+
- name: Security audit
51+
run: |
52+
cargo install cargo-audit --locked || true
53+
cargo audit
54+
55+
# Tests on Linux only (most comprehensive)
56+
test:
57+
name: Test Suite
58+
runs-on: ubuntu-latest
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Install Rust nightly
63+
uses: dtolnay/rust-toolchain@nightly
64+
65+
- name: Cache cargo registry
66+
uses: actions/cache@v4
67+
with:
68+
path: ~/.cargo/registry
69+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
70+
71+
- name: Cache cargo index
72+
uses: actions/cache@v4
73+
with:
74+
path: ~/.cargo/git
75+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
76+
77+
- name: Cache target directory
78+
uses: actions/cache@v4
79+
with:
80+
path: target
81+
key: ${{ runner.os }}-target-test-${{ hashFiles('**/Cargo.lock') }}
82+
83+
- name: Run tests
84+
run: cargo test --workspace
85+
timeout-minutes: 30
86+
87+
# Multi-platform builds
88+
build:
89+
name: Build - ${{ matrix.target }}
90+
runs-on: ${{ matrix.os }}
91+
strategy:
92+
fail-fast: false
93+
matrix:
94+
include:
95+
# Linux x86_64
96+
- os: ubuntu-latest
97+
target: x86_64-unknown-linux-gnu
98+
cross: false
99+
features: simd
100+
opencl: false
101+
102+
# Linux x86_64 with OpenCL
103+
- os: ubuntu-latest
104+
target: x86_64-unknown-linux-gnu
105+
cross: false
106+
features: simd,opencl
107+
opencl: true
108+
109+
# Linux ARM64
110+
- os: ubuntu-latest
111+
target: aarch64-unknown-linux-gnu
112+
cross: true
113+
features: ""
114+
opencl: false
115+
116+
# Windows x86_64
117+
- os: windows-latest
118+
target: x86_64-pc-windows-msvc
119+
cross: false
120+
features: simd
121+
opencl: false
122+
123+
# macOS x86_64
124+
- os: macos-13
125+
target: x86_64-apple-darwin
126+
cross: false
127+
features: simd
128+
opencl: false
129+
130+
# macOS x86_64 with OpenCL
131+
- os: macos-13
132+
target: x86_64-apple-darwin
133+
cross: false
134+
features: simd,opencl
135+
opencl: true
136+
137+
# macOS ARM64 (Apple Silicon)
138+
- os: macos-14
139+
target: aarch64-apple-darwin
140+
cross: false
141+
features: ""
142+
opencl: false
143+
144+
# macOS ARM64 with OpenCL
145+
- os: macos-14
146+
target: aarch64-apple-darwin
147+
cross: false
148+
features: opencl
149+
opencl: true
150+
151+
steps:
152+
- uses: actions/checkout@v4
153+
154+
- name: Install Rust nightly
155+
uses: dtolnay/rust-toolchain@nightly
156+
with:
157+
targets: ${{ matrix.target }}
158+
159+
- name: Cache cargo registry
160+
uses: actions/cache@v4
161+
with:
162+
path: ~/.cargo/registry
163+
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
164+
165+
- name: Cache cargo index
166+
uses: actions/cache@v4
167+
with:
168+
path: ~/.cargo/git
169+
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
170+
171+
- name: Cache target directory
172+
uses: actions/cache@v4
173+
with:
174+
path: target
175+
key: ${{ runner.os }}-${{ matrix.target }}-target-build-${{ hashFiles('**/Cargo.lock') }}
176+
177+
- name: Install cross-compilation tools
178+
if: matrix.cross
179+
run: |
180+
cargo install cross --git https://github.com/cross-rs/cross --locked || true
181+
182+
- name: Install OpenCL headers (Linux)
183+
if: matrix.opencl && runner.os == 'Linux'
184+
run: |
185+
sudo apt-get update
186+
sudo apt-get install -y ocl-icd-opencl-dev
187+
188+
- name: Build binaries
189+
run: |
190+
FEATURES_FLAG=""
191+
if [ -n "${{ matrix.features }}" ]; then
192+
FEATURES_FLAG="--no-default-features --features ${{ matrix.features }}"
193+
else
194+
FEATURES_FLAG="--no-default-features"
195+
fi
196+
197+
if [ "${{ matrix.cross }}" = "true" ]; then
198+
cross build --release --target ${{ matrix.target }} \
199+
-p pocx_miner \
200+
-p pocx_plotter \
201+
-p pocx_verifier \
202+
-p pocx_mockchain \
203+
$FEATURES_FLAG
204+
else
205+
cargo build --release --target ${{ matrix.target }} \
206+
-p pocx_miner \
207+
-p pocx_plotter \
208+
-p pocx_verifier \
209+
-p pocx_mockchain \
210+
$FEATURES_FLAG
211+
fi
212+
shell: bash
213+
timeout-minutes: 60
214+
215+
- name: Prepare artifacts (Unix)
216+
if: runner.os != 'Windows'
217+
run: |
218+
mkdir -p artifacts
219+
SUFFIX=""
220+
if [ "${{ matrix.opencl }}" = "true" ]; then
221+
SUFFIX="-opencl"
222+
fi
223+
cp target/${{ matrix.target }}/release/pocx_miner artifacts/pocx_miner-${{ matrix.target }}${SUFFIX}
224+
cp target/${{ matrix.target }}/release/pocx_plotter artifacts/pocx_plotter-${{ matrix.target }}${SUFFIX}
225+
cp target/${{ matrix.target }}/release/pocx_verifier artifacts/pocx_verifier-${{ matrix.target }}${SUFFIX}
226+
cp target/${{ matrix.target }}/release/pocx_mockchain artifacts/pocx_mockchain-${{ matrix.target }}${SUFFIX}
227+
chmod +x artifacts/*
228+
229+
- name: Prepare artifacts (Windows)
230+
if: runner.os == 'Windows'
231+
run: |
232+
mkdir artifacts
233+
cp target/${{ matrix.target }}/release/pocx_miner.exe artifacts/pocx_miner-${{ matrix.target }}.exe
234+
cp target/${{ matrix.target }}/release/pocx_plotter.exe artifacts/pocx_plotter-${{ matrix.target }}.exe
235+
cp target/${{ matrix.target }}/release/pocx_verifier.exe artifacts/pocx_verifier-${{ matrix.target }}.exe
236+
cp target/${{ matrix.target }}/release/pocx_mockchain.exe artifacts/pocx_mockchain-${{ matrix.target }}.exe
237+
shell: bash
238+
239+
- name: Upload artifacts
240+
uses: actions/upload-artifact@v4
241+
with:
242+
name: binaries-${{ matrix.target }}${{ matrix.opencl && '-opencl' || '' }}
243+
path: artifacts/*
244+
retention-days: 90
245+
246+
# Summary job
247+
ci-success:
248+
name: CI Success
249+
needs: [checks, test, build]
250+
runs-on: ubuntu-latest
251+
if: always()
252+
steps:
253+
- name: Check all jobs
254+
run: |
255+
if [ "${{ needs.checks.result }}" != "success" ] || \
256+
[ "${{ needs.test.result }}" != "success" ] || \
257+
[ "${{ needs.build.result }}" != "success" ]; then
258+
echo "One or more CI jobs failed"
259+
exit 1
260+
fi
261+
echo "All CI jobs passed successfully!"

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ axum = "0.8"
5050
toml = "0.9"
5151
diesel = { version = "2.3", features = ["sqlite", "r2d2", "chrono"] }
5252
diesel_migrations = "2.3"
53+
libsqlite3-sys = { version = "0.30", features = ["bundled"] }
5354
r2d2 = "0.8"
5455
tower = "0.5"
5556
tower-http = { version = "0.6", features = ["cors"] }

pocx_address/tests/integration_tests.rs

Lines changed: 0 additions & 52 deletions
This file was deleted.

pocx_hashlib/src/buffer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ use crate::error::{PoCXHashError, Result};
2222
use std::alloc::{alloc_zeroed, dealloc, Layout};
2323

2424
#[derive(Debug)]
25+
#[cfg_attr(
26+
not(any(target_arch = "x86", target_arch = "x86_64")),
27+
allow(dead_code)
28+
)]
2529
pub struct PageAlignedByteBuffer {
2630
data: Option<Vec<u8>>,
2731
pointer: *mut u8,
2832
layout: Layout,
2933
}
3034

35+
#[cfg_attr(
36+
not(any(target_arch = "x86", target_arch = "x86_64")),
37+
allow(dead_code)
38+
)]
3139
impl PageAlignedByteBuffer {
3240
/// Creates a new page-aligned buffer with the specified size.
3341
///

0 commit comments

Comments
 (0)