Skip to content

Fix CWD interation between codspeed.yml and the cli commands#270

Merged
GuillaumeLagrange merged 3 commits intomainfrom
cod-2371-fix-clis-cwd-behavior-in-non-ci-usage
Mar 23, 2026
Merged

Fix CWD interation between codspeed.yml and the cli commands#270
GuillaumeLagrange merged 3 commits intomainfrom
cod-2371-fix-clis-cwd-behavior-in-non-ci-usage

Conversation

@GuillaumeLagrange
Copy link
Copy Markdown
Contributor

@GuillaumeLagrange GuillaumeLagrange commented Mar 18, 2026

The rule is

  1. When doing codspeed run without argument, the working directory should be by order of priority
    • the codspeed.yml general working directory setting, defined in project level options in codspeed.yml, as relative to the file it is written in
    • the path of the codspeed.yml directory

Note: For this case, CLI overrides of working directory are ignored with a warning

  1. When doing codspeed run -- command or codspeed exec -- command
    • explicit --working-directory cli flag
    • CWD

Note: For this case, we EXPLICITLY ignore the path of the discovered config

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 18, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks


Comparing cod-2371-fix-clis-cwd-behavior-in-non-ci-usage (742e79d) with main (6e55caf)

Open in CodSpeed

@GuillaumeLagrange GuillaumeLagrange force-pushed the cod-2371-fix-clis-cwd-behavior-in-non-ci-usage branch from 70676dc to f630ed5 Compare March 18, 2026 17:32
@GuillaumeLagrange GuillaumeLagrange marked this pull request as ready for review March 18, 2026 17:59
@GuillaumeLagrange GuillaumeLagrange changed the title Cod 2371 fix clis cwd behavior in non ci usage Fix CWD interation between codspeed.yml and the cli commands Mar 18, 2026
Copy link
Copy Markdown
Member

@not-matthias not-matthias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Move config file discovery logic from `ProjectConfig` into a dedicated
`DiscoveredProjectConfig` struct that preserves the config file path.
This removes the side-effect of `set_current_dir()` during discovery
and instead exposes `config_dir()` for callers to resolve paths
relative to the config file location.

Also stop merging `working_directory` from config in the merger since
it needs path resolution relative to the config file directory, which
the merger doesn't have access to.
When running `codspeed run` with config targets, the `working-directory`
option is now resolved relative to the config file's directory instead
of the current working directory. When no `working-directory` is set,
it defaults to the config file's directory.

For `codspeed run -- command` and `codspeed exec`, the config's
`working-directory` is explicitly ignored — only the `--working-directory`
CLI flag is used. A warning is emitted if `--working-directory` is passed
in config targets mode.
@GuillaumeLagrange GuillaumeLagrange force-pushed the cod-2371-fix-clis-cwd-behavior-in-non-ci-usage branch from f630ed5 to 742e79d Compare March 22, 2026 18:00
@GuillaumeLagrange GuillaumeLagrange merged commit 742e79d into main Mar 23, 2026
17 checks passed
@GuillaumeLagrange GuillaumeLagrange deleted the cod-2371-fix-clis-cwd-behavior-in-non-ci-usage branch March 23, 2026 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants