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

Unexpected input(s) 'commit' #64

Closed
RyanSchw opened this issue Dec 10, 2020 · 9 comments · Fixed by #65
Closed

Unexpected input(s) 'commit' #64

RyanSchw opened this issue Dec 10, 2020 · 9 comments · Fixed by #65
Assignees
Labels
enhancement New feature or request

Comments

@RyanSchw
Copy link

I'm running v1.6 and provided a git sha as shown in the README.

However, I get the following warning:

Warning: Unexpected input(s) 'commit', valid inputs are ['entryPoint', 'args', 'github_token', 'check_name', 'files', 'report_individual_runs', 'deduplicate_classes_by_file_name', 'hide_comments', 'comment_on_pr', 'log_level']
@EnricoMi
Copy link
Owner

Right, commit is an "undocumented" argument (though it is in the README). This is just a warning in the logs.

What is your use-case, maybe it is worth "documenting" it in the actions.yml.

@RyanSchw
Copy link
Author

Ah, gotcha.

Well for use case I'm using slash command dispatch to dispatch some jest tests. The comment is made on the PR (you would actually comment /test on the PR), and want to report the results of the test. Since the test command is technically launched from a repository_dispatch, there's no reference to the PR I want to comment on. I got around this by adding the git sha (of the HEAD of the PR branch) to the commit argument so that way this publish package knew where to publish the reports.

This is the result:
image

I would be happy to post a simple example YAML of my workflow if that helps illustrate my example more.

@EnricoMi
Copy link
Owner

Very interesting use-case, please add an example YAML file to see how this all wires together (especially the commit sha).

@RyanSchw
Copy link
Author

RyanSchw commented Dec 11, 2020

File that runs the jest tests:

name: Run jest tests

on:
  repository_dispatch:
    types: [e2e-command]

jobs:
  test_local:
    needs: build_local
    runs-on: ubuntu-latest
    steps:
    # repository_dispatch doesn't have the correct $GITHUB_REF so we need to provide it
    # first, get the name of the branch from the PR
    - name: Github API Request
      id: request
      uses: octokit/request-action@v2.0.0
      with:
        route: ${{ github.event.client_payload.github.payload.issue.pull_request.url }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    # then, check it out
    - uses: actions/checkout@v2
      with:
        ref: ${{ fromJson(steps.request.outputs.data).head.ref }}

    - name: Set up Node.js v13
      uses: actions/setup-node@v1
      with:
        node-version: '13.x'
    - name: Node install dependencies
      uses: bahmutov/npm-install@v1

    - name: Run tests
      run: |
        npm run serve &
        npm test ${{ github.event.client_payload.slash_command.args.unnamed.all }}

    - name: Publish test results
      uses: EnricoMi/publish-unit-test-result-action@v1.6
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        files: test/results/*.xml
        report_individual_runs: true
        commit: ${{ fromJson(steps.request.outputs.data).head.sha }}

Dispatch file:

name: Slash Command Dispatch
on:
  issue_comment:
    types: [created]
jobs:
  slashCommandDispatch:
    runs-on: ubuntu-latest
    steps:
      - name: Slash Command Dispatch
        uses: peter-evans/slash-command-dispatch@v2
        with:
          token: ${{ secrets.PAT }}
          commands: |
            e2e

Then, in a PR, you can comment /e2e xxx to run npm test xxx. The comment will launch the dispatch file which in turn will do a repository dispatch action of type e2e-command.

@EnricoMi
Copy link
Owner

This is an excellent use case for the commit argument. I am glad I haven't removed it. Thanks for the reference yaml, I find this is a very useful setup.

Please try the action from this branch:

uses: EnricoMi/publish-unit-test-result-action@branch-commit-arg-in-action-yaml

Let me know if the warning goes away.

@EnricoMi EnricoMi self-assigned this Dec 14, 2020
@EnricoMi EnricoMi added the enhancement New feature or request label Dec 14, 2020
@EnricoMi
Copy link
Owner

@RyanSchw any chance to test the action from this branch?

@RyanSchw
Copy link
Author

I lost access to the repo that was running that CICD pipeline. I think the warning went away when it ran, though. Sorry I can’t be more helpful.

@EnricoMi
Copy link
Owner

Thanks for insights, fix is merged!

@rwader-swi
Copy link

can I get reports in comment for a workflow_dispatch event? I've also mentioned the commit parameter as head SHA of PR? Should I mentioning it as head of workflow event?

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

Successfully merging a pull request may close this issue.

3 participants