diff --git a/.circleci/config.yml b/.circleci/config.yml index 092a0a7f6b..398b83fed2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,79 +1,14 @@ version: 2.1 -orbs: - go: circleci/go@1.5.0 - -jobs: - # This job builds the hive executable and stores it in the workspace. - build: - docker: - - image: cimg/go:1.21 - steps: - # Build it. - - checkout - - go/load-cache - - go/mod-download - - go/save-cache - - run: {command: 'go build -ldflags="-s -extldflags=-static" -tags "osusergo netgo static_build" .'} - # Store the executable. - - persist_to_workspace: - root: . - paths: ["hive"] - # This job runs the smoke test simulations. This requires a virtual - # machine instead of the container-based build environment because - # hive needs to be able to talk to the docker containers it creates. - smoke-tests: - machine: - image: ubuntu-2004:202201-02 - steps: - - checkout - - attach_workspace: {at: "/tmp/build"} - - run: - command: "/tmp/build/hive --sim=smoke/genesis --client=go-ethereum" - - run: - command: "/tmp/build/hive --sim=smoke/network --client=go-ethereum" +setup: true - # This job also runs the smoke test simulations, but against a remote dockerd. - smoke-tests-remote-docker: - docker: - - image: cimg/base:2022.04 - steps: - - checkout - - attach_workspace: {at: "/tmp/build"} - - setup_remote_docker: {version: 20.10.14} - - run: - command: "/tmp/build/hive --sim=smoke/genesis --client=go-ethereum --loglevel 5" - - run: - command: "/tmp/build/hive --sim=smoke/network --client=go-ethereum --loglevel 5" - - # This job runs the go unit tests. - go-test: - docker: - - image: cimg/go:1.21 - steps: - # Get the source. - - checkout - - go/load-cache - - go/mod-download - - go/save-cache - # Run the tests. - - run: - name: "hive module tests" - command: "go test -cover ./..." - - run: - name: "hiveproxy module tests" - command: "go test -cover ./..." - working_directory: "./hiveproxy" - - run: - name: "Compile Go simulators" - command: ".circleci/compile-simulators.sh" +orbs: + path-filtering: circleci/path-filtering@0.0.1 workflows: - main: + setup-workflow: jobs: - - go-test - - build - - smoke-tests: - requires: ["build"] - - smoke-tests-remote-docker: - requires: ["build"] + - path-filtering/filter: + mapping: | + simulators/portal/.* rust-ci true + base-revision: origin/master diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml new file mode 100644 index 0000000000..5534e7a1be --- /dev/null +++ b/.circleci/continue_config.yml @@ -0,0 +1,106 @@ +version: 2.1 +orbs: + go: circleci/go@1.5.0 + +parameters: + rust-ci: + type: boolean + default: false + +jobs: + # This job builds the hive executable and stores it in the workspace. + build: + docker: + - image: cimg/go:1.21 + steps: + # Build it. + - checkout + - go/load-cache + - go/mod-download + - go/save-cache + - run: {command: 'go build -ldflags="-s -extldflags=-static" -tags "osusergo netgo static_build" .'} + # Store the executable. + - persist_to_workspace: + root: . + paths: ["hive"] + + # This job runs the smoke test simulations. This requires a virtual + # machine instead of the container-based build environment because + # hive needs to be able to talk to the docker containers it creates. + smoke-tests: + machine: + image: ubuntu-2004:202201-02 + steps: + - checkout + - attach_workspace: {at: "/tmp/build"} + - run: + command: "/tmp/build/hive --sim=smoke/genesis --client=go-ethereum" + - run: + command: "/tmp/build/hive --sim=smoke/network --client=go-ethereum" + + # This job also runs the smoke test simulations, but against a remote dockerd. + smoke-tests-remote-docker: + docker: + - image: cimg/base:2022.04 + steps: + - checkout + - attach_workspace: {at: "/tmp/build"} + - setup_remote_docker: {version: 20.10.14} + - run: + command: "/tmp/build/hive --sim=smoke/genesis --client=go-ethereum --loglevel 5" + - run: + command: "/tmp/build/hive --sim=smoke/network --client=go-ethereum --loglevel 5" + + # This job runs the go unit tests. + go-test: + docker: + - image: cimg/go:1.21 + steps: + # Get the source. + - checkout + - go/load-cache + - go/mod-download + - go/save-cache + # Run the tests. + - run: + name: "hive module tests" + command: "go test -cover ./..." + - run: + name: "hiveproxy module tests" + command: "go test -cover ./..." + working_directory: "./hiveproxy" + - run: + name: "Compile Go simulators" + command: ".circleci/compile-simulators.sh" + # this makes sure the rust code is good + rust-simulators: + docker: + - image: cimg/rust:1.71.1 + steps: + - checkout + - run: + name: Install rustfmt + command: rustup component add rustfmt + - run: + name: Install Clippy + command: rustup component add clippy + - run: + name: Install Clang + command: sudo apt update && sudo apt-get install clang -y + - run: + name: "Lint, build, test Rust simulators" + command: ".circleci/rust-simulators.sh" + +workflows: + main: + jobs: + - go-test + - build + - smoke-tests: + requires: ["build"] + - smoke-tests-remote-docker: + requires: ["build"] + - rust-jobs: + when: << pipeline.parameters.rust-ci >> + jobs: + - rust-simulators \ No newline at end of file diff --git a/.circleci/rust-simulators.sh b/.circleci/rust-simulators.sh new file mode 100644 index 0000000000..5bf64708ac --- /dev/null +++ b/.circleci/rust-simulators.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# This causes the bash script to exit immediately if any commands errors out +set -e + +failed="" +sims=$(find simulators -name Cargo.toml) +for d in $sims; do + d="$(dirname "$d")" + echo "Lint, build, test $d" + ( cd "$d" || exit 1; + cargo fmt --all -- --check; + cargo clippy --all --all-targets --all-features --no-deps -- --deny warnings; + cargo test --workspace -- --nocapture; + ) +done