JetReconstruction.jl locally tested #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| pull_request: | |
| branches: [ main, master ] | |
| jobs: | |
| test: | |
| name: Julia ${{ matrix.version }} - ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: | |
| - '1.10' | |
| - '1.11' | |
| os: | |
| - ubuntu-latest | |
| arch: | |
| - x64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Julia environment | |
| uses: julia-actions/setup-julia@v1 | |
| with: | |
| version: ${{ matrix.version }} | |
| arch: ${{ matrix.arch }} | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| build-essential \ | |
| cmake \ | |
| pkg-config \ | |
| libhepmc3-dev \ | |
| python3-dev \ | |
| libclang-dev \ | |
| clang | |
| - name: Cache Julia packages | |
| uses: actions/cache@v4 | |
| env: | |
| cache-name: cache-artifacts | |
| with: | |
| path: ~/.julia | |
| key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }} | |
| restore-keys: ${{ runner.os }}-test-${{ env.cache-name }}- | |
| - name: Setup Julia project and install dependencies | |
| run: | | |
| julia --project=. -e " | |
| using Pkg | |
| Pkg.instantiate() | |
| # Install additional required packages | |
| Pkg.add([\"CxxWrap\", \"WrapIt\"]) | |
| # Load to trigger any builds | |
| using CxxWrap | |
| using WrapIt | |
| WrapIt.install() | |
| " | |
| - name: Find and install WrapIt executable | |
| run: | | |
| # Try multiple ways to find WrapIt executable | |
| echo "=== Searching for WrapIt executable ===" | |
| # Method 1: Check if it's in Julia packages | |
| JULIA_DEPOT=$(julia -e "println(first(DEPOT_PATH))") | |
| echo "Julia depot: $JULIA_DEPOT" | |
| # Search for wrapit executable | |
| find $JULIA_DEPOT -name "wrapit*" -type f 2>/dev/null || echo "No wrapit found in depot" | |
| find ~/.julia -name "wrapit*" -type f 2>/dev/null || echo "No wrapit found in ~/.julia" | |
| # Method 2: Try to get path from WrapIt module | |
| WRAPIT_PATH=$(julia --project=. -e " | |
| using WrapIt | |
| # Try different possible function names | |
| try | |
| println(WrapIt.wrapit_executable()) | |
| catch | |
| try | |
| println(WrapIt.executable_path()) | |
| catch | |
| try | |
| println(joinpath(dirname(pathof(WrapIt)), \"..\", \"deps\", \"wrapit\")) | |
| catch | |
| # Search in WrapIt package directory | |
| pkg_dir = dirname(dirname(pathof(WrapIt))) | |
| println(\"Searching in: \", pkg_dir) | |
| for (root, dirs, files) in walkdir(pkg_dir) | |
| for file in files | |
| if startswith(file, \"wrapit\") && isfile(joinpath(root, file)) | |
| println(joinpath(root, file)) | |
| break | |
| end | |
| end | |
| end | |
| end | |
| end | |
| end | |
| " 2>/dev/null || echo "Could not determine WrapIt path via Julia") | |
| echo "WrapIt path candidate: $WRAPIT_PATH" | |
| # Method 3: Manual search and install | |
| if [ -n "$WRAPIT_PATH" ] && [ -f "$WRAPIT_PATH" ]; then | |
| echo "Found WrapIt at: $WRAPIT_PATH" | |
| sudo cp "$WRAPIT_PATH" /usr/bin/wrapit | |
| sudo chmod +x /usr/bin/wrapit | |
| else | |
| echo "=== Manual WrapIt search ===" | |
| # Search common locations | |
| POSSIBLE_LOCATIONS=( | |
| "$JULIA_DEPOT/packages/WrapIt" | |
| "$JULIA_DEPOT/packages/WrapIt/*/deps" | |
| "$JULIA_DEPOT/packages/WrapIt/*/bin" | |
| "~/.julia/packages/WrapIt" | |
| "~/.julia/packages/WrapIt/*/deps" | |
| "~/.julia/packages/WrapIt/*/bin" | |
| ) | |
| FOUND_WRAPIT="" | |
| for loc in "${POSSIBLE_LOCATIONS[@]}"; do | |
| echo "Checking: $loc" | |
| if [ -d "$loc" ]; then | |
| FOUND_WRAPIT=$(find "$loc" -name "wrapit*" -type f -executable 2>/dev/null | head -1) | |
| if [ -n "$FOUND_WRAPIT" ]; then | |
| echo "Found WrapIt executable: $FOUND_WRAPIT" | |
| sudo cp "$FOUND_WRAPIT" /usr/bin/wrapit | |
| sudo chmod +x /usr/bin/wrapit | |
| break | |
| fi | |
| fi | |
| done | |
| if [ -z "$FOUND_WRAPIT" ]; then | |
| echo "❌ Could not find WrapIt executable, trying to build from source" | |
| julia --project=. -e " | |
| using WrapIt | |
| # Force rebuild/reinstall | |
| try | |
| WrapIt.build() | |
| catch e | |
| println(\"Build failed: \", e) | |
| end | |
| " | |
| # Try search again after build | |
| FOUND_WRAPIT=$(find ~/.julia -name "wrapit*" -type f -executable 2>/dev/null | head -1) | |
| if [ -n "$FOUND_WRAPIT" ]; then | |
| echo "Found WrapIt after build: $FOUND_WRAPIT" | |
| sudo cp "$FOUND_WRAPIT" /usr/bin/wrapit | |
| sudo chmod +x /usr/bin/wrapit | |
| fi | |
| fi | |
| fi | |
| # Verify installation | |
| if command -v wrapit &> /dev/null; then | |
| echo "✅ WrapIt installed successfully" | |
| wrapit --version || echo "WrapIt installed but no version info" | |
| which wrapit | |
| else | |
| echo "❌ WrapIt installation failed" | |
| exit 1 | |
| fi | |
| - name: Clean and rebuild bindings from scratch | |
| run: | | |
| cd gen | |
| rm -rf build/ cpp/jlHepMC3.* jl/ | |
| # Find Julia's libclang and set environment | |
| JULIA_DEPOT=$(julia -e "println(first(DEPOT_PATH))") | |
| LIBCLANG_DIR=$(find $JULIA_DEPOT -name "libclang*.so*" 2>/dev/null | head -1 | xargs dirname) | |
| # Run build.jl with proper library path | |
| LD_LIBRARY_PATH="$LIBCLANG_DIR:$LD_LIBRARY_PATH" julia --project=.. build.jl | |
| - name: Apply manual wrapper patches | |
| run: | | |
| # Apply the patches to include manual wrappers | |
| sed -i '/#include "HepMC3\/Units.h"/a #include "HepMC3Wrap.h"' gen/cpp/jlHepMC3.cxx | |
| sed -i '/for(const auto& w: wrappers) w->add_methods();/a \ add_manual_hepmc3_methods(jlModule);' gen/cpp/jlHepMC3.cxx | |
| # Verify patches were applied | |
| echo "=== Checking if patches were applied ===" | |
| grep -n "HepMC3Wrap.h" gen/cpp/jlHepMC3.cxx || echo "❌ HepMC3Wrap.h not found" | |
| grep -n "add_manual_hepmc3_methods" gen/cpp/jlHepMC3.cxx || echo "❌ add_manual_hepmc3_methods not found" | |
| - name: Rebuild with manual wrappers | |
| run: | | |
| cd gen/build | |
| cmake --build . --config Release --parallel 8 | |
| - name: Test basic example | |
| run: | | |
| julia --project=. examples/basic_tree_julia.jl | |
| - name: Run test suite | |
| run: | | |
| julia --project=. -e " | |
| using Pkg | |
| Pkg.test() | |
| " | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-results-${{ matrix.os }}-${{ matrix.version }} | |
| path: | | |
| gen/build/ | |
| examples/ | |
| test/ |