-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (88 loc) · 3.35 KB
/
change_impact.yml
File metadata and controls
106 lines (88 loc) · 3.35 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Reqvire Impact on PR Comment
on:
issue_comment:
types: [created]
jobs:
run-reqvire:
if: |
github.event.issue.pull_request != null &&
(
contains(github.event.comment.body, '/reqvire impact') ||
contains(github.event.comment.body, '/reqvire traces')
)
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- name: React to trigger comment with
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ github.event.comment.id }}
reactions: '+1'
- name: Checkout PR source branch
uses: actions/checkout@v4
- name: Get PR Head Ref using gh
id: get_pr_head
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
HEAD_REF=$(gh pr view ${{ github.event.issue.number }} --json headRefName --jq '.headRefName')
echo "Using PR head ref: $HEAD_REF"
echo "HEAD_REF=$HEAD_REF" >> $GITHUB_ENV
- name: Checkout PR source branch
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_REF }}
fetch-depth: 0 # needed for full commit history
- name: Get Base Branch from PR using gh
id: get_pr_base
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BASE_BRANCH=$(gh pr view ${{ github.event.issue.number }} --json baseRefName --jq '.baseRefName')
echo "Using base branch: $BASE_BRANCH"
echo "BASE_BRANCH=$BASE_BRANCH" >> $GITHUB_ENV
- name: Compute merge base commit
id: base_commit
run: |
git fetch origin "$BASE_BRANCH"
BASE_COMMIT=$(git merge-base origin/"$BASE_BRANCH" HEAD)
echo "Base commit: $BASE_COMMIT"
echo "BASE_COMMIT=$BASE_COMMIT" >> $GITHUB_ENV
- name: Ensure PR branch remains checked out
run: |
git checkout ${{ github.event.issue.pull_request.head.ref }}
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build reqvirecli from source
run: |
cargo build --release
cp target/release/reqvire ./reqvire
- name: Run Reqvire Impact (if triggered)
if: contains(github.event.comment.body, '/reqvire impact')
id: run_impact
run: |
OUTPUT=$(./reqvire change-impact --git-commit "$BASE_COMMIT" 2>&1 || echo "⚠️ reqvire impact failed.")
echo "REQVIRE_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$OUTPUT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run Reqvire Traces (if triggered)
if: contains(github.event.comment.body, '/reqvire traces')
id: run_traces
run: |
OUTPUT=$(./reqvire traces 2>&1 || echo "⚠️ reqvire traces failed.")
echo "REQVIRE_OUTPUT<<EOF" >> $GITHUB_ENV
echo "$OUTPUT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment on PR with result
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ github.event.issue.number }}
body: |
${{ env.REQVIRE_OUTPUT }}