Giter Club home page Giter Club logo

Comments (9)

EnricoMi avatar EnricoMi commented on May 18, 2024

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.

from publish-unit-test-result-action.

RyanSchw avatar RyanSchw commented on May 18, 2024

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.

from publish-unit-test-result-action.

EnricoMi avatar EnricoMi commented on May 18, 2024

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

from publish-unit-test-result-action.

RyanSchw avatar RyanSchw commented on May 18, 2024

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/[email protected]
      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/[email protected]
      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.

from publish-unit-test-result-action.

EnricoMi avatar EnricoMi commented on May 18, 2024

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.

from publish-unit-test-result-action.

EnricoMi avatar EnricoMi commented on May 18, 2024

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

from publish-unit-test-result-action.

RyanSchw avatar RyanSchw commented on May 18, 2024

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.

from publish-unit-test-result-action.

EnricoMi avatar EnricoMi commented on May 18, 2024

Thanks for insights, fix is merged!

from publish-unit-test-result-action.

rwader-swi avatar rwader-swi commented on May 18, 2024

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?

from publish-unit-test-result-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.