eed-web-application / core-build-system

0 stars 0 forks source link

Add endpoint for issue creation #27

Closed pnispero closed 2 weeks ago

github-actions[bot] commented 3 weeks ago
Overall Project 66.88% -1.51% :green_apple:
Files changed 0% :x:


File Coverage
ComponentMapper.java 100% :green_apple:
ComponentService.java 63.25% -6.59% :x:
ComponentController.java 53.13% -10.94% :x:
GithubServerRepository.java 8.26% -11.4% :x:
pnispero commented 3 weeks ago

Still need to write tests for this issue creation endpoint

pnispero commented 3 weeks ago

Finished writing the logic for the issue creation, I created a test to go along with it, but I can't seem to get it working.

  1. The api controller works fine, but the function addIssue() in repository/GithubServerRepostory.java is where it bugs out.
  2. I stepped through the code, and found on line GHRepository repo = ghInstancer.ghOrganization(coreBuildProperties.getGithubOrgName()).getRepository(component.getName()); I get a null repo.
  3. It get's a null repo because it is grabbing the wrong organization, (it's supposed to be organization-a, not ad-build-test)
  4. @bisegni, I was wondering how did you avoid this issue (the enableEvent() also uses that GHRepository class)? See screenshots for detail. Screenshots: image_720

image_720

image_720

bisegni commented 3 weeks ago

is organization a new field? anyway good to know, i add a default parameter to have a default organization value. so to be conservative with the past i suggest this fix:

var orgName = component.organization()==null?coreBuildProperties.getGithubOrgName():component.organization();
GHRepository repo = ghInstancer.ghOrganization(orgName).getRepository(component.getName());

so in case the organization is null it will get the default one configurad with thi paramter:

edu:
  stanford:
    slac:
      core-build-system:
          github-org-name: ${CBS_GH_ORG_NAME:ad-build-test}

remember each organization should authorize the github application used by the backend to read the repository and create pull request

pnispero commented 2 weeks ago

Update

  1. So I forced the organization name to be organization-a, but that did not solve the issue. I am still getting a null GHOrganization and in turn a null GHRepository.
  2. I tried to compare with existing functions that use GHOrganization, but unfortunately it seems like none of the functions are being called during the tests, and there is a test/.../repository/GithubRepositoryTest.java that has a test to call those existing functions, but its commented out, so seems like any GHOrganization functionality hasn't been actually tested if it works.
  3. TODO: Going to try just building a test image of this, then deploy it, and actually call it with ad-build-test, test-ioc repo. Since the mock java tests aren't working, it may be tough to actually test it since you have to make an actual github repo.
pnispero commented 2 weeks ago

Update

For now, I will omit the test since can't get it to work right. But the endpoint itself works, I've tested it with a dev-release on a real repository test-ioc on ad-build-test organization.

  1. Curl Request image

  2. Actual issue created on the test-ioc repository image

bisegni commented 2 weeks ago

Have you configured, before running the test, the GitHub app env variables? If not, it won’t work. Deploying and testing should work

github-actions[bot] commented 2 weeks ago
Overall Project 66.76% -1.68% :green_apple:
Files changed 0% :x:


File Coverage
ComponentMapper.java 100% :green_apple:
ComponentService.java 63.17% -6.71% :x:
ComponentController.java 53.13% -10.94% :x:
GithubServerRepository.java 8.01% -14.09% :x:
github-actions[bot] commented 2 weeks ago
Overall Project 65.83% -4.07% :green_apple:
Files changed 0% :x:


File Coverage
ComponentMapper.java 100% :green_apple:
ComponentService.java 63.17% -6.71% :x:
ComponentController.java 53.13% -10.94% :x:
GithubServerRepository.java 6.36% -47.15% :x: