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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report enhancements #96

Merged
merged 5 commits into from
Apr 21, 2024
Merged

Report enhancements #96

merged 5 commits into from
Apr 21, 2024

Conversation

joshjohanning
Copy link
Contributor

馃摑 Summary

This pull request primarily focuses on two files: .github/workflows/scorecard.yml and utils/reporting.js. The changes in the .github/workflows/scorecard.yml file are minor, with a shift from double quotes to single quotes for string literals. The changes in the utils/reporting.js file are more substantial, with updates to the handling of workflow state data and the formatting of action URLs.

Changes to .github/workflows/scorecard.yml:

  • Replaced double quotes with single quotes for string literals in various sections of the file. [1] [2] [3] [4]

Updates to utils/reporting.js:

  • Added a fallback value of 'workflows not enabled in fork' for the state property in the csvData array and in other areas of the code. [1] [2] [3]
  • Adjusted the handling of action URLs to account for local actions and actions from GitHub. This included splitting the action into different components, checking the URL, and formatting the final URL string.

馃攳 Details

1. fix: .com workflow link in md report

If you are pulling in workflows from .com, the url in the markdown was https://undefined/org/repo...

Like this:

[.github/workflows/nuget-publish.yml](https://undefined/joshjohanning-test-gei-deleteme-2/Wolfringo-github-packages/blob/HEAD/.github/workflows/nuget-publish.yml)

This worked correctly as-is for GHES, though (and tested to work still after the change).

2. feat: support local actions in md report

Local actions showed up in the CSV and JSON reports, and I added some logic to bring in local actions to the MD report. It uses "(local)" as the version instead of the ref/tag that regular actions use. The local action links to the directory in the repo where the action is stored.

A local action will look like this in the report:

  • [tspascoal/cobertura-action](https://github.com/tspascoal/cobertura-action) (`master`)
  • [actions/upload-artifact](https://github.com/actions/upload-artifact) (`v2`)
  • [./actions/provision-and-deploy](https://github.com/joshjohanning-org-test/MyShuttle/blob/HEAD/./actions/provision-and-deploy) (`local`)
  • image

    3. feat: note in state if workflows are disabled

    I was trying to figure out why some workflows were showing undefined for things like name and state. Originally I thought it was just because they had never been run before since the created_at and updated_at was also undefined, but I was still curious why the name property would return back undefined.

    I think the cause of this is that with forks, if you don't enable workflows to be run against the repository, the API returns empty

    image
    gh api /repos/joshjohanning-org-test/export-actions-usage-report/actions/workflows
    {
      "total_count": 0,
      "workflows": []
    }
    

    I'm adding the Workflows not enabled in fork to the status field in this case.

    image

    4. style: run prettier

    馃敆 Related Issues

    @joshjohanning
    Copy link
    Contributor Author

    There might have been a better way to do # 3 feat: note in state if workflows are disabled as opposed to setting it individually for each save csv, json, and markdown functions, but without refactoring the code I didn't see anywhere obvious since the workflow API returns empty and thus this line never gets hit.

    # Conflicts:
    #	.github/workflows/scorecard.yml
    @stoe stoe added the feature-request 馃毀 Want something new? label Apr 21, 2024
    @stoe
    Copy link
    Owner

    stoe commented Apr 21, 2024

    Thanks for the contributions @joshjohanning

    @stoe
    Copy link
    Owner

    stoe commented Apr 21, 2024

    There might have been a better way to do # 3 feat: note in state if workflows are disabled as opposed to setting it individually for each save csv, json, and markdown functions, but without refactoring the code I didn't see anywhere obvious since the workflow API returns empty and thus this line never gets hit.

    I agree, but your changes look great here.

    @stoe
    Copy link
    Owner

    stoe commented Apr 21, 2024

    I have deleted the scorecard.
    Was just an experiment. Although I want to do this (some day) I don't have the bandwidth to address everything right now.

    @stoe stoe merged commit 9ce5399 into stoe:main Apr 21, 2024
    4 checks passed
    @joshjohanning
    Copy link
    Contributor Author

    馃檱 thanks for the review and merge @stoe! 馃帀

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    feature-request 馃毀 Want something new?
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    None yet

    2 participants