Search code examples
rustintegration-testingcircleci

CircleCI Rust Tests in a species subdirectory


I am trying to set up CircleCI for my project. My project structure is as follows:

.circleci
  +- config.yml
tables
  +- src
  +- target
  +- tests
  +- Cargo.lock
  +- Cargo.toml
core
  +- (...) (regular rust project)
derive
  +- (...) (regular rust project)
(...) (some other directories and files)

My config.yml looks like this:

version: 2.1

jobs:
  build:
    working_directory: ~/simple_tables/tables
    docker:
      - image: cimg/rust:1.50.0
    steps:
      - checkout
      - run: cargo --version
      - run:
          name: Run Tests
          command: "cargo test"

I got this from the CircleCI blog. The working_directory I got from here.

When this runs, I get the following output however:

#!/bin/bash -eo pipefail
cargo test
error: could not find `Cargo.toml` in `/home/circleci/simple_tables/tables` or any parent directory

Exited with code exit status 101
CircleCI received exit code 101

How can I run the tests located in the /tables/tests?

Thanks in advance, Jonas


Solution

  • As Caesar mentioned, you can use - run: find "$PWD" for debugging.

    Also make sure that you have

    - checkout:
         path: ~/repo
    

    instead of just - checkout

    I also had to update - image: cimg/rust:1.50.0 to - image: cimg/rust:1.56.0, because the 1.56.0 indicates the rust version and as of now, this is the latest rust version (you can run rust --version on your own computer to get your installed version).