2023-01-29 17:16:29 +00:00
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 :
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
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-01-29 17:16:29 +00:00
with :
result-encoding : string
script : |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner : context.repo.owner,
repo : context.repo.repo,
2024-10-14 23:20:56 +00:00
run_id : ${{ github.event.workflow_run.id }},
2023-01-29 17:16:29 +00:00
});
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' }}
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-01-29 17:16:29 +00:00
with :
github-token : ${{ secrets.GITHUB_TOKEN }}
script : |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
2023-01-29 23:05:33 +00:00
if (fs.existsSync('./missing-metadata')) {
2023-01-29 17:16:29 +00:00
await github.rest.issues.createComment({
owner : context.repo.owner,
repo : context.repo.repo,
issue_number : issue_number,
2023-01-29 23:05:33 +00:00
body : 'You added a new example but didn\'t add metadata for it. Please update the root Cargo.toml file.'
2023-01-29 17:16:29 +00:00
});
}
2023-01-29 23:05:33 +00:00
if (fs.existsSync('./missing-update')) {
2023-01-29 17:16:29 +00:00
await github.rest.issues.createComment({
owner : context.repo.owner,
repo : context.repo.repo,
issue_number : issue_number,
2023-08-07 23:08:19 +00:00
body : 'The generated `examples/README.md` is out of sync with the example metadata in `Cargo.toml` or the example readme template. Please run `cargo run -p build-templated-pages -- update examples` to update it, and commit the file change.'
2023-02-28 14:24:47 +00:00
});
}
missing-features :
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
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-02-28 14:24:47 +00:00
with :
result-encoding : string
script : |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner : context.repo.owner,
repo : context.repo.repo,
2024-10-14 23:20:56 +00:00
run_id : ${{ github.event.workflow_run.id }},
2023-02-28 14:24:47 +00:00
});
var matchArtifacts = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "missing-features"
});
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-features.zip', Buffer.from(download.data));
return "true"
- run : unzip missing-features.zip
if : ${{ steps.find-artifact.outputs.result == 'true' }}
- name : 'Comment on PR'
if : ${{ steps.find-artifact.outputs.result == 'true' }}
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-02-28 14:24:47 +00:00
with :
github-token : ${{ secrets.GITHUB_TOKEN }}
script : |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
if (fs.existsSync('./missing-features')) {
await github.rest.issues.createComment({
owner : context.repo.owner,
repo : context.repo.repo,
issue_number : issue_number,
body : 'You added a new feature but didn\'t add a description for it. Please update the root Cargo.toml file.'
});
}
if (fs.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 feature but didn\'t update the readme. Please run `cargo run -p build-templated-pages -- update features` to update it, and commit the file change.'
2023-01-29 17:16:29 +00:00
});
}
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
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-01-29 17:16:29 +00:00
with :
result-encoding : string
script : |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner : context.repo.owner,
repo : context.repo.repo,
2024-10-14 23:20:56 +00:00
run_id : ${{ github.event.workflow_run.id }},
2023-01-29 17:16:29 +00:00
});
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' }}
2023-11-20 09:01:27 +00:00
uses : actions/github-script@v7
2023-01-29 17:16:29 +00:00
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.'
});
2024-10-14 19:16:12 +00:00
make-macos-screenshots-available :
runs-on : ubuntu-latest
timeout-minutes : 30
2024-10-14 23:20:56 +00:00
outputs :
branch-name : ${{ steps.branch-name.outputs.result }}
2024-10-14 19:16:12 +00:00
steps :
- name : 'Download artifact'
id : find-artifact
uses : actions/github-script@v7
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 == "screenshots-macos"
});
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}}/screenshots-macos.zip', Buffer.from(download.data));
return "true"
2024-10-14 21:16:25 +00:00
- name : prepare artifact folder
run : |
unzip screenshots-macos.zip
mkdir screenshots
mv screenshots-* screenshots/
2024-10-14 19:16:12 +00:00
- name : save screenshots
uses : actions/upload-artifact@v4
with :
name : screenshots-macos
2024-10-14 21:16:25 +00:00
path : screenshots
2024-10-14 23:20:56 +00:00
- name : branch name
id : branch-name
run : |
if [ -f PR ]; then
echo "result=PR-$(cat PR)-${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
else
echo "result=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
fi
2024-10-14 19:16:12 +00:00
compare-macos-screenshots :
name : Compare macOS screenshots
needs : [ make-macos-screenshots-available]
uses : ./.github/workflows/send-screenshots-to-pixeleagle.yml
with :
2024-10-14 23:20:56 +00:00
commit : ${{ github.event.workflow_run.head_sha }}
branch : ${{ needs.make-macos-screenshots-available.outputs.branch-name }}
2024-10-14 19:16:12 +00:00
artifact : screenshots-macos
os : macos
secrets : inherit