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

Support using sketches reports from local path #5

Merged
merged 5 commits into from
Sep 15, 2020
Merged

Support using sketches reports from local path #5

merged 5 commits into from
Sep 15, 2020

Conversation

per1234
Copy link
Collaborator

@per1234 per1234 commented Sep 13, 2020

The action was previously designed to only run from a scheduled workflow. The reason is that it needs a token with write permissions to comment on the PR, but due to security restrictions there is no way to have such a token when a
workflow is triggered by a pull_request event from a fork.

This is problematic for private repos because if the schedule is set to a short interval the action will use up the free GitHub actoins minutes allocation quickly (public repos have unlimited minutes). If the schedule is set to a long
interval, then there is a long potential wait time for the report.

A common work flow in private repos is for PRs to be submitted from branches, not forks, which makes it possible to trigger the action from the PR.

Running from a pull request triggered workflow should actually work as the action was, but the method of finding the artifact is very inefficient and unintuitive in that context.

Recently, GitHub added the ability for private repositories to allow write permissions for workflows triggered by pull requests, making it even more likely this method of using the action will be found useful:
https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks


Due to now supporting multiple sources of sketches reports, the input name size-deltas-reports-artifact-name was no longer appropriate (this input is now used for specifying the workflow artifact name when used in the traditional scheduled workflow method and for specifying the local folder name when using the new pull request triggered workflow method), so it has been renamed sketches-reports-source.

The previous input name is still supported, but a warning will be displayed in the build log recommending switching to the new input name.


Demonstration of the action used in a pull request triggered workflow:
https://github.com/per1234/report-size-deltas/pull/1#issuecomment-691649959
This is using the exact workflow from the readme, except with the arduino/report-size-deltas@main action name changed to per1234/report-size-deltas@local-report-support so it can use the version of the action with the implementation of this proposal.

@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (main@66f2d53). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##             main        #5   +/-   ##
========================================
  Coverage        ?   100.00%           
========================================
  Files           ?         2           
  Lines           ?       700           
  Branches        ?         0           
========================================
  Hits            ?       700           
  Misses          ?         0           
  Partials        ?         0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66f2d53...d4ae92e. Read the comment docs.

Copy link
Collaborator

@aentinger aentinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 Thank you @per1234 🚀

@aentinger
Copy link
Collaborator

@per1234 please resolve the conflict within README.md before merging.

The test was triggering an intentional delay in a function, resulting in this test causing a signficant increase in the time required to run the unit tests.

The solution was to simply fake time.sleep() so it no longer causes a delay.
…urce-name

Preparation to use the input for specifying the source of sketches reports either in a workflow artifact or a local folder.

The old input name is still supported but warning will be displayed in the build log to explain the name change.
The action was previously designed to only run from a scheduled workflow. The
reason is that it needs a token with write permissions to comment on the PR, but
due to security restrictions there is no way to have such a token when a
workflow is triggered by a pull_request event from a fork.

This is problematic for private repos because if the schedule is set to a short
interval the action will use up the free GitHub actoins minutes allocation
quickly (public repos have unlimited minutes). If the schedule is set to a long
interval, then there is a long potential wait time for the report.

A common work flow in private repos is for PRs to be submitted from branches,
not forks, which makes it possible to trigger the action from the PR.

Running from a pull request triggered workflow should actually work as the
action was, but the method of finding the artifact is very inefficient and
unintuitive in that context.

Recently, GitHub added the ability for private repositories to allow write
permissions for workflows triggered by pull requests, making it even more likely
this method of using the action will be found useful:
https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository#enabling-workflows-for-private-repository-forks
…() into separate functions

The addition of support for sourcing the sketches reports from a local path resulted in the function containing code for two completely separate usages of the script.

Moving each flavor of code to a separate function improves readability, maintainability, and testability.
I decided the "-name" part of the input name was superfluous.

This is part of a single PR, so no further backwards compatibility measures are necessary. I just don't feel like making the effort to fixup the previous name change commit and deal with all the conflicts while rebasing.
@per1234
Copy link
Collaborator Author

per1234 commented Sep 15, 2020

@aentinger I have now resolved the merge conflict.

@aentinger aentinger merged commit 2f05f71 into arduino:main Sep 15, 2020
@per1234 per1234 deleted the local-report-support branch September 15, 2020 15:57
@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Jun 13, 2024
@per1234 per1234 self-assigned this Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants