summary refs log tree commit diff
path: root/.github/workflows/post-merge.yml
blob: de31c28cc90e027b5e701f2ebb042945c74a1344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Workflow that runs after a merge to master, analyses changes in test executions
# and posts the result to the merged PR.

name: Post merge analysis

on:
  push:
    branches:
      - master

jobs:
  analysis:
    runs-on: ubuntu-24.04
    if: github.repository == 'rust-lang/rust'
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        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: |
          # Get closest bors merge commit
          PARENT_COMMIT=`git rev-list --author='bors <bors@rust-lang.org>' -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'`
          echo "HEAD: ${{ github.sha }} (#${HEAD_PR})"

          cd src/ci/citool

          printf "*This is an experimental post-merge analysis report. You can ignore it.*\n\n" > output.log
          printf "<details>\n<summary>Post-merge report</summary>\n\n" >> output.log

          cargo run --release post-merge-report ${PARENT_COMMIT} ${{ github.sha }} >> output.log

          printf "</details>\n" >> output.log

          cat output.log

          gh pr comment ${HEAD_PR} -F output.log