Skip to content

Commit

Permalink
Build Script Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tjemmmic committed Aug 21, 2024
1 parent f54ea59 commit 70f73a9
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 38 deletions.
31 changes: 0 additions & 31 deletions .github/workflows/validate_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,6 @@ env:
CARGO_TERM_COLOR: always

jobs:
forge:
name: Forge
runs-on: macos-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Install Foundry
run: |
curl -L https://foundry.paradigm.xyz | bash
source /Users/runner/.bashrc
foundryup
- name: Add Foundry to PATH
run: echo "${HOME}/.foundry/bin" >> $GITHUB_PATH

- name: Verify Forge installation
run: forge --version

- name: Run build script
run: |
chmod +x ./test-utils/scripts/build.sh
./test-utils/scripts/build.sh
- name: Upload Build Artifacts
if: success()
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: ./out/

formatting:
name: Rustfmt
runs-on: ubuntu-latest
Expand Down
9 changes: 5 additions & 4 deletions avs/incredible-squaring-avs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use std::process::Command;
fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec![
"../../contracts",
"../../contracts/lib/eigenlayer-middleware",
"contracts",
"./../../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./../../contracts/lib/eigenlayer-middleware",
"./../../contracts/",
"./contracts",
];

// Get the project root directory
Expand All @@ -19,7 +20,7 @@ fn main() {
if full_path.exists() {
println!("cargo:rerun-if-changed={}", full_path.display());

let status = Command::new("/home/tjemmmic/.foundry/bin/forge")
let status = Command::new("forge")
.current_dir(&full_path)
.arg("build")
.status()
Expand Down
7 changes: 4 additions & 3 deletions avs/tangle-avs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use std::process::Command;
fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec![
"../../contracts",
"../../contracts/lib/eigenlayer-middleware",
"contracts",
"./../../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./../../contracts/lib/eigenlayer-middleware",
"./../../contracts/",
"./contracts",
];

// Get the project root directory
Expand Down
35 changes: 35 additions & 0 deletions contracts/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use std::env;
use std::path::Path;
use std::process::Command;

fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec![
"./lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./lib/eigenlayer-middleware",
"./",
];

// Get the project root directory
let root = env::var("CARGO_MANIFEST_DIR").unwrap();

for dir in contract_dirs {
let full_path = Path::new(&root).join(dir).canonicalize().unwrap();

if full_path.exists() {
println!("cargo:rerun-if-changed={}", full_path.display());

let status = Command::new("forge")
.current_dir(&full_path)
.arg("build")
.status()
.expect("Failed to execute Forge build");

if !status.success() {
panic!("Forge build failed for directory: {}", full_path.display());
}
} else {
println!("Directory not found: {}", full_path.display());
}
}
}
37 changes: 37 additions & 0 deletions test-utils/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::env;
use std::path::Path;
use std::process::Command;

fn main() {
// List of directories containing Solidity contracts
let contract_dirs = vec![
"./../contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts",
"./../contracts/lib/eigenlayer-middleware",
"./../contracts/",
"./../avs/tangle-avs/contracts",
"./../avs/incredible-squaring-avs/contracts",
];

// Get the project root directory
let root = env::var("CARGO_MANIFEST_DIR").unwrap();

for dir in contract_dirs {
let full_path = Path::new(&root).join(dir).canonicalize().unwrap();

if full_path.exists() {
println!("cargo:rerun-if-changed={}", full_path.display());

let status = Command::new("forge")
.current_dir(&full_path)
.arg("build")
.status()
.expect("Failed to execute Forge build");

if !status.success() {
panic!("Forge build failed for directory: {}", full_path.display());
}
} else {
println!("Directory not found: {}", full_path.display());
}
}
}
24 changes: 24 additions & 0 deletions test-utils/scripts/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Define the directories
DIR0="./contracts/lib/eigenlayer-middleware/lib/eigenlayer-contracts"
DIR1="./contracts/lib/eigenlayer-middleware"
DIR2="./contracts"
DIR3="./avs/incredible-squaring-avs/contracts"
DIR4="./avs/tangle-avs/contracts"

# Function to run forge commands in a directory
run_forge_commands() {
local dir=$1
echo "Running forge commands in $dir"
cd "$dir" || exit
forge clean
cd - || exit
}

# Run forge commands in all listed directories
run_forge_commands "$DIR0"
run_forge_commands "$DIR1"
run_forge_commands "$DIR2"
run_forge_commands "$DIR3"
run_forge_commands "$DIR4"

0 comments on commit 70f73a9

Please sign in to comment.