0

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

Jomy
  • 514
  • 6
  • 22
  • If you read the answers to the question you linked carefully, it seems that the `checkout` is applied after the `working_directory`, so your tables directory is now in fact at `~/simple_tables/tables/tables`. (add a `- run: find .` to verify). The answers you linked also explain how to solve this. – Caesar Jan 12 '22 at 00:58
  • Thanks for the `- run: find .` tip! I managed to solve the problem – Jomy Jan 12 '22 at 09:30
  • 1
    A short comment (or a self-answer) on how you solved it would probably be appreciated, if anyone ever comes here from a search engine. (Also, I should have recommended `- run: find "$PWD"`. Oh well.) – Caesar Jan 12 '22 at 11:23

1 Answers1

0

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).

Jomy
  • 514
  • 6
  • 22