| # Workflow that runs after a merge to the default branch, analyses changes in test executions | |
| # and posts the result to the merged PR. | |
| name: Post merge analysis | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| analysis: | |
| runs-on: ubuntu-24.04 | |
| if: github.repository == 'rust-lang/rust' | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| # Make sure that we have enough commits to find the parent merge commit. | |
| # Since all merges should be through merge commits, fetching two commits | |
| # should be enough to get the parent bors merge commit. | |
| fetch-depth: 2 | |
| - name: Perform analysis and send PR | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| # Give GitHub some time to propagate the information that the PR was merged | |
| sleep 60 | |
| # Get closest bors merge commit | |
| PARENT_COMMIT=`git rev-list --author='bors@rust-lang.org' --author='122020455+rust-bors\[bot\]@users.noreply.github.com' -n1 --first-parent HEAD^1` | |
| echo "Parent: ${PARENT_COMMIT}" | |
| # Find PR for the current commit | |
| HEAD_PR=`gh pr list --search "${{ github.sha }}" --state merged --json number --jq '.[0].number'` | |
| if [ -z "${HEAD_PR}" ]; then | |
| echo "PR for commit SHA ${{ github.sha }} not found, exiting" | |
| exit 1 | |
| fi | |
| echo "HEAD: ${{ github.sha }} (#${HEAD_PR})" | |
| cd src/ci/citool | |
| printf "<details>\n<summary>What is this?</summary>\n" >> output.log | |
| printf "This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.\n" >> output.log | |
| printf "</details>\n\n" >> output.log | |
| cargo run --release post-merge-report ${PARENT_COMMIT} ${{ github.sha }} >> output.log | |
| cat output.log | |
| gh pr comment ${HEAD_PR} -F output.log |