-
Notifications
You must be signed in to change notification settings - Fork 165
ci: post the LOC diff as a sticky pull request comment #1753
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
Merged
+112
−98
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b398c2
ci: post the LOC diff as a sticky pull request comment
sbryngelson 17ae833
ci: address review of the LOC diff comment bot
sbryngelson a67c1d1
ci: reject symlinks in the counted tree and drop the untrusted checkout
sbryngelson f696f12
Merge branch 'master' into ci/loc-diff-comment
sbryngelson cfdfabc
ci: trim comments in the LOC diff bot
sbryngelson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,58 +1,55 @@ | ||
| name: Lines of Code | ||
|
|
||
| # pull_request_target: fork PRs are read-only under pull_request and cannot be | ||
| # commented on. Nothing in pr/ may ever be executed. | ||
| # Unfiltered by path: a PR that stops touching src/ must still run to clean up. | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| workflow_dispatch: | ||
| pull_request_target: | ||
|
|
||
| jobs: | ||
| file-changes: | ||
| name: Detect File Changes | ||
| runs-on: 'ubuntu-latest' | ||
| outputs: | ||
| checkall: ${{ steps.changes.outputs.checkall }} | ||
| steps: | ||
| - name: Clone | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Detect Changes | ||
| uses: dorny/paths-filter@v4 | ||
| id: changes | ||
| with: | ||
| filters: ".github/file-filter.yml" | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.event.number }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| sz: | ||
| name: Core MFC Line Difference | ||
| if: needs.file-changes.outputs.checkall == 'true' | ||
| needs: file-changes | ||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code from PR branch | ||
| - name: Checkout the base branch | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| path: pr | ||
|
|
||
| - name: Checkout code from MFC master | ||
| uses: actions/checkout@v5 | ||
| with: | ||
| repository: ${{ github.event.pull_request.repository }} | ||
| ref: ${{ github.event.pull_request.base.ref }} | ||
| path: base | ||
| # repository: MFlowCode/MFC | ||
| # ref: master | ||
| # path: base | ||
| path: base | ||
| fetch-depth: 0 | ||
|
|
||
| # git worktree, not actions/checkout: no untrusted checkout in a | ||
| # privileged workflow. Merge base, not branch tip: a stale branch is not | ||
| # charged for other people's lines. | ||
| - name: Get Line Diff | ||
| id: diff | ||
| working-directory: base | ||
| run: | | ||
| BASE="$GITHUB_WORKSPACE/base" | ||
| PR="$GITHUB_WORKSPACE/pr" | ||
| cd $BASE | ||
| export MFC_PR=$PR | ||
| pwd | ||
| ./mfc.sh init &> tmp.txt | ||
| ./mfc.sh count_diff | ||
| git fetch --no-tags origin "+refs/pull/${{ github.event.number }}/head:refs/mfc/pr" | ||
| git worktree add ../pr refs/mfc/pr | ||
| git worktree add ../mb "$(git merge-base HEAD refs/mfc/pr)" | ||
| ./mfc.sh count_diff ../mb ../pr --markdown "$GITHUB_WORKSPACE/loc.md" | ||
| test -s "$GITHUB_WORKSPACE/loc.md" && echo "changed=true" >> "$GITHUB_OUTPUT" || echo "changed=false" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Comment Line Diff | ||
| if: steps.diff.outputs.changed == 'true' | ||
| uses: marocchino/sticky-pull-request-comment@v3 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| skip_unchanged: true | ||
| recreate: true | ||
| path: loc.md | ||
|
|
||
| # No diff: take down any comment an earlier push left. | ||
| - name: Remove Line Diff Comment | ||
| if: steps.diff.outputs.changed == 'false' | ||
| uses: marocchino/sticky-pull-request-comment@v3 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| delete: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.