Skip to content

Commit

Permalink
add a comment on PR on MSRV failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Jan 28, 2023
1 parent 2becb46 commit 3291021
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci-comment-failures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,50 @@ jobs:
});
}
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@v3.1.0
with:
result-encoding: string
script: |
var artifacts = await github.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.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@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
var fs = require('fs');
var issue_number = Number(fs.readFileSync('./NR'));
await github.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.'
});
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,13 @@ jobs:
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
- name: Run cargo check
run: cargo check
- name: Save PR number
if: ${{ failure() && github.event_name == 'pull_request' }}
run: |
mkdir -p ./msrv
echo ${{ github.event.number }} > ./msrv/NR
- uses: actions/upload-artifact@v2
if: ${{ failure() && github.event_name == 'pull_request' }}
with:
name: msrv
path: msrv/

0 comments on commit 3291021

Please sign in to comment.