hipstersmoothie/jest-github-reporter

Reporter says that app is not installed

Opened this issue · 5 comments

Hello! I have my own teamcity server. And reporter says:

It looks like you don't have the "Jest Results" Github App installed to your repo! https://github.com/apps/jest-results

Here is PR with integration: https://github.com/Dekkee/tuktuk-scg-scrapper/pull/17/files
App is installed:
image
Tried to make my own app as shown in readme.md, but error is the same.

As I see, it happens due to bad credentials: https://github.com/hipstersmoothie/create-check/blob/68da97dd5f59acf2cea7c156c60b71acfb20643a/src/index.ts#L85
But it happens even with your hard-coded key.

What did I miss? Thanks!

I found an issue. It was because of this line: https://github.com/hipstersmoothie/create-check/blob/68da97dd5f59acf2cea7c156c60b71acfb20643a/src/index.ts#L10
My CI (TeamCity) doesn't have owner and repo information, so I pass them via Environment Variables.
I think it should be mentioned in README

I need your explanation about your CI. Because in my case slug looks like:
image
In this case first argument is truthy and owner becomes 'Test' (it is name of my job), but second argument is falsy and it becomes process.env.REPO.

I think it could be more universal solution.
Module create-check is a github-only tool as the terms REPO and OWNER are github-only too.
So we can take them from repo url taken by git remote get-url origin.
This solution is CI independent and can run locally, because repo url will be the same.
URL pattern for all repos will be the same, so we can extract by regExp.

Explanation:

const { exec } = require('child_process');
const regex = /https?:\/\/.*\/(.+)\/(.+)\.git/;
exec('git remote get-url origin', (err, stdout) => {
    // stdout = https://github.com/owner/repo.git
    const [, owner = process.env.OWNER, repo = process.env.REPO] = stdout.match(regex) || [];
    console.log('=== rev-parse', owner, repo, stdout);
});

Sandbox with the mock: https://repl.it/repls/TremendousMoccasinCrypto

If its ok for you, I will wake PR to https://github.com/hipstersmoothie/create-check first, and then to reporter.

Something like that: hipstersmoothie/create-check#70

There are still issues with the plugin, but I just set OWNER/REPO environment variables