Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Jul 11, 2024
2 parents ab3842c + ef62fdb commit 50b0958
Show file tree
Hide file tree
Showing 906 changed files with 80,336 additions and 100,150 deletions.
19 changes: 6 additions & 13 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
[alias]
cheats = "test -p foundry-cheatcodes --features schema tests::"
cheats = "test -p foundry-cheatcodes-spec --features schema tests::"
test-debugger = "test -p forge --test cli manual_debug_setup -- --include-ignored --nocapture"

# Increase the stack size to 10MB for Windows targets, which is in line with Linux
# (whereas default for Windows is 1MB).
[target.x86_64-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-C",
"link-arg=/STACK:10000000",
]
rustflags = ["-Clink-arg=/STACK:10000000"]

[target.i686-pc-windows-msvc]
rustflags = [
# Increases the stack size to 10MB, which is
# in line with Linux (whereas default for Windows is 1MB)
"-C",
"link-arg=/STACK:10000000",
]
rustflags = ["-Clink-arg=/STACK:10000000"]
11 changes: 11 additions & 0 deletions .config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[profile.default]
retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true }
slow-timeout = { period = "1m", terminate-after = 3 }

[[profile.default.overrides]]
filter = "test(/ext_integration|can_test_forge_std/)"
slow-timeout = { period = "5m", terminate-after = 4 }

[[profile.default.overrides]]
filter = "package(foundry-cheatcodes-spec)"
retries = 0
4 changes: 0 additions & 4 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
# auto-detection may fail for human-readable files, like the ones in abi/abi/*.sol
**/*.sol linguist-language=Solidity

crates/abi/src/bindings/*.rs linguist-generated
crates/cheatcodes/assets/*.json linguist-generated
testdata/cheats/Vm.sol linguist-generated
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* @danipopes @evalir @mattsse

crates/anvil/ @danipopes @mattsse @evalir
crates/cheatcodes/ @danipopes @mattsse @klkvr @evalir
crates/evm/coverage/ @onbjerg
crates/fmt/ @rkrasiuk
crates/linking/ @klkvr
crates/macros/ @danipopes
crates/script/ @danipopes @mattsse @klkvr
crates/wallets/ @klkvr
111 changes: 58 additions & 53 deletions .github/scripts/matrices.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,105 +4,109 @@
import os


# A runner target
class Target:
# GitHub runner OS
os_id: str
# GHA runner
runner_label: str
# Rust target triple
target: str
# SVM Solc target
svm_target_platform: str

def __init__(self, os_id: str, target: str):
self.os_id = os_id
def __init__(self, runner_label: str, target: str, svm_target_platform: str):
self.runner_label = runner_label
self.target = target
self.svm_target_platform = svm_target_platform


# A single test suite to run.
class Case:
# Name of the test suite.
name: str
# Nextest filter expression.
filter: str
# Number of partitions to split the test suite into.
n_partitions: int
xplatform: bool
# Whether to run on non-Linux platforms for PRs. All platforms and tests are run on pushes.
pr_cross_platform: bool

def __init__(self, name: str, filter: str, n_partitions: int, xplatform: bool):
def __init__(
self, name: str, filter: str, n_partitions: int, pr_cross_platform: bool
):
self.name = name
self.filter = filter
self.n_partitions = n_partitions
self.xplatform = xplatform
self.pr_cross_platform = pr_cross_platform


# GHA matrix entry
class Expanded:
os: str
target: str
name: str
runner_label: str
target: str
svm_target_platform: str
flags: str
partition: int

def __init__(self, os: str, target: str, name: str, flags: str, partition: int):
self.os = os
self.target = target
def __init__(
self,
name: str,
runner_label: str,
target: str,
svm_target_platform: str,
flags: str,
partition: int,
):
self.name = name
self.runner_label = runner_label
self.target = target
self.svm_target_platform = svm_target_platform
self.flags = flags
self.partition = partition


default_target = Target("ubuntu-latest", "x86_64-unknown-linux-gnu")
if os.environ.get("EVENT_NAME") == "pull_request":
targets = [default_target]
else:
targets = [
default_target,
Target("ubuntu-latest", "aarch64-unknown-linux-gnu"),
Target("macos-latest", "x86_64-apple-darwin"),
# Disabled since the test binary will be built for M1/M2, but there are no
# GitHub runners capable of executing those binaries.
# Target("macos-latest", "aarch64-apple-darwin"),
Target("windows-latest", "x86_64-pc-windows-msvc"),
]
profile = os.environ.get("PROFILE")
is_pr = os.environ.get("EVENT_NAME") == "pull_request"
t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64")
# TODO: Figure out how to make this work
# t_linux_arm = Target("ubuntu-latest", "aarch64-unknown-linux-gnu", "linux-aarch64")
t_macos = Target("macos-latest", "aarch64-apple-darwin", "macosx-aarch64")
t_windows = Target("windows-latest", "x86_64-pc-windows-msvc", "windows-amd64")
targets = [t_linux_x86, t_windows] if is_pr else [t_linux_x86, t_macos, t_windows]

config = [
Case(
name="unit",
filter="kind(lib) | kind(bench) | kind(proc-macro)",
filter="!kind(test)",
n_partitions=1,
xplatform=True,
pr_cross_platform=True,
),
Case(
name="integration",
filter="kind(test) & !test(/issue|forge_std|ext_integration/)",
n_partitions=3,
xplatform=True,
pr_cross_platform=True,
),
Case(
name="integration/issue-repros",
name="integration / issue-repros",
filter="package(=forge) & test(~issue)",
n_partitions=2,
xplatform=False,
),
Case(
name="integration/forge-std",
filter="package(=forge) & test(~forge_std)",
n_partitions=1,
xplatform=False,
pr_cross_platform=False,
),
Case(
name="integration/external",
name="integration / external",
filter="package(=forge) & test(~ext_integration)",
n_partitions=2,
xplatform=False,
pr_cross_platform=False,
),
]


def build_matrix():
expanded = []
for target in targets:
expanded.append({"os": target.os_id, "target": target.target})
print_json({"include": expanded})


def test_matrix():
def main():
expanded = []
for target in targets:
for case in config:
if not case.xplatform and target != default_target:
if is_pr and (not case.pr_cross_platform and target != t_linux_x86):
continue

for partition in range(1, case.n_partitions + 1):
Expand All @@ -116,12 +120,16 @@ def test_matrix():
s = f"{partition}/{case.n_partitions}"
name += f" ({s})"
flags += f" --partition count:{s}"

if profile == "isolate":
flags += " --features=isolate-by-default"
name += os_str

obj = Expanded(
os=target.os_id,
target=target.target,
name=name,
runner_label=target.runner_label,
target=target.target,
svm_target_platform=target.svm_target_platform,
flags=flags,
partition=partition,
)
Expand All @@ -135,7 +143,4 @@ def print_json(obj):


if __name__ == "__main__":
if int(os.environ.get("TEST", "0")) == 0:
build_matrix()
else:
test_matrix()
main()
43 changes: 36 additions & 7 deletions .github/scripts/prune-prereleases.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
// In case node 21 is not used.
function groupBy(array, keyOrIterator) {
var iterator;

// use the function passed in, or create one
if(typeof keyOrIterator !== 'function') {
const key = String(keyOrIterator);
iterator = function (item) { return item[key]; };
} else {
iterator = keyOrIterator;
}

return array.reduce(function (memo, item) {
const key = iterator(item);
memo[key] = memo[key] || [];
memo[key].push(item);
return memo;
}, {});
}

module.exports = async ({ github, context }) => {
console.log("Pruning old prereleases");

Expand All @@ -11,16 +31,25 @@ module.exports = async ({ github, context }) => {
release =>
// Only consider releases tagged `nightly-${SHA}` for deletion
release.tag_name.includes("nightly") &&
release.tag_name !== "nightly" &&
// ref: https://github.com/foundry-rs/foundry/issues/3881
// Skipping pruning the build on 1st day of each month
!release.created_at.includes("-01T")
release.tag_name !== "nightly"
);

// Keep newest 3 nightlies
nightlies = nightlies.slice(3);
// Pruning rules:
// 1. only keep the earliest (by created_at) release of the month
// 2. to keep the newest 30 nightlies (to make sure nightlies are kept until the next monthly release)
// Notes:
// - This addresses https://github.com/foundry-rs/foundry/issues/6732
// - Name of the release may deviate from created_at due to the usage of different timezones.

// Group releases by months.
// Per doc:
// > The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute.
const groups = groupBy(nightlies, i => i.created_at.slice(0, 7));
const nightliesToPrune = Object.values(groups)
.reduce((acc, cur) => acc.concat(cur.slice(0, -1)), []) // rule 1
.slice(30); // rule 2

for (const nightly of nightlies) {
for (const nightly of nightliesToPrune) {
console.log(`Deleting nightly: ${nightly.tag_name}`);
await github.rest.repos.deleteRelease({
owner: context.repo.owner,
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/bump-forge-std.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Daily CI job to update forge-std version used for tests if new release has been published

name: bump-forge-std

on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
update-tag:
name: update forge-std tag
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Fetch and update forge-std tag
run: curl 'https://api.github.com/repos/foundry-rs/forge-std/tags' | jq '.[0].commit.sha' -jr > testdata/forge-std-rev
- name: Create pull request
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: bump forge-std version used for tests"
title: "chore(tests): bump forge-std version"
body: |
New release of forge-std has been published, bump forge-std version used in tests. Likely some fixtures need to be updated.
branch: chore/bump-forge-std
38 changes: 19 additions & 19 deletions .github/workflows/deny.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
name: deny

on:
push:
branches: [master]
paths: [Cargo.lock, deny.toml]
pull_request:
branches: [master]
paths: [Cargo.lock, deny.toml]
push:
branches: [master]
paths: [Cargo.lock, deny.toml]
pull_request:
branches: [master]
paths: [Cargo.lock, deny.toml]

env:
CARGO_TERM_COLOR: always
CARGO_TERM_COLOR: always

jobs:
cargo-deny:
name: cargo deny check
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check all
# Clear out arguments to not pass `--all-features` to `cargo deny`.
# many crates have an `openssl` feature which enables banned dependencies
arguments: ""
cargo-deny:
name: cargo deny check
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1
with:
command: check all
# Clear out arguments to not pass `--all-features` to `cargo deny`.
# many crates have an `openssl` feature which enables banned dependencies
arguments: ""
Loading

0 comments on commit 50b0958

Please sign in to comment.