Skip to content

serve + improvements #46

serve + improvements

serve + improvements #46

Workflow file for this run

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 }}