Skip to content

Commit 9005337

Browse files
Saga4KRRT7
andauthored
Syntax improvement for wf file change (#147)
* workflow test for wf file change(Test PR) * syntax improve for wf changes --------- Co-authored-by: Kevin Turcios <[email protected]>
1 parent 8a917e3 commit 9005337

8 files changed

+40
-13
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Validate PR
3333
run: |
3434
# Check for any workflow changes
35-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
35+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3636
echo "⚠️ Workflow changes detected."
3737
3838
# Get the PR author

.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Validate PR
3232
run: |
3333
# Check for any workflow changes
34-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
34+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3535
echo "⚠️ Workflow changes detected."
3636
3737
# Get the PR author

.github/workflows/end-to-end-test-bubblesort-unittest.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Validate PR
3232
run: |
3333
# Check for any workflow changes
34-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
34+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3535
echo "⚠️ Workflow changes detected."
3636
3737
# Get the PR author
@@ -41,7 +41,7 @@ jobs:
4141
# Allowlist check
4242
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4343
echo "✅ Authorized user ($AUTHOR). Proceeding."
44-
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
44+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4545
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4646
else
4747
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-coverage.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
- name: Validate PR
3030
run: |
3131
# Check for any workflow changes
32-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
32+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3333
echo "⚠️ Workflow changes detected."
3434
3535
# Get the PR author
@@ -39,7 +39,7 @@ jobs:
3939
# Allowlist check
4040
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4141
echo "✅ Authorized user ($AUTHOR). Proceeding."
42-
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
42+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4343
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4444
else
4545
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-futurehouse.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Validate PR
3232
run: |
3333
# Check for any workflow changes
34-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
34+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3535
echo "⚠️ Workflow changes detected."
3636
3737
# Get the PR author
@@ -41,7 +41,7 @@ jobs:
4141
# Allowlist check
4242
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4343
echo "✅ Authorized user ($AUTHOR). Proceeding."
44-
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
44+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4545
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4646
else
4747
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-init-optim.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Validate PR
3131
run: |
3232
# Check for any workflow changes
33-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
33+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3434
echo "⚠️ Workflow changes detected."
3535
3636
# Get the PR author
@@ -40,7 +40,7 @@ jobs:
4040
# Allowlist check
4141
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4242
echo "✅ Authorized user ($AUTHOR). Proceeding."
43-
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
43+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4444
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4545
else
4646
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-test-tracer-replay.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Validate PR
3131
run: |
3232
# Check for any workflow changes
33-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
33+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3434
echo "⚠️ Workflow changes detected."
3535
3636
# Get the PR author
@@ -40,7 +40,7 @@ jobs:
4040
# Allowlist check
4141
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
4242
echo "✅ Authorized user ($AUTHOR). Proceeding."
43-
elif [["${{ github.event.pull_request.state }}" == "open" ]]; then
43+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
4444
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4545
else
4646
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."

.github/workflows/end-to-end-topological-sort-test.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,38 @@ jobs:
2727
with:
2828
fetch-depth: 0
2929
token: ${{ secrets.GITHUB_TOKEN }}
30+
- name: Debug Environment Decision
31+
run: |
32+
# Construct the condition result manually for debugging
33+
EVENT_NAME="${{ github.event_name }}"
34+
FILES_CHANGED="${{ toJSON(github.event.pull_request.files.*.filename) }}"
35+
PR_AUTHOR="${{ github.event.pull_request.user.login }}"
36+
37+
echo "Event Name: $EVENT_NAME"
38+
echo "Files Changed: $FILES_CHANGED"
39+
echo "PR Author: $PR_AUTHOR"
40+
41+
# Check workflow file changes
42+
if [[ "$FILES_CHANGED" == *".github/workflows/"* ]]; then
43+
echo "Workflow files changed: YES"
44+
else
45+
echo "Workflow files changed: NO"
46+
fi
47+
48+
# Check author conditions
49+
if [[ "$PR_AUTHOR" != "misrasaurabh1" && "$PR_AUTHOR" != "KRRT7" ]]; then
50+
echo "Author needs approval: YES"
51+
else
52+
echo "Author needs approval: NO"
53+
fi
54+
55+
# Selected environment
56+
echo "Selected Environment: ${{ (github.event_name == 'workflow_dispatch' || (contains(toJSON(github.event.pull_request.files.*.filename), '.github/workflows/') && github.event.pull_request.user.login != 'misrasaurabh1' && github.event.pull_request.user.login != 'KRRT7')) && 'external-trusted-contributors' || '' }}"
3057
3158
- name: Validate PR for workflow changes
3259
run: |
3360
# Check for any workflow changes
34-
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
61+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
3562
echo "⚠️ Workflow changes detected."
3663
# Get the PR author
3764
AUTHOR="${{ github.event.pull_request.user.login }}"

0 commit comments

Comments
 (0)