Skip to content

Commit eda4a30

Browse files
committed
Add CI step to install foundry
1 parent f862526 commit eda4a30

File tree

2 files changed

+41
-33
lines changed

2 files changed

+41
-33
lines changed

.circleci/config.yml

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,15 @@ defaults:
293293
sudo apt install python3-pip --assume-yes --no-install-recommends
294294
python3 -m pip install requests --user
295295
296+
- steps_install_foundry: &steps_install_foundry
297+
steps:
298+
- run:
299+
name: Install foundry
300+
command: |
301+
# Note: Currently Foundry only has nightly builds and there is no release checksum
302+
wget https://github.com/foundry-rs/foundry/releases/download/nightly/foundry_nightly_linux_amd64.tar.gz --output-document /tmp/foundry.tar.gz
303+
sudo tar --extract --gzip --file /tmp/foundry.tar.gz --directory /usr/local/bin
304+
296305
# --------------------------------------------------------------------------
297306
# Base Image Templates
298307

@@ -1215,15 +1224,14 @@ jobs:
12151224
type: boolean
12161225
default: false
12171226
docker:
1218-
- image: <<parameters.image>>
1219-
resource_class: <<parameters.resource_class>>
1227+
- image: << parameters.image >>
1228+
resource_class: << parameters.resource_class >>
12201229
# NOTE: Each external test runs up to 6 independent settings presets. If parallelism is higher than
12211230
# actual preset count, some runs will exit immediately. If it's lower, some runs will get more than one preset.
12221231
parallelism: 6
12231232
environment:
12241233
TERM: xterm
1225-
COMPILE_ONLY: <<parameters.compile_only>>
1226-
<<: *steps_install_python_dependencies
1234+
COMPILE_ONLY: << parameters.compile_only >>
12271235
steps:
12281236
- checkout
12291237
- attach_workspace:
@@ -1234,6 +1242,15 @@ jobs:
12341242
# lsof is used by Colony in its stop-blockchain-client.sh script
12351243
sudo apt update
12361244
sudo apt-get --quiet --assume-yes --no-install-recommends install lsof
1245+
- when:
1246+
condition: true
1247+
<<: *steps_install_python_dependencies
1248+
- when:
1249+
condition:
1250+
matches:
1251+
pattern: /^.+rust.+$/
1252+
value: << parameters.image >>
1253+
<<: *steps_install_foundry
12371254
- when:
12381255
condition: << parameters.python2 >>
12391256
steps:
@@ -1249,17 +1266,30 @@ jobs:
12491266
equal: [<< parameters.binary_type >>, "solcjs"]
12501267
steps:
12511268
- run:
1252-
name: External <<parameters.project>> tests (solcjs)
1269+
name: External << parameters.project >> tests (solcjs)
1270+
command: |
1271+
test/externalTests/<< parameters.project >>.sh solcjs /tmp/workspace/soljson.js
1272+
- when:
1273+
condition:
1274+
and:
1275+
- equal: [<< parameters.binary_type >>, "native"]
1276+
- equal: [<< parameters.project >>, "prb-math"]
1277+
steps:
1278+
- run:
1279+
name: External << parameters.project >> tests (native)
12531280
command: |
1254-
test/externalTests/<<parameters.project>>.py solcjs /tmp/workspace/soljson.js
1281+
test/externalTests/<< parameters.project >>.py --solc-binary-type native --solc-binary-path /tmp/workspace/solc/solc
1282+
# TODO: remove after address comment: https://github.com/ethereum/solidity/pull/13873#discussion_r1081687334
12551283
- when:
12561284
condition:
1257-
equal: [<< parameters.binary_type >>, "native"]
1285+
and:
1286+
- equal: [<< parameters.binary_type >>, "native"]
1287+
- not equal: [<< parameters.project >>, "prb-math"]
12581288
steps:
12591289
- run:
1260-
name: External <<parameters.project>> tests (native)
1290+
name: External << parameters.project >> tests (native)
12611291
command: |
1262-
test/externalTests/<<parameters.project>>.py --solc-binary-type native --solc-binary-path /tmp/workspace/solc/solc
1292+
test/externalTests/<< parameters.project >>.sh native /tmp/workspace/solc/solc
12631293
- store_artifacts:
12641294
path: reports/externalTests/
12651295
# persist_to_workspace fails if the directory does not exist and the test script will create

test/externalTests/foundry.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,37 +61,15 @@ def __init__(self, config: TestConfig, setup_fn=None, compile_fn=None, test_fn=N
6161
# Note: the test_dir will be set on setup_environment
6262
self.test_dir: Path = None
6363

64-
def setup_environment(self, test_dir: Path, from_src: bool = False):
64+
def setup_environment(self, test_dir: Path):
6565
"""Configure the project build environment"""
6666

6767
self.test_dir = test_dir
6868
os.chdir(test_dir)
6969

7070
print("Configuring Foundry building environment...")
7171
if which("forge") is None:
72-
if not which("cargo"):
73-
raise RuntimeError("Cargo not found.")
74-
foundry_dir = test_dir / "foundry"
75-
foundry_bin_dir = foundry_dir / "bin"
76-
foundry_bin_dir.mkdir(parents=True, exist_ok=True)
77-
self.env.update({"FOUNDRY_DIR": foundry_dir.resolve()})
78-
if from_src:
79-
ExternalTest.download_project(foundry_dir, self.foundry_repo, "branch", "master")
80-
os.chdir(foundry_dir)
81-
run_cmd(f"cargo install --path {foundry_dir.resolve()}/cli --profile local --bins --locked --force")
82-
else :
83-
# Create the man directory required for the foundryup script
84-
foundry_man_dir = foundry_dir / "share/man/man1"
85-
foundry_man_dir.mkdir(parents=True, exist_ok=True)
86-
req = requests.get(self.foundryup_url, stream=True, verify=True, timeout=10)
87-
foundryup_bin = test_dir / "foundryup"
88-
with open(foundryup_bin, 'wb') as f:
89-
for chunk in req.iter_content(chunk_size=512):
90-
f.write(chunk)
91-
run_cmd(f"chmod +x {foundryup_bin.resolve()}")
92-
run_cmd(f"{foundryup_bin.resolve()}", self.env)
93-
if not any(path == foundry_bin_dir for path in self.env["PATH"].split(os.pathsep)):
94-
self.env["PATH"] += os.pathsep + str(foundry_bin_dir.resolve())
72+
raise RuntimeError("Forge not found.")
9573
if self.setup_fn:
9674
self.setup_fn(self.test_dir, self.env)
9775

0 commit comments

Comments
 (0)