version: 2.1
jobs:
  fce:
    docker:
      - image: circleci/rust:latest
    environment:
      RUST_BACKTRACE: 1
      #RUST_TEST_THREADS: 1
    steps:
      - checkout
      - restore_cache:
          keys:
            - fce03-{{ checksum "Cargo.lock" }}
      - run: |
          rustup toolchain install nightly
          rustup component add rustfmt
          rustup component add clippy --toolchain nightly
          rustup target add wasm32-wasi

          cargo install fcli

          cargo fmt --all -- --check --color always
          cargo +nightly check -v --all-features


          cd ./examples/call_parameters/
          ./build.sh

          cd ../greeting/
          ./build.sh

          cd ../ipfs-node/
          ./build.sh

          cd ../records/
          ./build.sh

          cd ../url-downloader/
          ./build.sh

          cd ../../fluence-faas/tests/wasm_tests/

          cd ../../

          cargo +nightly test --release -v --all-features
          cargo +nightly clippy -v

      - save_cache:
          paths:
            - ~/.cargo
            - ~/.rustup
          key: fce03-{{ checksum "Cargo.lock" }}

workflows:
  version: 2.1
  fce:
    jobs:
      - fce