mirror of
https://github.com/bevyengine/bevy
synced 2024-11-25 06:00:20 +00:00
a8530ebbc8
# Objective - Used the wrong variable to set metadata - new fixes after https://github.com/bevyengine/bevy/pull/15911 ## Solution - Use the right one - Also keep a reference to the original PR when there's one
241 lines
9.5 KiB
YAML
241 lines
9.5 KiB
YAML
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
|
|
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 == "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@v7
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
var fs = require('fs');
|
|
var issue_number = Number(fs.readFileSync('./NR'));
|
|
if (fs.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 (fs.existsSync('./missing-update')) {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: issue_number,
|
|
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.'
|
|
});
|
|
}
|
|
|
|
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
|
|
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 == "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' }}
|
|
uses: actions/github-script@v7
|
|
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.'
|
|
});
|
|
}
|
|
|
|
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@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 == "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@v7
|
|
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.'
|
|
});
|
|
|
|
make-macos-screenshots-available:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 30
|
|
outputs:
|
|
branch-name: ${{ steps.branch-name.outputs.result }}
|
|
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"
|
|
- name: prepare artifact folder
|
|
run: |
|
|
unzip screenshots-macos.zip
|
|
mkdir screenshots
|
|
mv screenshots-* screenshots/
|
|
- name: save screenshots
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: screenshots-macos
|
|
path: screenshots
|
|
- 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
|
|
|
|
compare-macos-screenshots:
|
|
name: Compare macOS screenshots
|
|
needs: [make-macos-screenshots-available]
|
|
uses: ./.github/workflows/send-screenshots-to-pixeleagle.yml
|
|
with:
|
|
commit: ${{ github.event.workflow_run.head_sha }}
|
|
branch: ${{ needs.make-macos-screenshots-available.outputs.branch-name }}
|
|
artifact: screenshots-macos
|
|
os: macos
|
|
secrets: inherit
|