diff --git a/.github/workflows/codeflash-optimize.yaml b/.github/workflows/codeflash-optimize.yaml index 0f8d829ad..6a08635bf 100644 --- a/.github/workflows/codeflash-optimize.yaml +++ b/.github/workflows/codeflash-optimize.yaml @@ -32,7 +32,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author diff --git a/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml b/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml index ebc577cd9..cd53470ba 100644 --- a/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml +++ b/.github/workflows/end-to-end-test-bubblesort-pytest-no-git.yaml @@ -31,7 +31,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author diff --git a/.github/workflows/end-to-end-test-bubblesort-unittest.yaml b/.github/workflows/end-to-end-test-bubblesort-unittest.yaml index 3bd5dc440..ba188652a 100644 --- a/.github/workflows/end-to-end-test-bubblesort-unittest.yaml +++ b/.github/workflows/end-to-end-test-bubblesort-unittest.yaml @@ -31,7 +31,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author @@ -41,7 +41,7 @@ jobs: # Allowlist check if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then echo "✅ Authorized user ($AUTHOR). Proceeding." - elif [["${{ github.event.pull_request.state }}" == "open" ]]; then + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." else echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." diff --git a/.github/workflows/end-to-end-test-coverage.yaml b/.github/workflows/end-to-end-test-coverage.yaml index a65976395..d3764653d 100644 --- a/.github/workflows/end-to-end-test-coverage.yaml +++ b/.github/workflows/end-to-end-test-coverage.yaml @@ -29,7 +29,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author @@ -39,7 +39,7 @@ jobs: # Allowlist check if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then echo "✅ Authorized user ($AUTHOR). Proceeding." - elif [["${{ github.event.pull_request.state }}" == "open" ]]; then + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." else echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." diff --git a/.github/workflows/end-to-end-test-futurehouse.yaml b/.github/workflows/end-to-end-test-futurehouse.yaml index f32d577ac..55f7de040 100644 --- a/.github/workflows/end-to-end-test-futurehouse.yaml +++ b/.github/workflows/end-to-end-test-futurehouse.yaml @@ -31,7 +31,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author @@ -41,7 +41,7 @@ jobs: # Allowlist check if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then echo "✅ Authorized user ($AUTHOR). Proceeding." - elif [["${{ github.event.pull_request.state }}" == "open" ]]; then + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." else echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." diff --git a/.github/workflows/end-to-end-test-init-optim.yaml b/.github/workflows/end-to-end-test-init-optim.yaml index a6712e6f3..3379a2056 100644 --- a/.github/workflows/end-to-end-test-init-optim.yaml +++ b/.github/workflows/end-to-end-test-init-optim.yaml @@ -30,7 +30,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author @@ -40,7 +40,7 @@ jobs: # Allowlist check if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then echo "✅ Authorized user ($AUTHOR). Proceeding." - elif [["${{ github.event.pull_request.state }}" == "open" ]]; then + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." else echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." diff --git a/.github/workflows/end-to-end-test-tracer-replay.yaml b/.github/workflows/end-to-end-test-tracer-replay.yaml index 35dc1f41b..68fdf25d0 100644 --- a/.github/workflows/end-to-end-test-tracer-replay.yaml +++ b/.github/workflows/end-to-end-test-tracer-replay.yaml @@ -30,7 +30,7 @@ jobs: - name: Validate PR run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author @@ -40,7 +40,7 @@ jobs: # Allowlist check if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then echo "✅ Authorized user ($AUTHOR). Proceeding." - elif [["${{ github.event.pull_request.state }}" == "open" ]]; then + elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding." else echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting." diff --git a/.github/workflows/end-to-end-topological-sort-test.yaml b/.github/workflows/end-to-end-topological-sort-test.yaml index bfe8dd1f6..875fbd56e 100644 --- a/.github/workflows/end-to-end-topological-sort-test.yaml +++ b/.github/workflows/end-to-end-topological-sort-test.yaml @@ -27,11 +27,38 @@ jobs: with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} + - name: Debug Environment Decision + run: | + # Construct the condition result manually for debugging + EVENT_NAME="${{ github.event_name }}" + FILES_CHANGED="${{ toJSON(github.event.pull_request.files.*.filename) }}" + PR_AUTHOR="${{ github.event.pull_request.user.login }}" + + echo "Event Name: $EVENT_NAME" + echo "Files Changed: $FILES_CHANGED" + echo "PR Author: $PR_AUTHOR" + + # Check workflow file changes + if [[ "$FILES_CHANGED" == *".github/workflows/"* ]]; then + echo "Workflow files changed: YES" + else + echo "Workflow files changed: NO" + fi + + # Check author conditions + if [[ "$PR_AUTHOR" != "misrasaurabh1" && "$PR_AUTHOR" != "KRRT7" ]]; then + echo "Author needs approval: YES" + else + echo "Author needs approval: NO" + fi + + # Selected environment + 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' || '' }}" - name: Validate PR for workflow changes run: | # Check for any workflow changes - if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then + if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then echo "⚠️ Workflow changes detected." # Get the PR author AUTHOR="${{ github.event.pull_request.user.login }}"