Skip to content

Commit 180ca83

Browse files
Improve workflow: use env variable and more robust line counting
Co-authored-by: functionstackx <47992694+functionstackx@users.noreply.github.com>
1 parent 6a9ad80 commit 180ca83

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

.github/workflows/pr-line-counter.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
count-lines:
99
runs-on: ubuntu-latest
10+
env:
11+
TARGET_FILE: utils/matrix-logic/generate_sweep_configs.py
1012

1113
steps:
1214
- name: Checkout code
@@ -15,10 +17,8 @@ jobs:
1517
- name: Count lines in generate_sweep_configs.py
1618
id: line-count
1719
run: |
18-
FILE_PATH="utils/matrix-logic/generate_sweep_configs.py"
19-
20-
if [ -f "$FILE_PATH" ]; then
21-
LINE_COUNT=$(wc -l < "$FILE_PATH")
20+
if [ -f "$TARGET_FILE" ]; then
21+
LINE_COUNT=$(wc -l "$TARGET_FILE" | awk '{print $1}')
2222
echo "line_count=$LINE_COUNT" >> $GITHUB_OUTPUT
2323
echo "file_exists=true" >> $GITHUB_OUTPUT
2424
else
@@ -33,12 +33,10 @@ jobs:
3333
3434
FILE_EXISTS="${{ steps.line-count.outputs.file_exists }}"
3535
if [ "$FILE_EXISTS" == "true" ]; then
36-
FILE_PATH="utils/matrix-logic/generate_sweep_configs.py"
3736
LINE_COUNT="${{ steps.line-count.outputs.line_count }}"
38-
echo "**File:** \`$FILE_PATH\`" >> $GITHUB_STEP_SUMMARY
37+
echo "**File:** \`$TARGET_FILE\`" >> $GITHUB_STEP_SUMMARY
3938
echo "" >> $GITHUB_STEP_SUMMARY
4039
echo "**Total Lines:** $LINE_COUNT" >> $GITHUB_STEP_SUMMARY
4140
else
42-
FILE_PATH="utils/matrix-logic/generate_sweep_configs.py"
43-
echo "⚠️ **File not found:** \`$FILE_PATH\`" >> $GITHUB_STEP_SUMMARY
41+
echo "⚠️ **File not found:** \`$TARGET_FILE\`" >> $GITHUB_STEP_SUMMARY
4442
fi

0 commit comments

Comments
 (0)