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

Fix PR Metadata and Downstream issues #1466

Merged
merged 21 commits into from
Oct 20, 2023
Merged

Fix PR Metadata and Downstream issues #1466

merged 21 commits into from
Oct 20, 2023

Conversation

trajan0x
Copy link
Contributor

@trajan0x trajan0x commented Oct 20, 2023

Description

This WIP PR aims to fix #1467 and #1434

To Do:

  • Determine if pr_metadata is even necessary. The whole point of find-current-pr is it allows us to associate a commit w/ a pull request. But unless we want to run the go generate stuff on push rather than pull request, this seems dumb. Maybe there's an argument for running on both if we comment on the commit instead, but I'm not sure this makes sense. A similiar concern was raised in Fix git-changes-action when module was unchanged #1399

Update: I think this is completely fine, let's just run this on pull_requests. There's not a good way to get notified that's not extremely annoying on commits anyway.

After merging:

Optional/Future Work:

Summary by CodeRabbit

  • New Feature: Introduced custom GitHub Actions "Add Label" and "Remove Label" to manage labels on issues and pull requests more efficiently.
  • Improvement: Updated workflows to use these custom actions, enhancing the reliability and control over label management.
  • Refactor: Replaced third-party actions with custom actions for adding and removing labels, reducing dependency on external sources.
  • Improvement: Adjusted conditions for running jobs in workflows, providing more precise control over when certain actions are triggered.
  • New Feature: Enabled Yarn's global cache in the Node.js setup, improving package installation speed and efficiency.

@github-actions github-actions bot added M-ci Module: CI size/xs labels Oct 20, 2023
@trajan0x trajan0x changed the title [ignore me] Fix PR Metadata and Downstream issues Oct 20, 2023
@trajan0x trajan0x changed the title Fix PR Metadata and Downstream issues [WIP] Fix PR Metadata and Downstream issues Oct 20, 2023
@trajan0x trajan0x linked an issue Oct 20, 2023 that may be closed by this pull request
@github-actions github-actions bot added size/s and removed size/xs labels Oct 20, 2023
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4416f0a) 50.69210% compared to head (f856451) 50.85025%.
Report is 16 commits behind head on master.

❗ Current head f856451 differs from pull request most recent head 74e225a. Consider uploading reports for the commit 74e225a to get more accurate results

Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #1466         +/-   ##
===================================================
+ Coverage   50.69210%   50.85025%   +0.15814%     
===================================================
  Files            356         356                 
  Lines          24274       24287         +13     
  Branches         267         268          +1     
===================================================
+ Hits           12305       12350         +45     
+ Misses         10775       10744         -31     
+ Partials        1194        1193          -1     
Flag Coverage Δ
packages 90.62003% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
packages/contracts-core/contracts/Destination.sol 87.50000% <100.00000%> (ø)
packages/contracts-core/contracts/GasOracle.sol 100.00000% <100.00000%> (ø)
packages/contracts-core/contracts/Origin.sol 95.45455% <100.00000%> (+0.21644%) ⬆️
packages/contracts-core/contracts/Summit.sol 96.59091% <100.00000%> (ø)
...ages/contracts-core/contracts/hubs/SnapshotHub.sol 83.19328% <100.00000%> (ø)
.../contracts-core/contracts/inbox/StatementInbox.sol 89.74359% <100.00000%> (ø)
...ontracts-core/contracts/manager/BondingManager.sol 86.58537% <100.00000%> (ø)
.../contracts-core/contracts/manager/LightManager.sol 96.66667% <100.00000%> (ø)

... and 11 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trajan0x trajan0x mentioned this pull request Oct 20, 2023
trajan0x added a commit that referenced this pull request Oct 20, 2023
Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
@trajan0x trajan0x mentioned this pull request Oct 20, 2023
2 tasks
* try to fix yarn install time

* yarn workflow mod

* undo me (modified sdk-router yarn.lock, used to test #1466)

* ignore me

* Revert "ignore me"

This reverts commit 6ae9e60.

* fix spelling issue, try again

* yarnrc fix

* undo me

* Revert "undo me" (Test warm cache)

This reverts commit 032e1e7.

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
@trajan0x trajan0x marked this pull request as ready for review October 20, 2023 13:15
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 20, 2023

Walkthrough

This pull request introduces custom GitHub Actions for adding and removing labels from issues or pull requests. It also refines the conditions for executing these actions and replaces third-party actions with custom ones. Additionally, it sets up global configuration for Yarn.

Changes

File(s) Summary
.github/actions/add-label/..., .github/actions/remove-label/... Introduced custom GitHub Actions for adding and removing labels from issues or pull requests. Added documentation and usage examples.
.github/workflows/go.yml, .github/workflows/packages.yml Updated workflows to use custom actions for label management and refined conditions for executing these actions.
.github/actions/setup-nodejs/action.yml Added a step to set up global configuration for Yarn.

🐇💻

In the land of code, where the rabbits play,

A pull request was made today.

Labels added, labels removed,

With custom actions, we've improved.

Yarn's global cache, now in sight,

Makes our code run just right.

So here's to changes, big and small,

In the world of code, we rule them all! 🎉


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • Mention @coderabbitai in any review comment for bot assistance.
  • Note: Review comments are made on code diffs or files, not on the PR overview.

Pause Incremental Reviews

  • Insert @coderabbitai: ignore in the PR description to halt the bot's ongoing reviews. Remove the line to resume.
  • Additionally, enter @coderabbitai pause to halt the bot's ongoing reviews as any issue or review comment. To
    resume reviews, enter @coderabbitai resume as any issue or review comment.

@trajan0x trajan0x changed the title [WIP] Fix PR Metadata and Downstream issues Fix PR Metadata and Downstream issues Oct 20, 2023
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 4

Commits Files that changed from the base of the PR and between dcda614 and 3ffaef2.
Files ignored due to filter (1)
  • packages/sdk-router/yarn.lock
Files selected for processing (7)
  • .github/actions/add-label/README.md (1 hunks)
  • .github/actions/add-label/action.yml (1 hunks)
  • .github/actions/remove-label/README.md (1 hunks)
  • .github/actions/remove-label/action.yml (1 hunks)
  • .github/actions/setup-nodejs/action.yml (1 hunks)
  • .github/workflows/go.yml (4 hunks)
  • .github/workflows/packages.yml (1 hunks)
Files skipped from review due to trivial changes (3)
  • .github/actions/add-label/action.yml
  • .github/actions/remove-label/README.md
  • .github/actions/setup-nodejs/action.yml
Additional comments (Suppressed): 8
.github/workflows/packages.yml (2)
  • 62-67: The "Add Label" action is correctly replaced with a custom action. However, the issue_number input is missing, which is required to specify the issue or pull request to which the label should be added. Please verify if the issue_number is being handled in the custom action or if it needs to be added here.
           with:
             label: 'needs-yarn-install'
+            issue_number: ${{ needs.issue_number.outputs.issue_number }}
  • 68-72: The "Remove Label" action is incorrectly using the "Add Label" action. This should be replaced with the "Remove Label" action. Also, the issue_number input is missing here as well.
-           uses: ./.github/actions/add-label
+           uses: ./.github/actions/remove-label
           with:
             label: 'needs-yarn-install'
+            issue_number: ${{ needs.issue_number.outputs.issue_number }}
.github/workflows/go.yml (6)
  • 356-356: The condition for running the job has been changed from pull_request to push. Ensure that this change aligns with the intended workflow triggers.
-    if: ${{ github.event_name != 'pull_request' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}
+    if: ${{ github.event_name != 'push' && format('refs/heads/{0}', github.event.repository.default_branch) != github.ref }}
  • 363-366: The gh api command is used to fetch metadata for the pull request. However, the gh api command requires authentication. Ensure that the GITHUB_TOKEN is set in the environment variables to authenticate the GitHub CLI.

  • 390-390: The condition for running the job has been changed from pull_request to push. Ensure that this change aligns with the intended workflow triggers.

-    if: ${{ github.event_name != 'pull_request' && needs.changes.outputs.solidity_changes == 'true' }}
+    if: ${{ github.event_name != 'push' && needs.changes.outputs.solidity_changes == 'true' }}
  • 638-639: The deprecated third-party action andymckay/labeler has been replaced with custom actions for adding and removing labels. This is a good practice as it reduces dependencies on third-party actions which may become deprecated or introduce breaking changes.

  • 488-488: The condition for running the job has been changed from pull_request to push. Ensure that this change aligns with the intended workflow triggers.

-    if: ${{ github.event_name != 'pull_request' && needs.changes.outputs.unchanged_package_count_deps > 0 && contains(needs.pr_metadata.outputs.labels, 'needs-go-generate') }}
+    if: ${{ github.event_name != 'push' && needs.changes.outputs.unchanged_package_count_deps > 0 && contains(needs.pr_metadata.outputs.labels, 'needs-go-generate') }}
  • 511-511: The condition for running the job has been changed from pull_request to push. Ensure that this change aligns with the intended workflow triggers.
-    if: ${{ github.event_name != 'pull_request' && needs.changes.outputs.package_count_deps > 0 }}
+    if: ${{ github.event_name != 'push' && needs.changes.outputs.package_count_deps > 0 }}

.github/actions/add-label/README.md Outdated Show resolved Hide resolved
.github/actions/remove-label/action.yml Outdated Show resolved Hide resolved
.github/actions/remove-label/action.yml Show resolved Hide resolved
.github/actions/remove-label/action.yml Show resolved Hide resolved
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Commits Files that changed from the base of the PR and between 3ffaef2 and 18f6ed1.
Files selected for processing (1)
  • .github/actions/remove-label/action.yml (1 hunks)
Additional comments (Suppressed): 1
.github/actions/remove-label/action.yml (1)
  • 34-43: The removeLabel function is expecting an array for the name parameter. This was previously flagged as an issue but was clarified by the user with supporting documentation. No changes are needed here.

Comment on lines +15 to +31
# TODO, dedupe w/ add-label
- name: Resolve issue number
id: resolve_issue_number
run: |
if [[ -n '${{ inputs.issue_number }}' ]]; then
echo 'Using input issue number: ${{ inputs.issue_number }}'
echo '::set-output name=issue::${{ inputs.issue_number }}'
elif [[ -n '${{ github.event.number }}' ]]; then
echo 'Using event number: ${{ github.event.number }}'
echo '::set-output name=issue::${{ github.event.number }}'
elif [[ -n '${{ github.event.issue.number }}' ]]; then
echo 'Using event issue number: ${{ github.event.issue.number }}'
echo '::set-output name=issue::${{ github.event.issue.number }}'
else
echo 'Could not determine issue number'
exit 1
fi
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 20, 2023

Choose a reason for hiding this comment

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

The code for resolving the issue number is duplicated in add-label and remove-label actions. Consider extracting this logic into a separate action or a script to avoid code duplication. This will improve maintainability and make the code easier to test and debug.

-     # TODO, dedupe w/ add-label
-     - name: Resolve issue number
-       id: resolve_issue_number
-       run: |
-         if [[ -n '${{ inputs.issue_number }}' ]]; then
-           echo 'Using input issue number: ${{ inputs.issue_number }}'
-           echo '::set-output name=issue::${{ inputs.issue_number }}'
-         elif [[ -n '${{ github.event.number }}' ]]; then
-           echo 'Using event number: ${{ github.event.number }}'
-           echo '::set-output name=issue::${{ github.event.number }}'
-         elif [[ -n '${{ github.event.issue.number }}' ]]; then
-           echo 'Using event issue number: ${{ github.event.issue.number }}'
-           echo '::set-output name=issue::${{ github.event.issue.number }}'
-         else
-           echo 'Could not determine issue number'
-           exit 1
-         fi
-       shell: bash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

already added a todo for this

Copy link
Contributor

Choose a reason for hiding this comment

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

@trajan0x, I understand that you've added a TODO comment to address this issue in the future. However, it's generally a good practice to avoid merging code that contains duplication, especially when the duplication is non-trivial and could be abstracted into a reusable component. This is in line with the DRY (Don't Repeat Yourself) principle, which is a fundamental concept in software development for reducing repetition of software patterns, replacing it with abstractions or using data normalization to avoid redundancy.

Here's a suggestion on how you could abstract the issue number resolution logic into a separate GitHub action:

name: Resolve Issue Number
description: Resolve the issue number from inputs or event context
inputs:
  issue_number:
    description: 'The issue number to associate with. Defaults to the current issue or pull request number used to trigger the action.'
    required: false
    default: ''
runs:
  using: 'composite'
  steps:
    - name: Resolve issue number
      id: resolve_issue_number
      run: |
        if [[ -n '${{ inputs.issue_number }}' ]]; then
          echo 'Using input issue number: ${{ inputs.issue_number }}'
          echo '::set-output name=issue::${{ inputs.issue_number }}'
        elif [[ -n '${{ github.event.number }}' ]]; then
          echo 'Using event number: ${{ github.event.number }}'
          echo '::set-output name=issue::${{ github.event.number }}'
        elif [[ -n '${{ github.event.issue.number }}' ]]; then
          echo 'Using event issue number: ${{ github.event.issue.number }}'
          echo '::set-output name=issue::${{ github.event.issue.number }}'
        else
          echo 'Could not determine issue number'
          exit 1
        fi
      shell: bash
outputs:
  issue:
    description: 'The resolved issue number'

Then, in your add-label and remove-label actions, you can use this new action like so:

- name: Resolve Issue Number
  id: resolve_issue_number
  uses: ./.github/actions/resolve-issue-number
  with:
    issue_number: ${{ inputs.issue_number }}

This way, you can keep your code DRY and maintainable.

@trajan0x trajan0x merged commit 8852be5 into master Oct 20, 2023
26 checks passed
@trajan0x trajan0x deleted the fix/metadata branch October 20, 2023 13:22
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Commits Files that changed from the base of the PR and between 18f6ed1 and 74e225a.
Files selected for processing (2)
  • .github/actions/add-label/README.md (1 hunks)
  • .github/actions/remove-label/README.md (1 hunks)
Additional comments (Suppressed): 1
.github/actions/add-label/README.md (1)
  • 12-18: The usage example is clear and concise, providing a good reference for how to use the action in a workflow. However, it would be beneficial to include an example of how to handle the action's failure, especially considering the potential issue mentioned above.

This action adds a specified label to an issue or pull request.

## Inputs
* `issue_number`: The issue number derived from the event payload. Default is `${{ github.event.number }}` then `${{ github.event.issue.number }}`. Action will fail if neither of these is present. If you need to use this action on a push event (or any event not associated directly with an `issue` or `pull_request`, please see [gh-find-current-pr](https://github.com/jwalton/gh-find-current-pr))
Copy link
Contributor

Choose a reason for hiding this comment

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

The default value for issue_number is first set to ${{ github.event.number }} and then ${{ github.event.issue.number }}. However, the action will fail if neither of these is present. This could be a potential issue if the action is used in a context where these values are not available. Consider adding error handling or a more descriptive failure message to guide users in such scenarios.

Comment on lines +1 to +3
## Remove Label

This action removes a specified label to an issue or pull request.
Copy link
Contributor

Choose a reason for hiding this comment

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

The description of the action is misleading. It says the action "removes a specified label to an issue or pull request", which implies that it's adding a label, not removing it. Please correct the description to accurately reflect the action's functionality.

- This action removes a specified label to an issue or pull request.
+ This action removes a specified label from an issue or pull request.


## Inputs
* `issue_number`: The issue number derived from the event payload. Default is `${{ github.event.number }}` then `${{ github.event.issue.number }}`. Action will fail if neither of these is present. If you need to use this action on a push event (or any event not associated directly with an `issue` or `pull_request`, please see [gh-find-current-pr](https://github.com/jwalton/gh-find-current-pr))
* `label`: The label to add to the issue
Copy link
Contributor

Choose a reason for hiding this comment

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

The description of the label input is incorrect. It says "The label to add to the issue", but this action is for removing labels, not adding them. Please correct the description to accurately reflect the input's purpose.

- * `label`: The label to add to the issue
+ * `label`: The label to remove from the issue

trajan0x added a commit that referenced this pull request Oct 20, 2023
trajan0x added a commit that referenced this pull request Oct 20, 2023
trajan0x added a commit that referenced this pull request Oct 20, 2023
* fix canto urls

* list changed files for debugging

* add label->remove label (Fix issue from #1466)

---------

Co-authored-by: Trajan0x <trajan0x@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code M-ci Module: CI size/s
Projects
None yet
1 participant