garden-rs / garden

Garden grows and cultivates collections of Git trees ~ Official mirror of https://gitlab.com/garden-rs/garden
https://garden-rs.gitlab.io
MIT License
64 stars 9 forks source link

Integration tests fail in NixOS using nix-build #21

Closed jordilin closed 7 months ago

jordilin commented 7 months ago

NixOS builds in sandboxed environments using nixbld users and /homeless-shelter as a $HOME. Those build users do not have .gitconfig setup, so git operations fail with error: could not lock config file /homeless-shelter/.gitconfig: No such file or directory. Complete output below after issuing nix build

     Running tests/integration_test.rs (target/release/deps/integration_test-74d13108bef44e11)

running 43 tests
test cmd_dot_default_no_args ... ok
test cmd_exec_grafted_group ... ok
test cmd_exec_garden_with_grafted_trees ... ok
test cmd_dot_default_double_dash_args ... ok
test cmd_exec_group_with_grafted_trees ... ok
test cmd_dot_default_double_dash ... ok
test cmd_dot_default_no_args_echo ... ok
test eval_config_dir_with_chdir_and_root ... ok
test cmd_no_errexit ... ok
test cmd_dash_dash_arguments_custom ... ok
test eval_exec_pwd_with_root_and_chdir ... ok
test eval_graft_variable_at_tree_scope ... ok
test eval_grafted_variable_at_global_scope ... ok
test eval_grafted_variable_with_namespace ... ok
test cmd_dash_dash_arguments ... ok
test eval_root_with_root ... ok
test cmd_shell_variables ... ok
test eval_root_with_root_and_chdir ... ok
test cmd_breadth_first_and_depth_first ... ok
test cmd_no_errexit_for_command_lists ... ok
test eval_grafted_builtin_variables ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test cmd_prune_depth ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

test git_branches ... FAILED
fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

test eval_garden_config_dir ... FAILED
fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test eval_override_variables ... FAILED
test git_worktree_details ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_bare_repo_with_config ... FAILED
test cmd_pre_and_post_commands ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_branches_for_clone ... FAILED
test grow_bare_repo ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_branch_default ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone_shallow ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_clone_single_branch ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_default_remote_name ... FAILED
test grow_default_remote_url ... FAILED
test cmd_pre_and_post_nested_commands ... ok
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_gitconfig ... FAILED
test grow_gitconfig_append_value ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_symlinks ... FAILED
test grow_remotes ... FAILED
Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'nixbld@localhost.(none)')
test grow_worktree_and_parent ... FAILED
test cmd_keep_going_and_no_errexit ... ok

failures:

---- cmd_prune_depth stdout ----
thread 'cmd_prune_depth' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- git_branches stdout ----
thread 'git_branches' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- eval_garden_config_dir stdout ----
thread 'eval_garden_config_dir' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- eval_override_variables stdout ----
thread 'eval_override_variables' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- git_worktree_details stdout ----
thread 'git_worktree_details' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_bare_repo_with_config stdout ----
thread 'grow_bare_repo_with_config' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_branches_for_clone stdout ----
thread 'grow_branches_for_clone' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_bare_repo stdout ----
thread 'grow_bare_repo' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_branch_default stdout ----
thread 'grow_branch_default' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone stdout ----
thread 'grow_clone' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone_shallow stdout ----
thread 'grow_clone_shallow' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_clone_single_branch stdout ----
thread 'grow_clone_single_branch' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_default_remote_name stdout ----
thread 'grow_default_remote_name' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_default_remote_url stdout ----
thread 'grow_default_remote_url' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_gitconfig stdout ----
thread 'grow_gitconfig' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_gitconfig_append_value stdout ----
thread 'grow_gitconfig_append_value' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_symlinks stdout ----
thread 'grow_symlinks' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_remotes stdout ----
thread 'grow_remotes' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

---- grow_worktree_and_parent stdout ----
thread 'grow_worktree_and_parent' panicked at tests/common/mod.rs:171:5:
assertion `left == right` failed
  left: 128
 right: 0

failures:
    cmd_prune_depth
    eval_garden_config_dir
    eval_override_variables
    git_branches
    git_worktree_details
    grow_bare_repo
    grow_bare_repo_with_config
    grow_branch_default
    grow_branches_for_clone
    grow_clone
    grow_clone_shallow
    grow_clone_single_branch
    grow_default_remote_name
    grow_default_remote_url
    grow_gitconfig
    grow_gitconfig_append_value
    grow_remotes
    grow_symlinks
    grow_worktree_and_parent

test result: FAILED. 24 passed; 19 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.09s

error: test failed, to rerun pass `--test integration_test`

Possible approaches I can think of:

davvid commented 7 months ago

Hi Jordi, and thanks for the heads-up! I think we should be able to arrange to provide a gitconfig for use by the tests. We might be able to use git config commands inside of the temporary repositories we're creating and make sure they don't write to $HOME.

If that doesn't work then an environment variable should be able to handle it. I believe git supports $XDG_CONFIG_HOME so that might be another option.

davvid commented 7 months ago

https://gitlab.com/garden-rs/garden/-/blob/main/tests/integration/setup.sh?ref_type=heads#L24 is where we should be able to

git config user.name Garden
git config user.email garden@localhost

and then we won't interact with $HOME at all.

davvid commented 7 months ago

I knew this sounded familiar.. we had first run into this when setting up the .gitlab-ci.yml but the fix was regulated to just that entry point. Now we're fixing it in the tests directly. I should probably rewrite that shell script into a rust function in tests/common/mod.rs.

Thanks Jordi!

jordilin commented 7 months ago

Thanks @davvid - this fixed it :+1: