diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 0000000..c810fde --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,18 @@ +name: Coverage +on: [pull_request, push] +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Rust + run: rustup toolchain install nightly --component llvm-tools-preview + - name: Install cargo-llvm-cov + run: curl -LsSf https://github.com/taiki-e/cargo-llvm-cov/releases/latest/download/cargo-llvm-cov-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v1 + with: + files: lcov.info + fail_ci_if_error: true diff --git a/Dockerfile b/Dockerfile index 93c409f..824cdb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,16 +1,37 @@ FROM ghcr.io/xmtp/rust:latest ARG PROJECT=didethresolver -WORKDIR /workspaces/${PROJECT} +RUN sudo apt update && sudo apt install -y pkg-config openssl libssl-dev + + +WORKDIR /build +RUN git clone https://github.com/foundry-rs/foundry + +ARG MAXIMUM_THREADS=2 +WORKDIR /build/foundry +RUN git pull && LATEST_TAG=$(git describe --tags --abbrev=0) || LATEST_TAG=master && \ + echo "building tag ${LATEST_TAG}" && \ + git -c advice.detachedHead=false checkout nightly && \ + . $HOME/.cargo/env && \ + THREAD_NUMBER=$(cat /proc/cpuinfo | grep -c ^processor) && \ + MAX_THREADS=$(( THREAD_NUMBER > ${MAXIMUM_THREADS} ? ${MAXIMUM_THREADS} : THREAD_NUMBER )) && \ + echo "building with ${MAX_THREADS} threads" && \ + cargo install --path crates/anvil --jobs ${MAX_THREADS} + +WORKDIR /workspaces/${PROJECT} USER xmtp ENV USER=xmtp ENV PATH=/home/${USER}/.cargo/bin:$PATH + # source $HOME/.cargo/env COPY --chown=xmtp:xmtp . . RUN cargo fmt --check RUN cargo clippy --all-features --no-deps -RUN cargo test +# Skip integration tests for now +RUN cargo test --lib +RUN cargo test --doc + CMD cargo run