#`withExec` that sets up data in a service is being cached, but not the following `withExec`

1 messages · Page 1 of 1 (latest)

normal thistle
#

I'm running some unit tests in CI (using github actions + depot) with a block like:

  @func()
  async elixirTest(): Promise<number> {
    const postgres = dag
      .container()
      .from("postgres:15")
      .withEnvVariable("DEDUPE", "mandark_test")
      .withEnvVariable("POSTGRES_PASSWORD", "postgres")
      .withExposedPort(5432)
      .asService({
        useEntrypoint: true,
      });
    return this.elixirBuildEnv()
      .withServiceBinding("localhost", postgres)
      .withExec(["mix", "reset"])
      .withExec(["mix", "test", "--warnings-as-errors"])
      .exitCode();
  }

mix reset handles setting up the database for mix test, but it's been cached and hasn't been running, causing mix test to fail because there's no database.

I'm not quite sure how mix reset could be cached but not mix test, though.

Any ideas on the best way to handle commands with side effects like this that need to run together, since they're acting on a service outside the cache? Could probably combine into a single mix command, I guess?

desert obsidian
#

if mix test has failed, that would explain it not being cached

normal thistle
#

🤔
Hm, I don't necessarily want it to always run, though.
I do want to make sure that if it does run, both commands run.

#

Maybe best way is to combine them into a single mix command?