diff --git a/.dockerignore b/.dockerignore index c340af7ad..8e083c0e6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,3 @@ target -fendermint/builtin-actors contracts/cache contracts/node-modules diff --git a/.github/workflows/add-bug-tracker.yaml b/.github/workflows/add-bug-tracker.yaml deleted file mode 100644 index bd4a83200..000000000 --- a/.github/workflows/add-bug-tracker.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Add bugs to tracker - -on: - issues: - types: - - opened - - labeled - -jobs: - add-to-project: - name: Add issue to tracker - runs-on: ubuntu-latest - steps: - - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/consensus-shipyard/projects/3 - github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} - labeled: bug \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 000000000..4d280f758 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,128 @@ +name: Build IPC + +# This workflow is triggered from the main CI workflow. +on: + workflow_call: + +jobs: + build: + name: Build IPC + runs-on: ubuntu-latest + env: + RUST_BACKTRACE: full + RUSTFLAGS: -Dwarnings + + steps: + # https://github.com/marketplace/actions/free-disk-space-ubuntu + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + large-packages: false + swap-storage: false + docker-images: false + android: true + dotnet: true + haskell: true + + - name: Check out the project + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Tools + uses: ./.github/actions/install-tools + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + rust: stable + + - name: Install Node.js + uses: actions/setup-node@v2 + with: + node-version: 18.19.0 + + - uses: Swatinem/rust-cache@v2 + if: always() + with: + cache-on-failure: true + + - name: Cache Solidity ABI artifacts + uses: actions/cache@v4 + if: always() + with: + path: | + ./contracts/out + ./contracts/bindings + ./contracts/cache + ## TODO maybe add the rust version and solc version to the key + key: v2-contracts-abi-${{ hashFiles('./contracts/**/*.sol') }} + + - name: Generate ABI and bindings + run: cd contracts && make gen + + - name: Install Rust nightly + uses: dtolnay/rust-toolchain@master + with: + toolchain: nightly + components: rustfmt,clippy + + - name: Check fmt (fmt, clippy) + run: cargo +nightly fmt --check --all + + - name: Check clippy + run: cargo clippy --tests --no-deps -- -D clippy::all + + - name: Build all + run: | + cd fendermint && make $PWD/builtin-actors/output/bundle.car + cargo build --locked --release + + - name: Build Docker image for e2e tests + run: | + ## Create the temporary Dockerfile. + cat < /tmp/Dockerfile + # syntax=docker/dockerfile:1 + FROM alpine as builder + COPY /fendermint/app/config /app/fendermint/app/config + COPY /target/release/fendermint /app/output/bin/fendermint + COPY /target/release/ipc-cli /app/output/bin/ipc-cli + EOF + + ## Append the runner build phase to the Dockerfile. + cat fendermint/docker/runner.Dockerfile >> /tmp/Dockerfile + + ## Print the Dockerfile for debugging. + echo "Dockerfile:" + cat /tmp/Dockerfile + + ## Create the temporary .dockerignore file. + cat < /tmp/Dockerfile.dockerignore + target + !target/release/fendermint + !target/release/ipc-cli + contracts/cache + contracts/node-modules + EOF + + ## Print the .dockerignore file for debugging. + echo "Dockerfile.dockerignore:" + cat /tmp/Dockerfile.dockerignore + + ## Build the Docker image. + DOCKER_BUILDKIT=1 docker build \ + --load \ + -f /tmp/Dockerfile \ + -t fendermint:latest \ + . + + - name: Create artifacts directory + run: mkdir -p /tmp/artifacts + + - name: Export Docker image + run: docker save fendermint:latest > /tmp/artifacts/docker-image.tar + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: docker-image + path: /tmp/artifacts/docker-image.tar diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f5a2263ed..770857fcb 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -23,53 +23,16 @@ on: jobs: - # JOB to run change detection - changes: - runs-on: ubuntu-latest - # Required permissions - permissions: - pull-requests: read - # Set job outputs to values from filter step - outputs: - workspace: ${{ steps.filter.outputs.workspace }} - contracts: ${{ steps.filter.outputs.contracts }} - ipc: ${{ steps.filter.outputs.ipc }} - ipld-resolver: ${{ steps.filter.outputs.ipld-resolver }} - fendermint: ${{ steps.filter.outputs.fendermint }} - steps: - # For pull requests it's not necessary to checkout the code, - # but the workflow is also triggered on pushes to `main`. - - uses: actions/checkout@v3 - - - uses: dorny/paths-filter@v2 - id: filter - with: - filters: | - workspace: - - 'Cargo.toml' - contracts: - - 'contracts/**' - ipc: - - 'ipc/**' - ipld-resolver: - - 'ipld/resolver/**' - fendermint: - - 'fendermint/**' license: uses: ./.github/workflows/license.yaml contracts-prettier: uses: ./.github/workflows/contracts-prettier.yaml - needs: [changes] - if: >- - needs.changes.outputs.contracts == 'true' || - github.ref == 'refs/heads/main' || - github.ref_type == 'tag' contracts-deployment-test: uses: ./.github/workflows/contracts-deployment-test.yaml - needs: [ contracts-prettier ] + needs: [contracts-prettier] contracts-test: uses: ./.github/workflows/contracts-test.yaml @@ -79,9 +42,12 @@ jobs: uses: ./.github/workflows/contracts-storage.yaml needs: [contracts-prettier] - contracts-pnpm-audit: - uses: ./.github/workflows/contracts-pnpm-audit.yaml - needs: [contracts-prettier] +## This causes too much unpredictable noise, turning our builds red whenever a new vulnerability is found. +## It's better to have a separate workflow for auditing, and have it run on a schedule. +## However, given this code is purely used for tooling and not for production, it's not a big deal. +# contracts-pnpm-audit: +# uses: ./.github/workflows/contracts-pnpm-audit.yaml +# needs: [contracts-prettier] contracts-sast: uses: ./.github/workflows/contracts-sast.yaml @@ -91,53 +57,33 @@ jobs: uses: ./.github/workflows/extras.yaml needs: [contracts-prettier] - ipc: - uses: ./.github/workflows/ipc.yaml - needs: [changes, license] - if: >- - needs.changes.outputs.workspace == 'true' || - needs.changes.outputs.contracts == 'true' || - needs.changes.outputs.ipc == 'true' || - github.ref == 'refs/heads/main' || - github.ref_type == 'tag' + build: + uses: ./.github/workflows/build.yaml + needs: [license] - ipld-resolver: - uses: ./.github/workflows/ipld-resolver.yaml - needs: [changes, license] - if: >- - needs.changes.outputs.workspace == 'true' || - needs.changes.outputs.ipld-resolver == 'true' || - github.ref == 'refs/heads/main' || - github.ref_type == 'tag' + unit-tests: + uses: ./.github/workflows/tests-unit.yaml + secrets: inherit + needs: + - build - fendermint-test: - uses: ./.github/workflows/fendermint-test.yaml + e2e-tests: + uses: ./.github/workflows/tests-e2e.yaml secrets: inherit - needs: [changes, license] - if: >- - needs.changes.outputs.workspace == 'true' || - needs.changes.outputs.contracts == 'true' || - needs.changes.outputs.ipc == 'true' || - needs.changes.outputs.ipld-resolver == 'true' || - needs.changes.outputs.fendermint == 'true' || - github.ref == 'refs/heads/main' || - github.ref_type == 'tag' + needs: + - build fevm-contract-tests: uses: ./.github/workflows/fevm-contract-tests.yaml secrets: inherit - needs: [changes, license] + needs: + - build if: >- - needs.changes.outputs.workspace == 'true' || - needs.changes.outputs.contracts == 'true' || - needs.changes.outputs.ipc == 'true' || - needs.changes.outputs.ipld-resolver == 'true' || - needs.changes.outputs.fendermint == 'true' || github.ref == 'refs/heads/main' || github.ref_type == 'tag' - fendermint-publish: - uses: ./.github/workflows/fendermint-publish.yaml + docker-publish: + uses: ./.github/workflows/docker-publish.yaml secrets: inherit # Dependencies are not strictly necessary, but if fendermint tests pass they publish docker too, so they better work. # It is because of these needs that all the filters are allowed to run on `main` too, otherwise this would be disabled. @@ -148,6 +94,6 @@ jobs: github.ref_type == 'tag' needs: - contracts-test # generates the ABI artifacts (although fendermint can do on its own too) - - ipc - - ipld-resolver - - fendermint-test + - build + - unit-tests + - e2e-tests diff --git a/.github/workflows/contracts-deployment-test.yaml b/.github/workflows/contracts-deployment-test.yaml index ae4c8a2c1..7d7de2147 100644 --- a/.github/workflows/contracts-deployment-test.yaml +++ b/.github/workflows/contracts-deployment-test.yaml @@ -1,4 +1,4 @@ -name: Deployment Test +name: 'Contracts: Smoke test deployment' # This workflow is triggered from the main CI workflow. on: diff --git a/.github/workflows/contracts-pnpm-audit.yaml b/.github/workflows/contracts-pnpm-audit.yaml index 4f9913a01..7bcff9b82 100644 --- a/.github/workflows/contracts-pnpm-audit.yaml +++ b/.github/workflows/contracts-pnpm-audit.yaml @@ -1,4 +1,4 @@ -name: NPM Audit +name: 'Contracts: pnpm audit' # This workflow is triggered from the main CI workflow. on: diff --git a/.github/workflows/contracts-prettier.yaml b/.github/workflows/contracts-prettier.yaml index 6df464a23..125a28264 100644 --- a/.github/workflows/contracts-prettier.yaml +++ b/.github/workflows/contracts-prettier.yaml @@ -1,5 +1,5 @@ -# .github/workflows/prettier.yml -name: Prettier + +name: 'Contracts: Prettier' # This workflow is triggered from the main CI workflow. on: @@ -8,30 +8,23 @@ on: jobs: prettier: runs-on: ubuntu-latest - permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # added or changed files to the repository. - contents: write steps: - - uses: actions/checkout@v4 - with: - ref: ${{ github.ref }} + - name: Checkout + uses: actions/checkout@v4 + - uses: pnpm/action-setup@v2 + - name: Set up node.js uses: actions/setup-node@v4 with: node-version: '21' cache: 'pnpm' + - name: Run formatter run: cd contracts && make fmt + - name: Check diff clean run: | git status git diff --name-only git --no-pager diff --quiet - -# - name: Commit changes -# uses: stefanzweifel/git-auto-commit-action@v5 -# with: -# commit_message: Apply Prettier formatting -# branch: ${{ github.head_ref }} diff --git a/.github/workflows/contracts-sast.yaml b/.github/workflows/contracts-sast.yaml index 3141eda45..1b820bec9 100644 --- a/.github/workflows/contracts-sast.yaml +++ b/.github/workflows/contracts-sast.yaml @@ -1,4 +1,4 @@ -name: Static analysis +name: 'Contracts: Static analysis' # This workflow is triggered from the main CI workflow. on: diff --git a/.github/workflows/contracts-storage.yaml b/.github/workflows/contracts-storage.yaml index e9dbde508..0bb6ce935 100644 --- a/.github/workflows/contracts-storage.yaml +++ b/.github/workflows/contracts-storage.yaml @@ -1,4 +1,4 @@ -name: Storage check +name: 'Contracts: Storage check' # This workflow is triggered from the main CI workflow. on: diff --git a/.github/workflows/contracts-test.yaml b/.github/workflows/contracts-test.yaml index 9e2900b81..0e8b8c754 100644 --- a/.github/workflows/contracts-test.yaml +++ b/.github/workflows/contracts-test.yaml @@ -1,4 +1,4 @@ -name: Tests +name: 'Contracts: Tests' # This workflow is triggered from the main CI workflow. on: @@ -15,17 +15,6 @@ jobs: ref: ${{ github.ref }} submodules: recursive - - name: Install python - uses: actions/setup-python@v4 - with: - python-version: "3.10" - - - name: Install abi - run: pip install eth_abi - - - name: Install lcov and genhtml - run: sudo apt-get update && sudo apt-get -y install lcov - - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: @@ -34,11 +23,11 @@ jobs: - name: Cache Solidity ABI artifacts uses: actions/cache@v2 with: - path: ./contracts/out - key: contracts-abi-${{ hashFiles('./contracts/src/**/*.sol') }} - - - name: Run coverage check - flaky so we run twice to catch false negatives - run: cd contracts; make coverage || make coverage + path: | + ./contracts/out + ./contracts/bindings + ./contracts/cache + key: v2-contracts-abi-${{ hashFiles('./contracts/**/*.sol') }} - name: Run tests run: cd contracts; make test diff --git a/.github/workflows/fendermint-publish.yaml b/.github/workflows/docker-publish.yaml similarity index 100% rename from .github/workflows/fendermint-publish.yaml rename to .github/workflows/docker-publish.yaml diff --git a/.github/workflows/fendermint-test.yaml b/.github/workflows/fendermint-test.yaml deleted file mode 100644 index 892aa2a23..000000000 --- a/.github/workflows/fendermint-test.yaml +++ /dev/null @@ -1,113 +0,0 @@ -name: Fendermint CI - Test - -# This workflow is triggered from the main CI workflow. -on: - workflow_call: - -env: - CARGO_INCREMENTAL: '0' - SCCACHE_CACHE_SIZE: 10G - CC: "sccache clang" - CXX: "sccache clang++" - PROFILE: "ci" - BUILDX_FLAGS: "--cache-from=type=gha --cache-to=type=gha,mode=max" - -jobs: - # Check code formatting; anything that doesn't require compilation. - pre-compile-checks: - name: Pre-compile checks - runs-on: ubuntu-latest - steps: - - name: Check out the project - uses: actions/checkout@v3 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - components: rustfmt - - - name: Check code formatting - run: cd fendermint && make check-fmt - - - # Test matrix, running tasks from the Makefile. - tests: - # Skip tests on draft PRs, they take a long time, and drafts are for visibility. - if: ${{ !github.event.pull_request.draft }} - needs: [pre-compile-checks] - name: ${{ matrix.make.name }} (${{ matrix.os }}, ${{ matrix.rust }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - rust: [stable] - make: - - name: Clippy - task: check-clippy - # Technically it's not necessary to build, testing would be fine on its own. - # However, tests bring in dev-dependencies, and without them something might not compile, - # which we want to catch as it would mean the `cargo build` in the docs would fail. - # Doing it a one step so build artifacts can be reused by the tests, minimising the overhead. - - name: Build and Test - task: build test - # Tests that involve docker. - - name: End-to-End - task: e2e - exclude: - # Not running Clippy on nightly because sometimes it seems to give false positives. - - rust: nightly - make: - name: Clippy - - rust: nightly - make: - name: End-to-end - - env: - RUST_BACKTRACE: full - RUSTFLAGS: -Dwarnings - - steps: - # https://github.com/marketplace/actions/free-disk-space-ubuntu - - name: Free Disk Space (Ubuntu) - uses: jlumbroso/free-disk-space@main - with: - tool-cache: false - large-packages: false - swap-storage: false - docker-images: false - android: true - dotnet: true - haskell: true - - - name: Check out the project - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install Tools - uses: ./.github/actions/install-tools - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - rust: ${{ matrix.rust }} - - - name: Setup Cache - uses: ./.github/actions/setup-cache - timeout-minutes: 5 - continue-on-error: true - with: - # Caching everything separately, in case they don't ask for the same things to be compiled. - cache-prefix: fendermint-${{ matrix.make.name }}-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') }} - cache-suffix: ${{ hashFiles('**/Cargo.lock') }} - - - name: Cache Solidity ABI artifacts - uses: actions/cache@v2 - with: - path: ./contracts/out - key: contracts-abi-${{ hashFiles('./contracts/src/**/*.sol') }} - - - name: ${{ matrix.make.name }} - env: - PROMTAIL_CLIENT_URL: ${{ secrets.PROMTAIL_CLIENT_URL }} - run: cd fendermint && make ${{ matrix.make.task }} diff --git a/.github/workflows/fevm-contract-tests.yaml b/.github/workflows/fevm-contract-tests.yaml index f4b59d5e4..1febb45f3 100644 --- a/.github/workflows/fevm-contract-tests.yaml +++ b/.github/workflows/fevm-contract-tests.yaml @@ -14,36 +14,29 @@ jobs: submodules: 'recursive' repository: 'consensus-shipyard/fevm-contract-tests' path: 'fevm-contract-tests' + - name: Checkout Fendermint uses: actions/checkout@v2 with: repository: 'consensus-shipyard/ipc' submodules: 'recursive' path: 'ipc' + - name: Install Node.js uses: actions/setup-node@v2 with: node-version: 18.19.0 + - name: Install dependencies run: npm install working-directory: 'fevm-contract-tests' + - name: Install Rust uses: actions-rs/toolchain@v1 with: profile: minimal toolchain: stable - - name: Set up Rust cargo cache - uses: actions/cache@v3 - continue-on-error: false - with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: ${{ runner.os }}-cargo- + - name: Install cargo-make run: | if ! command -v cargo-make &> /dev/null @@ -51,28 +44,17 @@ jobs: cargo install -f cargo-make fi - - uses: actions/cache/save@v3 - if: always() + - name: Download Docker image + uses: actions/download-artifact@v4 with: - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/ - key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - - name: Install Foundry - working-directory: ipc/contracts - run: | - curl -L https://foundry.paradigm.xyz | bash - export PATH="$PATH:/home/runner/.config/.foundry/bin" - foundryup - - name: Pull latest docker build - id: docker-build - working-directory: ipc/fendermint + name: docker-image + path: /tmp + + - name: Load Docker image run: | - export PATH="$PATH:/home/runner/.config/.foundry/bin" - docker pull ghcr.io/consensus-shipyard/fendermint:latest + docker load --input /tmp/docker-image.tar + docker image ls -a + - name: Run a testnode id: testnode working-directory: ipc/ diff --git a/.github/workflows/ipc.yaml b/.github/workflows/ipc.yaml deleted file mode 100644 index 5c3f22f26..000000000 --- a/.github/workflows/ipc.yaml +++ /dev/null @@ -1,83 +0,0 @@ -name: IPC CI - -# This workflow is triggered from the main CI workflow. -on: - workflow_call: - -jobs: - # Check code formatting; anything that doesn't require compilation. - pre-compile-checks: - name: Pre-compile checks - runs-on: ubuntu-latest - steps: - - name: Check out the project - uses: actions/checkout@v3 - - - name: Install Rust - uses: dtolnay/rust-toolchain@master - with: - toolchain: nightly - components: rustfmt - - - name: Check code formatting - run: cd ipc && make check-fmt - - # - name: Check diagrams - # run: make check-diagrams - - # Test matrix, running tasks from the Makefile. - tests: - if: ${{ !github.event.pull_request.draft }} - needs: [pre-compile-checks] - name: ${{ matrix.make.name }} (${{ matrix.os }}, ${{ matrix.rust }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - rust: [stable] - make: - - name: Clippy - task: check-clippy - - name: Test - task: test - - env: - RUST_BACKTRACE: full - RUSTFLAGS: -Dwarnings - CARGO_INCREMENTAL: '0' - SCCACHE_CACHE_SIZE: 10G - CC: "sccache clang" - CXX: "sccache clang++" - - steps: - - name: Check out the project - uses: actions/checkout@v3 - - - name: Install Tools - uses: ./.github/actions/install-tools - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - rust: ${{ matrix.rust }} - - - name: Setup Cache - uses: ./.github/actions/setup-cache - timeout-minutes: 5 - continue-on-error: true - with: - # Caching everything separately, in case they don't ask for the same things to be compiled. - cache-prefix: ipc-${{ matrix.make.name }}-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') }} - cache-suffix: ${{ hashFiles('**/Cargo.lock') }} - - - name: Cache Solidity ABI artifacts - uses: actions/cache@v2 - with: - path: ./contracts/out - key: contracts-abi-${{ hashFiles('./contracts/src/**/*.sol') }} - - - name: Generate Solidity ABI artifacts - run: >- - [ -d contracts/out ] || (cd contracts && make compile-abi) - - - name: ${{ matrix.make.name }} - run: cd ipc && make ${{ matrix.make.task }} diff --git a/.github/workflows/ipld-resolver.yaml b/.github/workflows/ipld-resolver.yaml deleted file mode 100644 index 57e2b3f33..000000000 --- a/.github/workflows/ipld-resolver.yaml +++ /dev/null @@ -1,82 +0,0 @@ -name: IPLD Resolver CI - -# This workflow is triggered from the main CI workflow. -on: - workflow_call: - -jobs: - # Check code formatting; anything that doesn't require compilation. - pre-compile-checks: - name: Pre-compile checks - runs-on: ubuntu-latest - steps: - - name: Check out the project - uses: actions/checkout@v3 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly - components: rustfmt - - name: Check code formatting - run: cd ipld/resolver && make check-fmt - - # - name: Check diagrams - # run: make check-diagrams - - # Test matrix, running tasks from the Makefile. - tests: - if: ${{ !github.event.pull_request.draft }} - needs: [pre-compile-checks] - name: ${{ matrix.make.name }} (${{ matrix.os }}, ${{ matrix.rust }}) - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest] - rust: [stable] - make: - - name: Check clippy - task: check-clippy - - name: Test - task: test - - env: - RUST_BACKTRACE: full - RUSTFLAGS: -Dwarnings - CARGO_INCREMENTAL: '0' - SCCACHE_CACHE_SIZE: 10G - CC: "sccache clang" - CXX: "sccache clang++" - - steps: - - name: Check out the project - uses: actions/checkout@v3 - - - name: Install Tools - uses: ./.github/actions/install-tools - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - rust: ${{ matrix.rust }} - - - name: Setup Cache - uses: ./.github/actions/setup-cache - timeout-minutes: 5 - continue-on-error: true - with: - # Caching everything separately, in case they don't ask for the same things to be compiled. - cache-prefix: ipld-resolver-${{ matrix.make.name }}-${{ matrix.os }}-${{ matrix.rust }}-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') }} - cache-suffix: ${{ hashFiles('**/Cargo.lock') }} - - - name: Cache Solidity ABI artifacts - uses: actions/cache@v2 - with: - path: ./contracts/out - key: contracts-abi-${{ hashFiles('./contracts/src/**/*.sol') }} - - - name: Generate Solidity ABI artifacts - run: >- - [ -d contracts/out ] || (cd contracts && make compile-abi) - - - name: ${{ matrix.make.name }} - run: cd ipld/resolver && make ${{ matrix.make.task }} diff --git a/.github/workflows/license.yaml b/.github/workflows/license.yaml index a5554272b..f3aa5872f 100644 --- a/.github/workflows/license.yaml +++ b/.github/workflows/license.yaml @@ -1,5 +1,4 @@ - -name: License CI +name: Check licenses # This workflow is triggered from the main CI workflow. on: diff --git a/.github/workflows/tests-e2e.yaml b/.github/workflows/tests-e2e.yaml new file mode 100644 index 000000000..efc70b5e0 --- /dev/null +++ b/.github/workflows/tests-e2e.yaml @@ -0,0 +1,58 @@ +name: Run e2e tests + +# This workflow is triggered from the main CI workflow. +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + + env: + RUST_BACKTRACE: full + RUSTFLAGS: -Dwarnings + + steps: + - name: Check out the project + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Tools + uses: ./.github/actions/install-tools + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + rust: stable + + - name: Download Docker image + uses: actions/download-artifact@v4 + with: + name: docker-image + path: /tmp + + - name: Load Docker image + run: | + docker load --input /tmp/docker-image.tar + docker image ls -a + + - name: Cache Solidity ABI artifacts + uses: actions/cache@v4 + with: + path: | + ./contracts/out + ./contracts/bindings + ./contracts/cache + key: v2-contracts-abi-${{ hashFiles('./contracts/**/*.sol') }} + + - name: Cache Cargo Build + uses: actions/cache@v4 + with: + path: | + /home/runner/.cargo/registry + /home/runner/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run e2e tests + run: cd fendermint && PROFILE=ci make e2e-only + diff --git a/.github/workflows/tests-unit.yaml b/.github/workflows/tests-unit.yaml new file mode 100644 index 000000000..285f3ff93 --- /dev/null +++ b/.github/workflows/tests-unit.yaml @@ -0,0 +1,47 @@ +name: Run unit tests + +# This workflow is triggered from the main CI workflow. +on: + workflow_call: + +jobs: + run: + runs-on: ubuntu-latest + + env: + RUST_BACKTRACE: full + RUSTFLAGS: -Dwarnings + + steps: + - name: Check out the project + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Install Tools + uses: ./.github/actions/install-tools + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + rust: stable + + - name: Cache Solidity ABI artifacts + uses: actions/cache@v4 + with: + path: | + ./contracts/out + ./contracts/bindings + ./contracts/cache + key: v2-contracts-abi-${{ hashFiles('./contracts/**/*.sol') }} + + - name: Cache Cargo Build + uses: actions/cache@v4 + with: + path: | + /home/runner/.cargo/registry + /home/runner/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + + - name: Run unit tests + run: make test-rust + diff --git a/Makefile b/Makefile index 43ecc8b06..881b11505 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,15 @@ default: ./target/release/ipc-cli --version ./target/release/fendermint --version -SUBTREES := fendermint ipc ipld/resolver contracts +SUBTREES_RUST := fendermint ipc ipld/resolver +SUBTREES_CONTRACTS := contracts +SUBTREES_ALL := $(SUBTREES_RUST) $(SUBTREES_CONTRACTS) -test: $(patsubst %, test/%, $(SUBTREES)) +test: test-rust test-contracts + +test-rust: $(patsubst %, test/%, $(SUBTREES_RUST)) + +test-contracts: $(patsubst %, test/%, $(SUBTREES_CONTRACTS)) # Using `cd` instead of `-C` so $(PWD) is correct. test/%: @@ -21,4 +27,4 @@ lint/%: license: ./scripts/add_license.sh -lint: license $(patsubst %, lint/%, $(SUBTREES)) +lint: license $(patsubst %, lint/%, $(SUBTREES_ALL)) diff --git a/contracts/binding/build.rs b/contracts/binding/build.rs index 72f3b800d..75d56a51a 100644 --- a/contracts/binding/build.rs +++ b/contracts/binding/build.rs @@ -117,6 +117,7 @@ fn main() { .unwrap(); } + println!("cargo:rerun-if-changed=../out"); println!("cargo:rerun-if-changed=build.rs"); // Run rustfmt on binding/src/lib.rs to make sure we don't accidentally format it in our IDEs diff --git a/ext/merkle-tree-rs/src/standard.rs b/ext/merkle-tree-rs/src/standard.rs index 74b44e176..e925a7641 100644 --- a/ext/merkle-tree-rs/src/standard.rs +++ b/ext/merkle-tree-rs/src/standard.rs @@ -383,7 +383,7 @@ mod tests { .map(|v| v.iter().map(|v| v.to_string()).collect()) .collect(); - let leaves_array = vec![ + let leaves_array = [ vec![], vec![0, 1], vec![0, 1, 5], diff --git a/fendermint/Makefile b/fendermint/Makefile index 3936b2a37..92a668994 100644 --- a/fendermint/Makefile +++ b/fendermint/Makefile @@ -47,6 +47,9 @@ test: $(BUILTIN_ACTORS_BUNDLE) $(IPC_ACTORS_GEN) # Not using --release beause the build has been done in docker and the wasm code runs inside the container. e2e: docker-build | cargo-make + ${MAKE} e2e-only + +e2e-only: cd testing/smoke-test && cargo make --profile $(PROFILE) cd testing/snapshot-test && cargo make --profile $(PROFILE) cd testing/graph-test && cargo make --profile $(PROFILE) @@ -98,7 +101,6 @@ docker-build: docker-deps $(FENDERMINT_CODE) -t fendermint:latest $(PWD)/..; \ fi - # Build a bundle CAR; this is so we don't have to have a project reference, # which means we are not tied to the release cycle of both FVM _and_ actors; # so long as they work together. diff --git a/fendermint/docker/builder.ci.Dockerfile b/fendermint/docker/builder.ci.Dockerfile index 0ec2c8397..64c78e001 100644 --- a/fendermint/docker/builder.ci.Dockerfile +++ b/fendermint/docker/builder.ci.Dockerfile @@ -65,7 +65,11 @@ RUN if [ "${TARGETARCH}" = "arm64" ]; then \ COPY --from=stripper /app /app # Build the dependencies. -RUN set -eux; \ +RUN \ + --mount=type=cache,target=/root/.cargo/registry,sharing=locked \ + --mount=type=cache,target=/root/.cargo/git,sharing=locked \ + --mount=type=cache,target=/app/target,sharing=locked \ + set -eux; \ case "${TARGETARCH}" in \ amd64) ARCH='x86_64' ;; \ arm64) ARCH='aarch64' ;; \ @@ -83,7 +87,11 @@ COPY . . RUN find . -type f \( -wholename "**/src/lib.rs" -o -wholename "**/src/main.rs" \) | xargs touch # Do the final build. -RUN set -eux; \ +RUN \ + --mount=type=cache,target=/root/.cargo/registry,sharing=locked \ + --mount=type=cache,target=/root/.cargo/git,sharing=locked \ + --mount=type=cache,target=/app/target,sharing=locked \ + set -eux; \ case "${TARGETARCH}" in \ amd64) ARCH='x86_64' ;; \ arm64) ARCH='aarch64' ;; \ diff --git a/fendermint/docker/runner.Dockerfile b/fendermint/docker/runner.Dockerfile index c1315b90b..846d2985a 100644 --- a/fendermint/docker/runner.Dockerfile +++ b/fendermint/docker/runner.Dockerfile @@ -30,10 +30,10 @@ ENV FM_METRICS__LISTEN__HOST=0.0.0.0 RUN mkdir /fendermint/logs RUN chmod 777 /fendermint/logs -COPY fendermint/docker/.artifacts/bundle.car $FM_HOME_DIR/bundle.car -COPY fendermint/docker/.artifacts/custom_actors_bundle.car $FM_HOME_DIR/custom_actors_bundle.car -COPY fendermint/docker/.artifacts/contracts $FM_HOME_DIR/contracts COPY fendermint/docker/docker-entry.sh /usr/local/bin/docker-entry.sh +COPY fendermint/builtin-actors/output/bundle.car $FM_HOME_DIR/bundle.car +COPY fendermint/actors/output/custom_actors_bundle.car $FM_HOME_DIR/custom_actors_bundle.car +COPY contracts/out $FM_HOME_DIR/contracts COPY --from=builder /app/fendermint/app/config $FM_HOME_DIR/config COPY --from=builder /app/output/bin/fendermint /usr/local/bin/fendermint COPY --from=builder /app/output/bin/ipc-cli /usr/local/bin/ipc-cli diff --git a/ipc/.github/workflows/branch-check.yaml b/ipc/.github/workflows/branch-check.yaml deleted file mode 100644 index 7f7f6912c..000000000 --- a/ipc/.github/workflows/branch-check.yaml +++ /dev/null @@ -1,21 +0,0 @@ -name: Check branch - -on: - pull_request_target: # Do not combine with explicit checkout for security reasons - types: [opened] # Not triggering on "edited" to allow a forced path to main - -jobs: - check-branch: - runs-on: ubuntu-latest - steps: - - uses: Vankka/pr-target-branch-action@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - target: main - exclude: dev # Don't prevent going from development -> main - change-to: dev - comment: | - Your PR was set to target `main`. PRs should be target `dev`. - The base branch of this PR has been automatically changed to `dev`. - If you really intend to target `main`, edit the PR. \ No newline at end of file diff --git a/ipc/.github/workflows/release-binaries.yaml b/ipc/.github/workflows/release-binaries.yaml deleted file mode 100644 index 9c9b6c2ff..000000000 --- a/ipc/.github/workflows/release-binaries.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Release binaries - -permissions: - contents: write - -on: - workflow_dispatch: - release: - types: [ created ] - -jobs: - upload-assets: - strategy: - fail-fast: false - matrix: - include: - - target: x86_64-unknown-linux-gnu - os: ubuntu-latest - - target: universal-apple-darwin - os: macos-latest - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v3 - - uses: taiki-e/upload-rust-binary-action@v1 - with: - bin: ipc-agent - target: ${{ matrix.target }} - archive: $bin-$tag-$target - token: ${{ secrets.GITHUB_TOKEN }}