-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
[Merged by Bors] - Make CI friendlier #7398
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
62b835a
remove unneeded and false comment
mockersf d05f3bc
add a comment on PR on example run failure
mockersf b3fb715
add a comment on PR on example doc failure
mockersf 82aa91d
add a comment on PR on MSRV failure
mockersf 67f2107
be nice, say hello
mockersf 9206cba
extra write permission not needed here
mockersf 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
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 |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| name: CI - PR Comments | ||
|
|
||
| # This workflow has write permissions on the repo | ||
| # It must not checkout a PR and run untrusted code | ||
|
|
||
| # Also requesting write permissions on PR to be able to comment | ||
| permissions: | ||
| pull-requests: 'write' | ||
|
|
||
| on: | ||
| workflow_run: | ||
| workflows: ["CI"] | ||
| types: | ||
| - completed | ||
|
|
||
| jobs: | ||
| example-run: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'failure' | ||
| steps: | ||
| - name: 'Download artifact' | ||
| id: find-artifact | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| result-encoding: string | ||
| script: | | ||
| var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: ${{github.event.workflow_run.id }}, | ||
| }); | ||
| var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { | ||
| return artifact.name == "example-run" | ||
| }); | ||
| if (matchArtifacts.length == 0) { return "false" } | ||
| var matchArtifact = matchArtifacts[0]; | ||
| var download = await github.rest.actions.downloadArtifact({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| artifact_id: matchArtifact.id, | ||
| archive_format: 'zip', | ||
| }); | ||
| var fs = require('fs'); | ||
| fs.writeFileSync('${{github.workspace}}/example-run.zip', Buffer.from(download.data)); | ||
| return "true" | ||
| - run: unzip example-run.zip | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| - name: 'Comment on PR' | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| var fs = require('fs'); | ||
| var issue_number = Number(fs.readFileSync('./NR')); | ||
| var last_example_run = fs.readFileSync('./last_example_run'); | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| body: 'Example ' + last_example_run + ' failed to run, please try running it locally and check the result.' | ||
| }); | ||
|
|
||
| missing-examples: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'failure' | ||
| steps: | ||
| - name: 'Download artifact' | ||
| id: find-artifact | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| result-encoding: string | ||
| script: | | ||
| var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: ${{github.event.workflow_run.id }}, | ||
| }); | ||
| var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { | ||
| return artifact.name == "missing-examples" | ||
| }); | ||
| if (matchArtifacts.length == 0) { return "false" } | ||
| var matchArtifact = matchArtifacts[0]; | ||
| var download = await github.rest.actions.downloadArtifact({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| artifact_id: matchArtifact.id, | ||
| archive_format: 'zip', | ||
| }); | ||
| var fs = require('fs'); | ||
| fs.writeFileSync('${{github.workspace}}/missing-examples.zip', Buffer.from(download.data)); | ||
| return "true" | ||
| - run: unzip missing-examples.zip | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| - name: 'Comment on PR' | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| var fs = require('fs'); | ||
| var issue_number = Number(fs.readFileSync('./NR')); | ||
| if (existsSync('./missing-metadata')) { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| body: 'You added a new example but didn't add metadata for it. Please update the root Cargo.toml file.' | ||
| }); | ||
| } | ||
| if (existsSync('./missing-update')) { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| body: 'You added a new example but didn't update the readme. Please run `cargo run -p build-example-pages -- update` to update it, and commit the file change.' | ||
| }); | ||
| } | ||
|
|
||
| msrv: | ||
| runs-on: ubuntu-latest | ||
| if: > | ||
| github.event.workflow_run.event == 'pull_request' && | ||
| github.event.workflow_run.conclusion == 'failure' | ||
| steps: | ||
| - name: 'Download artifact' | ||
| id: find-artifact | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| result-encoding: string | ||
| script: | | ||
| var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| run_id: ${{github.event.workflow_run.id }}, | ||
| }); | ||
| var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { | ||
| return artifact.name == "msrv" | ||
| }); | ||
| if (matchArtifacts.length == 0) { return "false" } | ||
| var matchArtifact = matchArtifacts[0]; | ||
| var download = await github.rest.actions.downloadArtifact({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| artifact_id: matchArtifact.id, | ||
| archive_format: 'zip', | ||
| }); | ||
| var fs = require('fs'); | ||
| fs.writeFileSync('${{github.workspace}}/msrv.zip', Buffer.from(download.data)); | ||
| return "true" | ||
| - run: unzip msrv.zip | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| - name: 'Comment on PR' | ||
| if: ${{ steps.find-artifact.outputs.result == 'true' }} | ||
| uses: actions/github-script@v6 | ||
| with: | ||
| github-token: ${{ secrets.GITHUB_TOKEN }} | ||
| script: | | ||
| var fs = require('fs'); | ||
| var issue_number = Number(fs.readFileSync('./NR')); | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue_number, | ||
| body: 'Your PR increases Bevy Minimum Supported Rust Version. Please update the `rust-version` field in the root Cargo.toml file.' | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Welcome new contributors | ||
|
|
||
| # This workflow has write permissions on the repo | ||
| # It must not checkout a PR and run untrusted code | ||
|
|
||
| on: pull_request_target | ||
|
|
||
| jobs: | ||
| welcome: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/github-script@v6 | ||
| with: | ||
| script: | | ||
| // Get a list of all issues created by the PR opener | ||
| // See: https://octokit.github.io/rest.js/#pagination | ||
| const creator = context.payload.sender.login | ||
| const opts = github.rest.issues.listForRepo.endpoint.merge({ | ||
| ...context.issue, | ||
| creator, | ||
| state: 'all' | ||
| }) | ||
| const issues = await github.paginate(opts) | ||
|
|
||
| for (const issue of issues) { | ||
| if (issue.number === context.issue.number) { | ||
| continue | ||
| } | ||
|
|
||
| if (issue.pull_request) { | ||
| return // Creator is already a contributor. | ||
| } | ||
| } | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| issue_number: context.issue.number, | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| body: `**Welcome**, new contributor! | ||
|
|
||
| Please make sure you're read our [contributing guide](CONTRIBUTING.md) and we look forward to reviewing your Pull request shortly ✨` | ||
| }) | ||
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.