diff --git a/.github/INTEGRATION_FAILURE.md b/.github/INTEGRATION_FAILURE.md index afa055b18364e..bda129177f706 100644 --- a/.github/INTEGRATION_FAILURE.md +++ b/.github/INTEGRATION_FAILURE.md @@ -3,8 +3,8 @@ title: "bug: long-running integration tests failed" labels: P-high, T-bug --- -The heavy (long-running) integration tests have failed. This indicates a regression in foundry. +The heavy (long-running) integration tests have failed. This indicates a regression in Foundry. -Check the [heavy integration tests workflow page]({{env.WORKFLOW_URL}}) for details. +Check the [heavy integration tests workflow page]({{ env.WORKFLOW_URL }}) for details. -This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. \ No newline at end of file +This issue was raised by the workflow at `.github/workflows/heavy-integration.yml`. diff --git a/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md b/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md index eb33b48971ef4..2ff598cc1b371 100644 --- a/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md +++ b/.github/RELEASE_FAILURE_ISSUE_TEMPLATE.md @@ -5,6 +5,6 @@ labels: P-high, T-bug The release workflow has failed. Some or all binaries might have not been published correctly. -Check the [release workflow page]({{env.WORKFLOW_URL}}) for details. +Check the [release workflow page]({{ env.WORKFLOW_URL }}) for details. -This issue was raised by the workflow at `.github/workflows/release.yml`. \ No newline at end of file +This issue was raised by the workflow at `.github/workflows/release.yml`. diff --git a/.github/scripts/matrices.py b/.github/scripts/matrices.py new file mode 100644 index 0000000000000..19b7be5a8a17c --- /dev/null +++ b/.github/scripts/matrices.py @@ -0,0 +1,135 @@ +import json +import os + + +class Target: + # GitHub runner OS + os_id: str + # Rust target triple + target: str + + def __init__(self, os_id: str, target: str): + self.os_id = os_id + self.target = target + + +class Case: + name: str + filter: str + n_partitions: int + xplatform: bool + + def __init__(self, name: str, filter: str, n_partitions: int, xplatform: bool): + self.name = name + self.filter = filter + self.n_partitions = n_partitions + self.xplatform = xplatform + + +class Expanded: + os: str + target: str + name: str + flags: str + partition: int + + def __init__(self, os: str, target: str, name: str, flags: str, partition: int): + self.os = os + self.target = target + self.name = name + 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"), + Target("macos-latest", "aarch64-apple-darwin"), + Target("windows-latest", "x86_64-pc-windows-msvc"), + ] + +config = [ + Case( + name="unit", + filter="kind(lib) | kind(bench) | kind(proc-macro)", + n_partitions=1, + xplatform=True, + ), + Case( + name="integration", + filter="kind(test) & !test(/issue|forge_std|ext_integration/)", + n_partitions=3, + xplatform=True, + ), + Case( + 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, + ), + Case( + name="integration/external", + filter="package(=forge) & test(~ext_integration)", + n_partitions=2, + xplatform=False, + ), +] + + +def build_matrix(): + os_ids = [] + targets_ = [] + for target in targets: + os_ids.append(target.os_id) + targets_.append(target.target) + print(json.dumps({"os": os_ids, "target": targets_})) + + +def test_matrix(): + expanded = [] + for target in targets: + for case in config: + if not case.xplatform and target != default_target: + continue + + for partition in range(1, case.n_partitions + 1): + os_str = "" + if len(targets) > 1: + os_str = f" ({target.target})" + + name = case.name + flags = f"-E '{case.filter}'" + if case.n_partitions > 1: + s = f"{partition}/{case.n_partitions}" + name += f" ({s})" + flags += f" --partition count:{s}" + name += os_str + + obj = Expanded( + os=target.os_id, + target=target.target, + name=name, + flags=flags, + partition=partition, + ) + expanded.append(vars(obj)) + + print(json.dumps({"include": expanded}), end="", flush=True) + + +if __name__ == "__main__": + if int(os.environ.get("TEST", "0")) == 0: + build_matrix() + else: + test_matrix() diff --git a/.github/workflows/cross-platform.yml b/.github/workflows/cross-platform.yml deleted file mode 100644 index bd9e19fc21db3..0000000000000 --- a/.github/workflows/cross-platform.yml +++ /dev/null @@ -1,206 +0,0 @@ -on: - workflow_dispatch: - workflow_call: - -name: cross-platform - -env: - CARGO_TERM_COLOR: always - -jobs: - build-tests: - name: building ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }} - runs-on: ${{ matrix.job.os }} - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - flags: --workspace --all-features --lib --bins - - name: integration-tests - file: nextest-integration.tar.zst - flags: --workspace - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - wsl: wsl - - os: windows-latest - target: x86_64-pc-windows-msvc - - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - uses: Swatinem/rust-cache@v2 - - name: Install nextest - uses: taiki-e/install-action@nextest - - # Required for forge commands that use git - - name: Setup git - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: Apple M1 setup - if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} - run: | - echo "SDKROOT=$(xcrun -sdk macosx --show-sdk-path)" >> $GITHUB_ENV - echo "MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx --show-sdk-platform-version)" >> $GITHUB_ENV - - - name: Linux ARM setup - if: ${{ matrix.job.target == 'aarch64-unknown-linux-gnu' }} - run: | - sudo apt-get update -y - sudo apt-get install -y gcc-aarch64-linux-gnu - echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV - - # For some reason the FFI cheatcode uses WSL bash instead of Git bash, so we need to install a WSL distribution - - name: Windows setup - if: ${{ matrix.job.wsl == 'wsl' }} - uses: Vampire/setup-wsl@v1 - with: - distribution: Ubuntu-20.04 - set-as-default: true - - - name: Build archive (unit tests) - run: | - cargo nextest archive --locked ${{ matrix.job.flags }} --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - path: ${{ matrix.job.target }}-${{ matrix.archive.file }} - - unit: - name: unit tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ matrix.archive.name }} / ${{ matrix.nextest.name }} - runs-on: ${{ matrix.job.os }} - needs: build-tests - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - nextest: - - name: non-forking - filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_and_simulate)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}' - - integration: - name: - integration tests ${{ matrix.job.target }} (${{ matrix.job.os }}) / ${{ - matrix.archive.name }} / ${{ matrix.nextest.name }} - runs-on: ${{ matrix.job.os }} - timeout-minutes: 60 - needs: build-tests - strategy: - fail-fast: false - matrix: - archive: - - name: integration-tests - file: nextest-integration.tar.zst - job: - # The OS is used for the runner - # The target is used by Cargo - - os: ubuntu-latest - target: x86_64-unknown-linux-gnu - - os: ubuntu-latest - target: aarch64-unknown-linux-gnu - - os: macos-latest - target: x86_64-apple-darwin - - os: macos-latest - target: aarch64-apple-darwin - - os: windows-latest - target: x86_64-pc-windows-msvc - nextest: - - name: non-forking - # skip fork,verify,forge-std and script tests that use heavy simulation - filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_and_simulate)" - # the aarch64-apple-darwin runner is particularly slow with script related tests - macos-aarch-filter: "!test(~fork) & !test(~live) & !test(~forge_std) & !test(~deploy_)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: ${{ matrix.job.target }}-${{ matrix.archive.name }} - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.nextest.name != 'non-forking' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - if: ${{ matrix.job.target == 'aarch64-apple-darwin' }} - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.macos-aarch-filter }}' - - - name: cargo nextest - if: ${{ matrix.job.target != 'aarch64-apple-darwin' }} - shell: bash - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file ${{ matrix.job.target }}-${{ matrix.archive.file }} -E '${{ matrix.nextest.filter }}' diff --git a/.github/workflows/deny.yml b/.github/workflows/deny.yml index 9fac75ef56019..af8f4901ed5ed 100644 --- a/.github/workflows/deny.yml +++ b/.github/workflows/deny.yml @@ -15,6 +15,7 @@ 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 diff --git a/.github/workflows/dependencies.yml b/.github/workflows/dependencies.yml index e731a7a56923f..531480b8232b1 100644 --- a/.github/workflows/dependencies.yml +++ b/.github/workflows/dependencies.yml @@ -3,59 +3,62 @@ name: Update Dependencies on: - schedule: - # Run weekly - - cron: "0 0 * * SUN" - workflow_dispatch: - # Needed so we can run it manually + schedule: + # Run weekly + - cron: "0 0 * * SUN" + workflow_dispatch: + # Needed so we can run it manually env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - BRANCH: cargo-update - TITLE: "chore(deps): weekly `cargo update`" - BODY: | - Automation to keep dependencies in `Cargo.lock` current. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BRANCH: cargo-update + TITLE: "chore(deps): weekly `cargo update`" + BODY: | + Automation to keep dependencies in `Cargo.lock` current. -
cargo update log -

+

cargo update log +

- ```log - $cargo_update_log - ``` + ```log + $cargo_update_log + ``` -

-
+

+
jobs: - update: - name: Update - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly - - - name: cargo update - # Remove first line that always just says "Updating crates.io index" - run: cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a cargo_update.log - - - name: craft commit message and PR body - id: msg - run: | - export cargo_update_log="$(cat cargo_update.log)" - - echo "commit_message<> $GITHUB_OUTPUT - printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - echo "body<> $GITHUB_OUTPUT - echo "$BODY" | envsubst >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT - - - name: Create Pull Request - uses: peter-evans/create-pull-request@v5 - with: - add-paths: ./Cargo.lock - commit-message: ${{ steps.msg.outputs.commit_message }} - title: ${{ env.TITLE }} - body: ${{ steps.msg.outputs.body }} - branch: ${{ env.BRANCH }} + update: + name: Update + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly + + - name: cargo update + # Remove first line that always just says "Updating crates.io index" + run: + cargo update --color never 2>&1 | sed '/crates.io index/d' | tee -a + cargo_update.log + + - name: craft commit message and PR body + id: msg + run: | + export cargo_update_log="$(cat cargo_update.log)" + + echo "commit_message<> $GITHUB_OUTPUT + printf "$TITLE\n\n$cargo_update_log\n" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + echo "body<> $GITHUB_OUTPUT + echo "$BODY" | envsubst >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v5 + with: + add-paths: ./Cargo.lock + commit-message: ${{ steps.msg.outputs.commit_message }} + title: ${{ env.TITLE }} + body: ${{ steps.msg.outputs.body }} + branch: ${{ env.BRANCH }} diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index ae4382f3e6a91..4f52a545d5a7c 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,7 +23,7 @@ jobs: id-token: write packages: write contents: read - timeout-minutes: 60 + timeout-minutes: 30 steps: - name: Checkout repository diff --git a/.github/workflows/heavy-integration.yml b/.github/workflows/heavy-integration.yml index 1c9b8c914e8cc..db45353eb85da 100644 --- a/.github/workflows/heavy-integration.yml +++ b/.github/workflows/heavy-integration.yml @@ -10,94 +10,34 @@ env: CARGO_TERM_COLOR: always jobs: - build-tests: - name: build tests / ${{ matrix.archive.name }} - runs-on: ubuntu-latest - strategy: - matrix: - archive: - - name: heavy-integration-tests - file: heavy-integration.tar.zst - flags: -p forge --features heavy-integration-tests - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@nextest - - name: Build archive (long-running tests) - run: | - cargo nextest archive \ - --locked \ - --archive-file ${{ matrix.archive.file }} \ - ${{ matrix.archive.flags }} - - name: Upload archive - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.archive.name }} - path: ${{ matrix.archive.file }} - - install-svm-solc: - name: install svm and solidity / ${{ matrix.job.name }} - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Install svm - run: cargo install svm-rs - - name: Install Solidity 0.8.19 - run: svm install 0.8.19 - - name: Install Solidity 0.8.20 - run: svm install 0.8.20 - - name: Use Solidity 0.8.19 - run: svm use 0.8.19 - heavy-integration: - name: heavy (long-running) integration tests / ${{ matrix.job.name }} + name: heavy (long-running) integration tests runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: Long-running integration tests - filter: "!test(~live) & test(heavy)" env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: heavy-integration-tests - + - uses: taiki-e/install-action@nextest + - uses: Swatinem/rust-cache@v2 - name: Forge RPC cache uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' with: - path: "$HOME/.foundry/cache" + path: | + ~/.foundry/cache + ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: cargo nextest + - name: test run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file heavy-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest run -r -p forge --test cli --features heavy-integration-tests --retries 1 -E 'test(~heavy_integration)' - # If any of the steps fail, this will create a high-priority issue - # to signal so. + # If any of the steps fail, this will create a high-priority issue to signal so. - uses: JasonEtco/create-an-issue@v2 if: ${{ failure() }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + WORKFLOW_URL: | + ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} with: update_existing: true filename: .github/INTEGRATION_FAILURE.md diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml index f1dfd2727bb5f..9d450c2b757d2 100644 --- a/.github/workflows/project.yml +++ b/.github/workflows/project.yml @@ -7,7 +7,7 @@ jobs: add-to-project: name: add issue runs-on: ubuntu-latest - timeout-minutes: 60 + timeout-minutes: 30 steps: - uses: actions/add-to-project@main with: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bb89338c160f2..e877f25407364 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,237 +10,99 @@ env: CARGO_TERM_COLOR: always jobs: - build-tests: - name: build tests / ${{ matrix.archive.name }} + matrices: + name: build matrices runs-on: ubuntu-latest - strategy: - matrix: - archive: - - name: unit-tests - file: nextest-unit.tar.zst - flags: --workspace --all-features --lib --bins - - name: integration-tests - file: nextest-integration.tar.zst - flags: --workspace - - name: external-integration-tests - file: nextest-external-integration.tar.zst - flags: -p forge --features external-integration-tests + outputs: + build-matrix: ${{ steps.gen.outputs.build-matrix }} + test-matrix: ${{ steps.gen.outputs.test-matrix }} steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: Swatinem/rust-cache@v2 - - uses: taiki-e/install-action@nextest - - name: Build archive (unit tests) - run: | - cargo nextest archive \ - --locked \ - --archive-file ${{ matrix.archive.file }} \ - ${{ matrix.archive.flags }} - - name: Upload archive - uses: actions/upload-artifact@v3 + - uses: actions/setup-python@v4 with: - name: ${{ matrix.archive.name }} - path: ${{ matrix.archive.file }} - - install-svm-solc: - name: install svm and solidity / ${{ matrix.job.name }} - runs-on: ubuntu-latest - timeout-minutes: 30 - steps: - - name: Install svm - run: cargo install svm-rs - - name: Install Solidity 0.8.19 - run: svm install 0.8.19 - - name: Install Solidity 0.8.20 - run: svm install 0.8.20 - - name: Use Solidity 0.8.19 - run: svm use 0.8.19 - - unit: - name: unit tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests - timeout-minutes: 60 - strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork) & !test(~live)" - - name: forking - filter: "test(~fork) & !test(~live)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: unit-tests - - name: cargo nextest + python-version: "3.11" + - name: Generate matrices + id: gen + env: + EVENT_NAME: ${{ github.event_name }} run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-unit.tar.zst -E '${{ matrix.job.filter }}' + output=$(python3 .github/scripts/matrices.py) + echo "::debug::build-matrix=$output" + echo "build-matrix=$output" >> "$GITHUB_OUTPUT" - issue-repros-tests: - name: issue reproduction tests / ${{ matrix.job.name }} / ${{ matrix.job.partition }} - runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: issue-repros - filter: "test(~issue)" - partition: [1, 2] - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@stable - - uses: taiki-e/install-action@nextest - - name: Download archives - uses: actions/download-artifact@v3 - with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'issue-repros' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" + export TEST=1 - - name: cargo nextest - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --partition count:${{ matrix.partition }}/2 --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' + output=$(python3 .github/scripts/matrices.py) + echo "::debug::test-matrix=$output" + echo "test-matrix=$output" >> "$GITHUB_OUTPUT" - forge-std-tests: - name: forge std tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests + build-tests: + name: build tests + runs-on: ${{ matrix.os }} + timeout-minutes: 30 + needs: matrices strategy: - matrix: - job: - - name: forge-std-test - filter: "test(~forge_std)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.build-matrix) }} steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'forge-std-test' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest + target: ${{ matrix.target }} + - uses: Swatinem/rust-cache@v2 + - uses: taiki-e/install-action@nextest + - name: Build archive run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest archive \ + --workspace \ + --archive-file tests-${{ matrix.target }}.tar.zst + - name: Upload archive + uses: actions/upload-artifact@v3 + with: + name: tests-${{ matrix.target }} + path: tests-${{ matrix.target }}.tar.zst - integration: - name: integration tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests + test: + name: test ${{ matrix.name }} + runs-on: ${{ matrix.os }} + timeout-minutes: 60 + needs: + - matrices + - build-tests strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork) & !test(~live) & !test(~issue) & !test(~forge_std)" - - name: forking - filter: "test(~fork) & !test(~live)" - partition: [1, 2] + fail-fast: false + matrix: ${{ fromJson(needs.matrices.outputs.test-matrix) }} env: ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD steps: - uses: actions/checkout@v3 - - uses: taiki-e/install-action@nextest - uses: dtolnay/rust-toolchain@stable - - name: Download archives - uses: actions/download-artifact@v3 with: - name: integration-tests - - - name: Forge RPC cache - uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' - with: - path: "$HOME/.foundry/cache" - key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config - run: | - git config --global user.name "GitHub Actions Bot" - git config --global user.email "<>" - - - name: cargo nextest - run: | - # see https://github.com/foundry-rs/foundry/pull/3959 - export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --partition count:${{ matrix.partition }}/2 --retries 3 --archive-file nextest-integration.tar.zst -E '${{ matrix.job.filter }}' - - external-integration: - name: external integration tests / ${{ matrix.job.name }} - runs-on: ubuntu-latest - needs: build-tests - strategy: - matrix: - job: - - name: non-forking - filter: "!test(~fork_integration) & !test(~live)" - - name: forking - filter: "test(~fork_integration) & !test(~live)" - env: - ETH_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/C3JEvfW6VgtqZQa-Qp1E-2srEiIc02sD - steps: - - uses: actions/checkout@v3 + target: ${{ matrix.target }} - uses: taiki-e/install-action@nextest - - uses: dtolnay/rust-toolchain@stable - - name: Download archives + - name: Download archive uses: actions/download-artifact@v3 with: - name: external-integration-tests - + name: tests-${{ matrix.target }} - name: Forge RPC cache uses: actions/cache@v3 - if: matrix.job.name != 'non-forking' with: - path: "$HOME/.foundry/cache" + path: | + ~/.foundry/cache + ~/.config/.foundry/cache key: rpc-cache-${{ hashFiles('crates/forge/tests/rpc-cache-keyfile') }} - - name: Setup git config run: | git config --global user.name "GitHub Actions Bot" git config --global user.email "<>" - - - name: Force use of HTTPS for submodules - run: git config --global url."https://github.com/".insteadOf "git@github.com:" - - - name: cargo nextest + - name: Test run: | # see https://github.com/foundry-rs/foundry/pull/3959 export LD_LIBRARY_PATH="$(rustc --print sysroot)/lib" - cargo nextest run --retries 3 --archive-file nextest-external-integration.tar.zst -E '${{ matrix.job.filter }}' + cargo nextest run \ + --retries 2 \ + --archive-file tests-${{ matrix.target }}.tar.zst \ + ${{ matrix.flags }} doctests: name: doc tests @@ -251,13 +113,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: cargo test - run: cargo test --locked --workspace --all-features --doc - - cross-platform: - name: Cross-platform tests - if: github.event_name != 'pull_request' - needs: [unit, integration, doctests] - uses: ./.github/workflows/cross-platform.yml + run: cargo test --doc clippy: name: clippy diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index c7e48e46bd8b3..4ee9e0805ecc1 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -79,9 +79,6 @@ default = ["rustls"] rustls = ["foundry-cli/rustls", "reqwest/rustls-tls", "reqwest/rustls-tls-native-roots"] openssl = ["foundry-cli/openssl", "reqwest/default-tls"] -# feature for integration tests that test external projects -external-integration-tests = [] - # feature for heavy (long-running) integration tests heavy-integration-tests = [] diff --git a/crates/forge/tests/cli/ext_integration.rs b/crates/forge/tests/cli/ext_integration.rs new file mode 100644 index 0000000000000..08edac73ec614 --- /dev/null +++ b/crates/forge/tests/cli/ext_integration.rs @@ -0,0 +1,27 @@ +use foundry_test_utils::forgetest_external; + +forgetest_external!(solmate, "transmissions11/solmate"); +forgetest_external!(prb_math, "PaulRBerg/prb-math"); +forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); +forgetest_external!(solady, "Vectorized/solady"); +forgetest_external!( + geb, + "reflexer-labs/geb", + &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] +); +forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); +forgetest_external!(lootloose, "gakonst/lootloose"); +forgetest_external!(lil_web3, "m1guelpf/lil-web3"); + +// Forking tests + +forgetest_external!(multicall, "makerdao/multicall", &["--block-number", "1"]); +forgetest_external!( + drai, + "mds1/drai", + 13633752, + &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] +); +forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); +forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); +forgetest_external!(sparklend, "marsfoundation/sparklend"); diff --git a/crates/forge/tests/cli/heavy_integration.rs b/crates/forge/tests/cli/heavy_integration.rs index 200fe0fc6d8fa..7363b0ca4ef68 100644 --- a/crates/forge/tests/cli/heavy_integration.rs +++ b/crates/forge/tests/cli/heavy_integration.rs @@ -1,6 +1,5 @@ //! Heavy integration tests that can take an hour to run or more. -//! All tests are prefixed with heavy so they can be filtered by nextest. use foundry_test_utils::forgetest_external; -forgetest_external!(heavy_maple, "maple-labs/maple-core-v2"); +forgetest_external!(maple, "maple-labs/maple-core-v2"); diff --git a/crates/forge/tests/cli/integration.rs b/crates/forge/tests/cli/integration.rs deleted file mode 100644 index a32bd95e22a4d..0000000000000 --- a/crates/forge/tests/cli/integration.rs +++ /dev/null @@ -1,37 +0,0 @@ -use foundry_test_utils::{forgetest_external, util::setup_forge_remote}; - -forgetest_external!(solmate, "transmissions11/solmate"); -forgetest_external!(prb_math, "PaulRBerg/prb-math"); -forgetest_external!(prb_proxy, "PaulRBerg/prb-proxy"); -forgetest_external!(solady, "Vectorized/solady"); -forgetest_external!( - geb, - "reflexer-labs/geb", - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] -); -forgetest_external!(stringutils, "Arachnid/solidity-stringutils"); -forgetest_external!(lootloose, "gakonst/lootloose"); -forgetest_external!(lil_web3, "m1guelpf/lil-web3"); - -/// clone + build in one step -#[test] -#[ignore] -fn can_checkout_build() { - let (_prj, _cmd) = setup_forge_remote("transmissions11/solmate"); -} - -/// Forking tests -mod fork_integration { - use foundry_test_utils::forgetest_external; - - forgetest_external!(multicall, "makerdao/multicall", &["--block-number", "1"]); - forgetest_external!( - drai, - "mds1/drai", - 13633752, - &["--chain-id", "99", "--sender", "0x00a329c0648769A73afAc7F9381E08FB43dBEA72"] - ); - forgetest_external!(gunilev, "hexonaut/guni-lev", 13633752); - forgetest_external!(convex, "mds1/convex-shutdown-simulation", 14445961); - forgetest_external!(sparklend, "marsfoundation/sparklend"); -} diff --git a/crates/forge/tests/cli/main.rs b/crates/forge/tests/cli/main.rs index 1892172dabecf..0a05fe038be88 100644 --- a/crates/forge/tests/cli/main.rs +++ b/crates/forge/tests/cli/main.rs @@ -1,29 +1,18 @@ -#[cfg(not(feature = "external-integration-tests"))] +pub mod constants; +pub mod utils; + mod cache; -#[cfg(not(feature = "external-integration-tests"))] mod cmd; -#[cfg(not(feature = "external-integration-tests"))] mod config; -#[cfg(not(feature = "external-integration-tests"))] mod create; -#[cfg(not(feature = "external-integration-tests"))] mod doc; -#[cfg(not(feature = "external-integration-tests"))] mod multi_script; -#[cfg(not(feature = "external-integration-tests"))] mod script; mod svm; -#[cfg(not(feature = "external-integration-tests"))] mod test_cmd; -#[cfg(not(feature = "external-integration-tests"))] -mod utils; -#[cfg(not(feature = "external-integration-tests"))] mod verify; -#[cfg(feature = "external-integration-tests")] -mod integration; +mod ext_integration; #[cfg(feature = "heavy-integration-tests")] mod heavy_integration; - -pub mod constants; diff --git a/crates/forge/tests/cli/svm.rs b/crates/forge/tests/cli/svm.rs index be761193d4954..5635098edf53e 100644 --- a/crates/forge/tests/cli/svm.rs +++ b/crates/forge/tests/cli/svm.rs @@ -2,7 +2,7 @@ use foundry_test_utils::{forgetest_init, TestCommand, TestProject}; use semver::Version; -use svm::{self, Platform}; +use svm::Platform; /// The latest solc release /// @@ -14,14 +14,12 @@ use svm::{self, Platform}; const LATEST_SOLC: Version = Version::new(0, 8, 21); macro_rules! ensure_svm_releases { - ($($test:ident => $platform:ident),*) => { - $( + ($($test:ident => $platform:ident),* $(,)?) => {$( #[tokio::test(flavor = "multi_thread")] async fn $test() { ensure_latest_release(Platform::$platform).await } - )* - }; + )*}; } async fn ensure_latest_release(platform: Platform) { @@ -30,7 +28,7 @@ async fn ensure_latest_release(platform: Platform) { .unwrap_or_else(|err| panic!("Could not fetch releases for {platform}: {err:?}")); assert!( releases.releases.contains_key(&LATEST_SOLC), - "platform {platform:?} is missing solc info {LATEST_SOLC}" + "platform {platform:?} is missing solc info for v{LATEST_SOLC}" ); } @@ -45,26 +43,20 @@ ensure_svm_releases!( // Ensures we can always test with the latest solc build forgetest_init!(can_test_with_latest_solc, |prj: TestProject, mut cmd: TestCommand| { - prj.inner() - .add_test( - "Counter", - r#" + let src = format!( + r#" // SPDX-License-Identifier: UNLICENSED -pragma solidity =; +pragma solidity ={LATEST_SOLC}; import "forge-std/Test.sol"; -contract CounterTest is Test { - - function testAssert() public { - assert(true); - } -} - "# - .replace("", &LATEST_SOLC.to_string()), - ) - .unwrap(); - - cmd.args(["test"]); - cmd.stdout().contains("[PASS]") +contract CounterTest is Test {{ + function testAssert() public {{ + assert(true); + }} +}} + "# + ); + prj.inner().add_test("Counter", src).unwrap(); + cmd.arg("test").stdout().contains("[PASS]") }); diff --git a/crates/forge/tests/it/repros.rs b/crates/forge/tests/it/repros.rs index 54cd9e4f84a64..1fc8522d407b0 100644 --- a/crates/forge/tests/it/repros.rs +++ b/crates/forge/tests/it/repros.rs @@ -286,6 +286,6 @@ async fn test_issue_5038() { // #[tokio::test(flavor = "multi_thread")] -async fn test_issue3792() { +async fn test_issue_3792() { test_repro!("Issue3792"); }