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

Allow non-"build" name #3

Open
MPV opened this issue May 28, 2020 · 14 comments
Open

Allow non-"build" name #3

MPV opened this issue May 28, 2020 · 14 comments

Comments

@MPV
Copy link

MPV commented May 28, 2020

I ran into this when trying out this action:

Run ashley-taylor/[email protected]
  with:
    access-token: ***
    path: target/surefire-reports/*.xml
    includeSummary: true
    numFailures: 10
    testSrcPath: src/test/java/
  env:
    GITHUB_TOKEN: ***
    JAVA_HOME: /runner/.jabba/jdk/[email protected]
##[error]Cannot read property 'id' of undefined

Skärmavbild 2020-05-28 kl  12 15 34

Looking at the code of this action, could it be because it assumes the "check" is expected to be named "build"?

const check_run_id = res.data.check_runs.filter(check => check.name === 'build')[0].id

https://github.com/ashley-taylor/junit-report-annotations-action/blob/master/index.js#L88

@ashley-taylor
Copy link
Owner

have made a new version ashley-taylor/[email protected]
It reads the job id from an env variable no longer hard coded.

If it still does not work would you mind doing one run using @master as the version?
It should output some debug info so I will be able to understand why its not working.
If you could update this ticket with that output would be great.

@MPV
Copy link
Author

MPV commented May 29, 2020

Indeed 1.2 isn't there yet:

Current runner version: '2.263.0'
Prepare workflow directory
Prepare all required actions
Download action repository 'actions/checkout@v2'
Download action repository 'olafurpg/setup-scala@v5'
Download action repository 'actions/cache@v1'
Download action repository 'ashley-taylor/[email protected]'
##[error]An action could not be found at the URI 'https://api.github.com/repos/ashley-taylor/junit-report-annotations-action/tarball/v1.1'

So I tried with @master, there I'm getting:

Run ashley-taylor/junit-report-annotations-action@master
  with:
    access-token: ***
    path: target/surefire-reports/*.xml
    includeSummary: true
    numFailures: 10
    testSrcPath: src/test/java/
  env:
    GITHUB_TOKEN: ***
    JAVA_HOME: /runner/.jabba/jdk/[email protected]
{
    "ACTIONS_CACHE_URL": "https://artifactcache.actions.githubusercontent.com/JXFXmkDTLNA9dlq4VskGeHLtjNSJaOGpucslM47meKA7vFGXPd/"
    "ACTIONS_RUNTIME_TOKEN":***,
    "ACTIONS_RUNTIME_URL": "https://pipelines.actions.githubusercontent.com/JXFXmkDTLNA9dlq4VskGeHLtjNSJaOGpucslM47meKA7vFGXPd/",
    "CI": "true",
    "DEBIAN_FRONTEND": "noninteractive",
    "DOCKER_HOST": "tcp://localhost:2375",
    "DOCKER_IP": "172.17.0.1",
    "DOCKER_REGISTRY": "REDACTED",
    "GH_ORG": "REDACTED",
    "GH_TOKEN": "REDACTED",
    "GITHUB_ACTION": "ashley-taylorjunit-report-annotations-action",
    "GITHUB_ACTIONS": "true",
    "GITHUB_ACTOR": "MPV",
    "GITHUB_BASE_REF": "master",
    "GITHUB_EVENT_NAME": "pull_request",
    "GITHUB_EVENT_PATH": "/runner/_work/_temp/_github_workflow/event.json",
    "GITHUB_HEAD_REF": "github-actions-self-hosted-junit-annotations",
    "GITHUB_JOB": "build",
    "GITHUB_REF": "refs/pull/26/merge",
    "GITHUB_REPOSITORY": "REDACTED",
    "GITHUB_REPOSITORY_OWNER": "REDACTED",
    "GITHUB_RUN_ID": "118731344",
    "GITHUB_RUN_NUMBER": "35",
    "GITHUB_SHA": "REDACTED",
    "GITHUB_TOKEN": "***",
    "GITHUB_WORKFLOW": "Continuous Integration",
    "GITHUB_WORKSPACE": "/runner/_work/example-service/example-service",
    "HOME": "/runner",
    "HOSTNAME": "runner-pod-REDACTED",
    "INPUT_ACCESS-TOKEN": "***",
    "INPUT_INCLUDESUMMARY": "true",
    "INPUT_NUMFAILURES": "10",
    "INPUT_PATH": "target/surefire-reports/*.xml",
    "INPUT_TESTSRCPATH": "src/test/java/",
    "JAVA_HOME": "/runner/.jabba/jdk/[email protected]",
    "KUBERNETES_PORT": "tcp://10.66.64.1:443",
    "KUBERNETES_PORT_443_TCP": "tcp://10.66.64.1:443",
    "KUBERNETES_PORT_443_TCP_ADDR": "10.66.64.1",
    "KUBERNETES_PORT_443_TCP_PORT": "443",
    "KUBERNETES_PORT_443_TCP_PROTO": "tcp",
    "KUBERNETES_SERVICE_HOST": "10.66.64.1",
    "KUBERNETES_SERVICE_PORT": "443",
    "KUBERNETES_SERVICE_PORT_HTTPS": "443",
    "LANG": "C.UTF-8",
    "PATH": "/runner/bin:/runner/.jabba/jdk/[email protected]/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    "PWD": "/runner",
    "RUNNER_DEBUG": "true",
    "RUNNER_LABELS": "gke",
    "RUNNER_OS": "Linux",
    "RUNNER_TEMP": "/runner/_work/_temp",
    "RUNNER_TOOL_CACHE": "/runner/_work/_tool",
    "RUNNER_TRACKING_ID": "github_a34ff831-ff44-4a5e-b061-868977041afa",
    "RUNNER_WORKSPACE": "/runner/_work/example-service",
    "SHLVL": "1",
    "_": "/runner/bin/Runner.Listener",
}
[]
##[error]Cannot read property 'id' of undefined

@MPV
Copy link
Author

MPV commented May 29, 2020

Could it be that what you get in GITHUB_JOB isn't a name, but an ID?

I'm thinking that the code might be currently comparing these two?

jobs.<job_id> vs
jobs.<job_id>.name

@MPV
Copy link
Author

MPV commented May 29, 2020

Although, I'm not sure why there wasn't any output logged from:

console.log(JSON.stringify(res.data.check_runs))

(as you see from the next-to-last line logged with [] above)

@ashley-taylor
Copy link
Owner

Think I can see the cause. Is because is a pull request. Not just a push. Will have a look later.

@MPV
Copy link
Author

MPV commented May 29, 2020

Ah, nice find!

I'll give this a try too:

Skärmavbild 2020-05-29 kl  16 12 57

@MPV
Copy link
Author

MPV commented May 29, 2020

Not much better at first glance, I'm afraid:

Skärmavbild 2020-05-29 kl  16 15 56

Skärmavbild 2020-05-29 kl  16 16 22

Need to break for week-end, but I'll try to get back with debug details too, likely next week at earliest though.

@MPV
Copy link
Author

MPV commented Jun 4, 2020

@ashley-taylor Here's when I ran this on push (from my last comment above):

[
    {
        "id": 720625993,
        "node_id": "MDg6Q2hlY2tSdW43MjA2MjU5OTM=",
        "head_sha": "129bd843e23bbf9289e88ba6a018be9ce36b09e9",
        "external_id": "cfc9dbcb-a267-518e-5867-d1492fc1c90e",
        "url": "https://api.github.com/repos/my-org/example-service/check-runs/720625993",
        "html_url": "https://github.com/my-org/example-service/runs/720625993",
        "details_url": "https://github.com/my-org/example-service/runs/720625993",
        "status": "completed",
        "conclusion": "success",
        "started_at": "2020-05-29T14:12:18Z",
        "completed_at": "2020-05-29T14:12:19Z",
        "output": {
            "title": null,
            "summary": null,
            "text": null,
            "annotations_count": 0,
            "annotations_url": "https://api.github.com/repos/my-org/example-service/check-runs/720625993/annotations"
        },
        "name": "Delete Artifacts",
        "check_suite": {
            "id": 733437370
        },
        "app": {
            "id": 15368,
            "slug": "github-actions",
            "node_id": "MDM6QXBwMTUzNjg=",
            "owner": {
                "login": "github",
                "id": 9919,
                "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
                "avatar_url": "https://avatars1.githubusercontent.com/u/9919?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github",
                "html_url": "https://github.com/github",
                "followers_url": "https://api.github.com/users/github/followers",
                "following_url": "https://api.github.com/users/github/following{/other_user}",
                "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github/subscriptions",
                "organizations_url": "https://api.github.com/users/github/orgs",
                "repos_url": "https://api.github.com/users/github/repos",
                "events_url": "https://api.github.com/users/github/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github/received_events",
                "type": "Organization",
                "site_admin": false
            },
            "name": "GitHub Actions",
            "description": "Automate your workflow from idea to production",
            "external_url": "https://help.github.com/en/actions",
            "html_url": "https://github.com/apps/github-actions",
            "created_at": "2018-07-30T09:30:17Z",
            "updated_at": "2019-12-10T19:04:12Z",
            "permissions": {
                "actions": "write",
                "checks": "write",
                "contents": "write",
                "deployments": "write",
                "issues": "write",
                "metadata": "read",
                "packages": "write",
                "pages": "write",
                "pull_requests": "write",
                "repository_hooks": "write",
                "repository_projects": "write",
                "security_events": "write",
                "statuses": "write",
                "vulnerability_alerts": "read"
            },
            "events": [
                "check_run",
                "check_suite",
                "create",
                "delete",
                "deployment",
                "deployment_status",
                "fork",
                "gollum",
                "issues",
                "issue_comment",
                "label",
                "milestone",
                "page_build",
                "project",
                "project_card",
                "project_column",
                "public",
                "pull_request",
                "pull_request_review",
                "pull_request_review_comment",
                "push",
                "registry_package",
                "release",
                "repository",
                "repository_dispatch",
                "status",
                "watch"
            ]
        },
        "pull_requests": [
            {
                "url": "https://api.github.com/repos/my-org/example-service/pulls/26",
                "id": 424923173,
                "number": 26,
                "head": {
                    "ref": "github-actions-self-hosted-junit-annotations",
                    "sha": "129bd843e23bbf9289e88ba6a018be9ce36b09e9",
                    "repo": {
                        "id": 215329298,
                        "url": "https://api.github.com/repos/my-org/example-service",
                        "name": "example-service"
                    }
                },
                "base": {
                    "ref": "master",
                    "sha": "62af8ed9862efe1979b8e075128c6f84b86ff3ff",
                    "repo": {
                        "id": 215329298,
                        "url": "https://api.github.com/repos/my-org/example-service",
                        "name": "example-service"
                    }
                }
            }
        ]
    },
    {
        "id": 720625955,
        "node_id": "MDg6Q2hlY2tSdW43MjA2MjU5NTU=",
        "head_sha": "129bd843e23bbf9289e88ba6a018be9ce36b09e9",
        "external_id": "87183d11-15b6-51be-c26d-2b47679083ca",
        "url": "https://api.github.com/repos/my-org/example-service/check-runs/720625955",
        "html_url": "https://github.com/my-org/example-service/runs/720625955",
        "details_url": "https://github.com/my-org/example-service/runs/720625955",
        "status": "in_progress",
        "conclusion": null,
        "started_at": "2020-05-29T14:12:15Z",
        "completed_at": null,
        "output": {
            "title": null,
            "summary": null,
            "text": null,
            "annotations_count": 0,
            "annotations_url": "https://api.github.com/repos/my-org/example-service/check-runs/720625955/annotations"
        },
        "name": "Build and Test (self-hosted, 2.13.2, [email protected])",
        "check_suite": {
            "id": 733437335
        },
        "app": {
            "id": 15368,
            "slug": "github-actions",
            "node_id": "MDM6QXBwMTUzNjg=",
            "owner": {
                "login": "github",
                "id": 9919,
                "node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
                "avatar_url": "https://avatars1.githubusercontent.com/u/9919?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/github",
                "html_url": "https://github.com/github",
                "followers_url": "https://api.github.com/users/github/followers",
                "following_url": "https://api.github.com/users/github/following{/other_user}",
                "gists_url": "https://api.github.com/users/github/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/github/subscriptions",
                "organizations_url": "https://api.github.com/users/github/orgs",
                "repos_url": "https://api.github.com/users/github/repos",
                "events_url": "https://api.github.com/users/github/events{/privacy}",
                "received_events_url": "https://api.github.com/users/github/received_events",
                "type": "Organization",
                "site_admin": false
            },
            "name": "GitHub Actions",
            "description": "Automate your workflow from idea to production",
            "external_url": "https://help.github.com/en/actions",
            "html_url": "https://github.com/apps/github-actions",
            "created_at": "2018-07-30T09:30:17Z",
            "updated_at": "2019-12-10T19:04:12Z",
            "permissions": {
                "actions": "write",
                "checks": "write",
                "contents": "write",
                "deployments": "write",
                "issues": "write",
                "metadata": "read",
                "packages": "write",
                "pages": "write",
                "pull_requests": "write",
                "repository_hooks": "write",
                "repository_projects": "write",
                "security_events": "write",
                "statuses": "write",
                "vulnerability_alerts": "read"
            },
            "events": [
                "check_run",
                "check_suite",
                "create",
                "delete",
                "deployment",
                "deployment_status",
                "fork",
                "gollum",
                "issues",
                "issue_comment",
                "label",
                "milestone",
                "page_build",
                "project",
                "project_card",
                "project_column",
                "public",
                "pull_request",
                "pull_request_review",
                "pull_request_review_comment",
                "push",
                "registry_package",
                "release",
                "repository",
                "repository_dispatch",
                "status",
                "watch"
            ]
        },
        "pull_requests": []
    }
]

@MPV
Copy link
Author

MPV commented Jun 4, 2020

Does that give any ideas on what the problem is?

@ashley-taylor
Copy link
Owner

I have not forgotten about this.
I have enough info to recreate is just not as straight forward as I was hoping.
Need to call different endpoints depending on what type of job it is.

@moul
Copy link

moul commented Jun 22, 2020

@ashley-taylor
Copy link
Owner

can you try the latest version 1.2
When a PR comes in from a remote branch is some limits about what is allowed via the API.
On a failure build can log the warning to the console in a particular format that get picked up as annotations.
On a successful build from a remote branch can not log a notice annotation so currently log nothing.
Will give the summary on success if it has API access. So local commits and pull should hopefully get the summary

@ashley-taylor
Copy link
Owner

have changed how these report back to github.
Could you try switch the version of this plugin to @master and run it and tell me if it fixes your issue.
Please don't leave it on the @master version
If so will build a release with the change.

@jmosul
Copy link

jmosul commented Jul 22, 2020

@ashley-taylor we're just tried @master on our builds and it worked fine for our PHPUnit tests.

Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants