diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2948707ee..8972f23c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,27 +11,23 @@ on: env: CARGO_TERM_COLOR: always + CARGO_INCREMENTAL: 0 + CARGO_NET_RETRY: 10 + RUST_BACKTRACE: short + RUSTFLAGS: "-D warnings" + RUSTUP_MAX_RETRIES: 10 jobs: lint: runs-on: ubuntu-latest - container: circleci/rust:bullseye steps: - # The Docker file changes sets USER to circleci instead of using the default user, so we need to update file permissions for this image to work on GH Actions. - # See https://docs.github.com/actions/reference/virtual-environments-for-github-hosted-runners#docker-container-filesystem - - name: Setup file system permissions - run: sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - - uses: actions/checkout@v3 - - name: Install Rust + # will install toolchain specified in rust-toolchain + - name: Install Rust toolchain run: | - rustup toolchain install 1.60.0-x86_64-unknown-linux-gnu - rustup component add rustfmt --toolchain 1.60.0-x86_64-unknown-linux-gnu - rustup component add clippy --toolchain 1.60.0-x86_64-unknown-linux-gnu - sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - echo 'RUSTFLAGS=-D warnings' >> $GITHUB_ENV + rustup show - name: Version Information run: | @@ -41,60 +37,75 @@ jobs: cargo fmt -- --version cargo clippy -- --version + - name: Cache Dependencies + uses: Swatinem/rust-cache@v2 + - name: Lint (rustfmt) run: | cargo fmt -- --check - name: Lint (clippy) run: | - cargo clippy --all-features --all-targets + cargo clippy --locked --workspace --all-features --all-targets tests: runs-on: ubuntu-latest - container: circleci/rust:bullseye steps: - # The Docker file changes sets USER to circleci instead of using the default user, so we need to update file permissions for this image to work on GH Actions. - # See https://docs.github.com/actions/reference/virtual-environments-for-github-hosted-runners#docker-container-filesystem - - name: Setup file system permissions - run: sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - - uses: actions/checkout@v3 - - name: Install Rust + # will install toolchain specified in rust-toolchain + - name: Install Rust toolchain run: | - rustup toolchain install 1.60.0-x86_64-unknown-linux-gnu - sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - echo 'RUSTFLAGS=-D warnings' >> $GITHUB_ENV - - - name: Setup Additional Languages + rustup show + + - name: Setup Additional Languages (python3) + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Setup Additional Languages (python3 packages) run: | - sudo chmod -R 777 $GITHUB_WORKSPACE /github /__w/_temp - sudo apt-get update - sudo apt-get install -y apt-transport-https python3-all-dev python3-pip default-jdk golang-1.15-go - echo '/usr/lib/go-1.15/bin' >> $GITHUB_PATH python3 -m pip install pyre-check==0.0.59 python3 -m pip install numpy==1.20.1 echo '/github/home/.local/bin' >> $GITHUB_PATH - wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb - sudo dpkg -i packages-microsoft-prod.deb - sudo apt-get update - sudo apt-get install -y dotnet-sdk-2.1 dotnet-sdk-3.1 - curl -fsSL https://deno.land/x/install/install.sh | sh - echo 'DENO_INSTALL=/github/home/.deno' >> $GITHUB_ENV - echo '/github/home/.deno/bin' >> $GITHUB_PATH - sudo sh -c 'wget -qO- https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' - sudo sh -c 'wget -qO- https://storage.googleapis.com/download.dartlang.org/linux/debian/dart_stable.list > /etc/apt/sources.list.d/dart_stable.list' - sudo apt-get update - sudo apt-get install dart - sudo apt-get install binutils git gnupg2 libc6-dev libcurl4 libedit2 libgcc-9-dev libpython2.7 libsqlite3-0 libstdc++-9-dev libxml2 libz3-dev pkg-config tzdata zlib1g-dev -y - wget https://swift.org/builds/swift-5.3.3-release/ubuntu2004/swift-5.3.3-RELEASE/swift-5.3.3-RELEASE-ubuntu20.04.tar.gz - tar xzf swift-5.3.3-RELEASE-ubuntu20.04.tar.gz - sudo mkdir -p /opt - sudo mv swift-5.3.3-RELEASE-ubuntu20.04 /opt/swift - echo '/opt/swift/usr/bin' >> $GITHUB_PATH - sudo apt-get install opam - opam init --disable-sandboxing -y + + - name: Setup Additional Languages (.Net) + uses: actions/setup-dotnet@v3 + with: + dotnet-version: | + 2.1.x + 3.1.x + + - name: Setup Additional Languages (golang) + uses: actions/setup-go@v3 + with: + go-version: '~1.15.0' + + - name: Setup Additional Languages (deno) + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Setup Additional Languages (dart) + uses: dart-lang/setup-dart@v1 + with: + sdk: 2.14.0 + + - name: Setup Additional Languages (swift) + uses: swift-actions/setup-swift@v1 + with: + # older swift versions are having gpg issues https://github.com/swift-actions/setup-swift/issues/520 + swift-version: "5.7" + + - name: Setup Additional Languages (ocaml) + uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: 4.14.x + opam-disable-sandboxing: true + + - name: Setup Additional Languages (ocaml packages) + run: | eval $(opam env) opam install -y stdint uutf ppxlib @@ -112,12 +123,29 @@ jobs: deno --version dart --version swift --version + eval $(opam env) ocaml --version - - name: Build and Test + - name: Compile (dev tests) + run: cargo test --no-run --locked + + # It's faster to `test` before `build` according to + # https://github.com/rust-lang/rust-analyzer/blob/97b357e41b99ee3d5dd72a1640f6c74e4f4d6b64/.github/workflows/ci.yaml#L55 + - name: Compile (dev serde-reflection) + run: cargo build --locked --all-targets + + - name: Test (dev) run: | eval $(opam env) - cargo build --all-targets cargo test - cargo build --release --all-targets --all-features - cargo test --release --all-features + + - name: Compile (release tests) + run: cargo test --no-run --locked --release --all-features + + - name: Compile (release serde-reflection) + run: cargo build --locked --release --all-targets --all-features + + - name: Test (release) + run: | + eval $(opam env) + cargo test --locked --release --all-features diff --git a/rust-toolchain b/rust-toolchain deleted file mode 100644 index 4d5fde5bd..000000000 --- a/rust-toolchain +++ /dev/null @@ -1 +0,0 @@ -1.60.0 diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 000000000..b843f0c70 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "1.60.0" +profile = "default" diff --git a/serde-generate/runtime/cpp/bcs.hpp b/serde-generate/runtime/cpp/bcs.hpp index 9a380f965..4ed7ec489 100644 --- a/serde-generate/runtime/cpp/bcs.hpp +++ b/serde-generate/runtime/cpp/bcs.hpp @@ -5,6 +5,7 @@ #include #include +#include #include "binary.hpp" #include "serde.hpp" diff --git a/serde-generate/runtime/cpp/bincode.hpp b/serde-generate/runtime/cpp/bincode.hpp index 038f4e9ef..8c26d515b 100644 --- a/serde-generate/runtime/cpp/bincode.hpp +++ b/serde-generate/runtime/cpp/bincode.hpp @@ -4,6 +4,7 @@ #pragma once #include +#include #include "binary.hpp" #include "serde.hpp"