add line changes diff bot to CI (#1863)

This commit is contained in:
Yixiang Gao
2023-09-15 15:29:58 -05:00
committed by GitHub
parent 29ac8293d7
commit 789c84a7a3
2 changed files with 102 additions and 11 deletions

51
.github/workflows/szdiff.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: Check Line Counts
on:
pull_request:
# Cancel the workflow in progress in newer build is about to start.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
szdiff:
name: Core Library Line Difference
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout code from pr
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
path: pr
- name: Checkout code from base
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Count Lines Of Code
run: |
pip install tabulate
BASE="$GITHUB_WORKSPACE/base"
PR="$GITHUB_WORKSPACE/pr"
cp "$PR/sz.py" .
echo "loc_content<<EOF" >> "$GITHUB_ENV"
python sz.py "$BASE" "$PR" >> "$GITHUB_ENV"
echo "EOF" >> "$GITHUB_ENV"
- name: Comment Code Lines
continue-on-error: false
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
header: LOC
ignore_empty: true
skip_unchanged: true
recreate: true
message: ${{ env.loc_content }}