Skip to content

Conversation

@filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Nov 13, 2024

Description

Looks like we haven't run these in a while (at least a year and a half), and they needed some love. This PR provides that love.

How to test

Run the GitHub integrations tests in server

export GITPOD_TEST_TOKEN_GITHUB='{"username": "gitpod-integration-test", "value": "ghp_..."}'
cd components/server
yarn mocha './**/*.spec.js' --exclude './node_modules/**' --exit

The token is in 1Password.

Related issue(s)

Fixes CLC-930

/hold


@test public async testGetUserRepos() {
const result = await this.provider.getUserRepos(this.user);
expect(result).to.include({ url: "https://github.com/gitpod-io/gitpod", name: "gitpod" });
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub seemingly only considers recent contributions, who knew!

for (const type of ["contributedTo", "original", "forked"]) {
const nodes = result.data.viewer[type]?.nodes;
if (nodes) {
repos = nodes.map((n: any): RepositoryInfo => {
Copy link
Member Author

@filiptronicek filiptronicek Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was actually a bug where we always rewrote the existing array if there were nodes for a type. Unlucky for us, even if there weren't, empty JS arrays are truthy, so the repos would get overridden anyway.

const result = await this.parser.handle(
{},
this.user,
"https://github.com/eclipse-theia/theia/tree/master/LICENSE",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file disappeared, so we had to update it.

Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @filiptronicek

$ yarn build && yarn mocha 'dist/github/**/*.spec.js' --exclude './node_modules/**' --exit
...

  TestFileProvider
GitHub request took 227 ms
    ✔ testFileContent (228ms)

  TestGithubContextRepositoryProvider
    ✔ testFetchCommitHistory (280ms)
    ✔ testGetUserRepos (241ms)


  29 passing (8s)

Done in 8.80s.

@roboquat roboquat merged commit 177367e into main Nov 14, 2024
31 checks passed
@roboquat roboquat deleted the ft/fix-github-tests branch November 14, 2024 07:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants