Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: make GYB setup executable and GYB on path #14

Merged
merged 3 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .devcontainer/postAttach.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
set -eu

pre-commit install --install-hooks

echo -e "\nexport PATH=$PATH:/home/compiler/admin/.config/gyb" >> ~/.bashrc
10 changes: 6 additions & 4 deletions compiler_admin/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def init(args: Namespace) -> int:
See https://github.com/taers232c/GAMADV-XTD3/wiki/How-to-Install-Advanced-GAM

Args:
admin_user (str): The Compiler admin with which to initialize a new project.
username (str): The Compiler admin with which to initialize a new project.

gam (bool): If True, initialize a new GAM project.

Expand All @@ -37,10 +37,10 @@ def init(args: Namespace) -> int:
Returns:
A value indicating if the operation succeeded or failed.
"""
if not hasattr(args, "admin_user"):
raise ValueError("admin_user is required")
if not hasattr(args, "username"):
raise ValueError("username is required")

admin_user = args.admin_user
admin_user = args.username
res = RESULT_SUCCESS

if getattr(args, "gam", False):
Expand All @@ -58,6 +58,8 @@ def init(args: Namespace) -> int:
with gyb.open("w+") as dest:
res += subprocess.call(("curl", "-s", "-S", "-L", "https://gyb-shortn.jaylee.us/gyb-install"), stdout=dest)

res += subprocess.call(("chmod", "+x", str(gyb.absolute())))

# install, giving values to some options
# https://github.com/GAM-team/got-your-back/blob/main/install-gyb.sh
#
Expand Down
8 changes: 4 additions & 4 deletions tests/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ def test_clean_config_dir(mocker, mock_GAM_CONFIG_PATH, mock_rmtree):
def test_init_admin_user_required():
args = Namespace()

with pytest.raises(ValueError, match="admin_user is required"):
with pytest.raises(ValueError, match="username is required"):
init(args)


def test_init_default(mock_clean_config_dir, mock_google_CallGAMCommand, mock_subprocess_call):
args = Namespace(admin_user="username")
args = Namespace(username="username")
init(args)

assert mock_clean_config_dir.call_count == 0
Expand All @@ -69,7 +69,7 @@ def test_init_default(mock_clean_config_dir, mock_google_CallGAMCommand, mock_su


def test_init_gam(mock_GAM_CONFIG_PATH, mock_clean_config_dir, mock_google_CallGAMCommand):
args = Namespace(admin_user="username", gam=True, gyb=False)
args = Namespace(username="username", gam=True, gyb=False)
init(args)

mock_clean_config_dir.assert_called_once()
Expand All @@ -78,7 +78,7 @@ def test_init_gam(mock_GAM_CONFIG_PATH, mock_clean_config_dir, mock_google_CallG


def test_init_gyb(mock_GYB_CONFIG_PATH, mock_clean_config_dir, mock_subprocess_call):
args = Namespace(admin_user="username", gam=False, gyb=True)
args = Namespace(username="username", gam=False, gyb=True)
init(args)

mock_clean_config_dir.assert_called_once()
Expand Down
Loading