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

Testing .github/workflows/test-report.yml in public repos #423

Open
brianjmurrell opened this issue Apr 9, 2024 · 2 comments
Open

Testing .github/workflows/test-report.yml in public repos #423

brianjmurrell opened this issue Apr 9, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@brianjmurrell
Copy link

Describe

Hello.

Per your description for Recommended setup for public repositories how does the artifact: option know which triggering run to go fetch the artifacts from?

More to the point however, is do you have any advise on how one can test/debug their implementation of .github/workflows/test-report.yml in a PR -- without having to iterate on landing updates to make it work to the master branch?

I have tried adding on: -> workflow_dispatch to my .github/workflows/test-report.yml and then running the workflow manually but that manual run doesn't find artifacts to report on, I suppose because it has no linkage back to a .github/workflows/ci.yml that uploaded artifacts?

Proposed solution

I suppose it's this (NPI):

const resp = await this.octokit.rest.actions.listWorkflowRunArtifacts({
...github.context.repo,
run_id: this.runId
})

When run from a workflow_run trigger, I am guessing that this is the triggering workflow run but when run from a workflow_dispatch trigger, it is it's self.

Any thoughts on being able to make this action simulate a workflow_run trigger by being able to provide a run id value for

when triggered from a workflow_dispatch with an input perhaps?

Or am I barking up the completely wrong tree here in trying to test my .github/workflows/test-report.yml before merging it to the default branch and there is a better way?

Alternatives considered

Not sure of any other alternatives.

@brianjmurrell brianjmurrell added the enhancement New feature or request label Apr 9, 2024
@JojOatXGME
Copy link
Contributor

I haven't tried it, but wouldn't it be possible to create another workflow which triggers both of these workflows.

  1. Add the following trigger to both, ci.yml and test-report.yml.

    on:
      workflow_call:
  2. Add a third workflow to test the report creation:

    name: Test Creation of Test Report
    
    on:
      push:
        branches-ignore: [ 'master' ]
        paths:
          - .github/workflows/ci.yml
          - .github/workflows/test-report.yml
      workflow_dispatch:
    
    jobs:
      ci:
    
        uses: ./.github/workflows/ci.yml
    
      test-report:
    
        uses: ./.github/workflows/test-report.yml

As this would run both actions in the same top-level workflow, I would expect the fallback to the ID of the current workflow run to work just fine.

@JojOatXGME
Copy link
Contributor

JojOatXGME commented May 8, 2024

I just realized that my suggestion doesn't work with actions/upload-artifact@v3 or older. However, it should work with actions/upload-artifact@v4 when #363 has been resolved. (Maybe it has been resolved already.) The problem is that with actions/upload-artifact@v3 and older, artifacts are not available over the REST API (which is used by this action) as long as the workflow is still in progress.

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

No branches or pull requests

5 participants