Skip to content

Commit 079790e

Browse files
authored
Fix dubious ownership error in runtime-versioner unit tests (#3668)
## Motivation and Context In a Docker container we use in our release pipeline, we've got the following error in `runtime-versioner` unit tests ``` Running tests/test_audit.rs (src/smithy-rs/tools/target/debug/deps/test_audit-9e2b5cd76b506229) running 6 tests Cloning into 'test_base'... Cloning into 'test_base'... Cloning into 'test_base'... Cloning into 'test_base'... Cloning into 'test_base'... Cloning into 'test_base'... fatal: detected dubious ownership in repository at '/tmp/.tmpjwZMOW/test_base.git' To add an exception for this directory, call: git config --global --add safe.directory /tmp/.tmpjwZMOW/test_base.git fatal: detected dubious ownership in repository at '/tmp/.tmp9Aw4By/test_base.git' ``` `runtime-versioner` unit tests [unpacks a tar file for a fake git repo](https://github.com/smithy-lang/smithy-rs/blob/cd0f0bac513a1f74e1d0fa232d753c0ac37d8348/tools/ci-build/runtime-versioner/test-common/src/lib.rs#L31-L39), but for some reason, the resulting file had a strange owner:group assigned to it ``` drwxr-xr-x 6 504 games 4096 Dec 20 00:46 test_base.git ``` The tests have been passing but they started breaking yesterday for some reason. To side step this issue, this PR will ensure the resulting file has the correct current user. ## Testing Verified running unit tests in a container with the fix and confirmed it passed. ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 2cca202 commit 079790e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

tools/ci-build/runtime-versioner/Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/ci-build/runtime-versioner/test-common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ publish = false
88
camino = "1.1.6"
99
tempfile = "3.8.1"
1010
test_bin = "0.4.0"
11+
whoami = "1.5.1"

tools/ci-build/runtime-versioner/test-common/src/lib.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@ impl TestBase {
3737
.success(),
3838
"untarring the test_base into the temp directory failed"
3939
);
40+
// ensure unpacked file has the current user assigned to the owner,
41+
// otherwise we could get the `fatal: detected dubious ownership in repository` error
42+
let test_repo = Utf8PathBuf::try_from(tmp.path().join("test_base.git")).unwrap();
43+
assert!(
44+
Command::new("chown")
45+
.args(&[&format!("{}", whoami::username()), test_repo.as_str(),])
46+
.current_dir(tmp.path())
47+
.status()
48+
.unwrap()
49+
.success(),
50+
"setting the owner of `test_base.git` to the current user failed"
51+
);
4052
assert!(
4153
Command::new("git")
4254
.args(["clone", "test_base.git"])

0 commit comments

Comments
 (0)