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

Restore test_run_ci_on_github_repo.bats #72

Open
5 of 11 tasks
a-t-0 opened this issue Feb 13, 2022 · 2 comments
Open
5 of 11 tasks

Restore test_run_ci_on_github_repo.bats #72

a-t-0 opened this issue Feb 13, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@a-t-0
Copy link
Member

a-t-0 commented Feb 13, 2022

Restore the tests in test_run_ci_on_github_repo.bats in the updated code, which has been restructured and improved towards Google Bash Style guide compliance. This requires some effort. The first test of this file passes. Currently the second test is being restored:

@test "Test copying github branches with yaml to GitLab repo." {
	local github_username="a-t-0"
	local github_repo_name="sponsor_example"
	
	# Delete the repository locally if it exists.
	remove_dir "$MIRROR_LOCATION/GitHub/$github_repo_name"
	manual_assert_dir_not_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"

	# TODO: change this method to download with https?
	# Download the GitHub repo on which to run the GitLab CI:
	download_github_repo_on_which_to_run_ci "$github_username" "$github_repo_name"
	manual_assert_dir_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"
	
	repo_was_cloned=$(verify_github_repository_is_cloned "$github_repo_name" "$MIRROR_LOCATION/GitHub/$github_repo_name")
	assert_equal "$repo_was_cloned" "FOUND"

	copy_github_branches_with_yaml_to_gitlab_repo "$github_username" "$github_repo_name"
	# TODO: write some assert to verify yamls are copied to GitLab repo.
	

	# Delete the repository locally if it exists.
	remove_dir "$MIRROR_LOCATION/GitHub/$github_repo_name"
	manual_assert_dir_not_exists "$MIRROR_LOCATION/GitHub/$github_repo_name"
}

An issue in this test is that it requires using the GitLab personal access token, which has not yet been generated by the .install_gitlab.sh -s -r command. This test requires that token because it runs:

copy_github_branches_with_yaml_to_gitlab_repo

From

run_ci_on_github_repo.sh

which calls:

get_project_list(){

which asks the repositories from the GitLab API using the GitLab personal access token. Additionally, the function to manually create this token:

create_gitlab_personal_access_token()

in file: create_personal_access_token.sh throws an error.

Solution

  • First ensure the create_gitlab_personal_access_token() works.
  • Manually verify it works.
  • Then manually verify get_project_list(){ works.
  • Then manually verify copy_github_branches_with_yaml_to_gitlab_repo() { works.
  • # TODO: determine why
			#  The commit:aeaaa57120f74a695ef4215e819a175296a3de10 does not yet have a build status, and it DOES have a GitLab yaml.
			# even though the gitlab-ci-build-statuses repository does have that build status.
  • Then restore the remainder of the tests.

  • Then create/call the receipe to run this GitLab CI on GitHub from `./install_gitlab.sh -s -r

  • Then create a function that loops over all the repositories of a GitHub user and runs the CI on them

  • Then create a monitoring script that detects changes in the GitHub repo and runs the CI on them.

  • Create a separate issue to: Write a test that verifies create_gitlab_personal_access_token() works.

  • Create a separate issue to verify/ensure (and test) that the install_gitlab.sh -s -r command automatically generates this GitLab token. Ps. I expect that the code does do that automatically (if it works) but that it fails at doing so because of the error that is thrown by the create_gitlab_personal_access_token() function. So perhaps before creating a call to the function, see if such a call already exists.

@a-t-0 a-t-0 self-assigned this Feb 13, 2022
@a-t-0
Copy link
Member Author

a-t-0 commented Feb 13, 2022

Remove get_last_line_of_set_of_lines as it evaluates the incoming lines.

@a-t-0 a-t-0 added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Feb 15, 2022
@a-t-0
Copy link
Member Author

a-t-0 commented Feb 15, 2022

See #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant