From 4459627a771a38d1f9b1245fdbc3e25f43443b26 Mon Sep 17 00:00:00 2001 From: Saga4 Date: Sun, 13 Apr 2025 13:42:56 +0530 Subject: [PATCH 1/2] workflow test for wf file change(Test PR) --- .github/workflows/end-to-end-test-coverage.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/end-to-end-test-coverage.yaml b/.github/workflows/end-to-end-test-coverage.yaml index a65976395..ba1212c6c 100644 --- a/.github/workflows/end-to-end-test-coverage.yaml +++ b/.github/workflows/end-to-end-test-coverage.yaml @@ -19,7 +19,7 @@ jobs: POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} MAX_RETRIES: 3 - RETRY_DELAY: 5 + RETRY_DELAY: 4 CODEFLASH_END_TO_END: 1 steps: - uses: actions/checkout@v4 From 43007d2cbe339c2b8d203c048a8006f286daabed Mon Sep 17 00:00:00 2001 From: Saga4 Date: Mon, 14 Apr 2025 02:16:15 +0530 Subject: [PATCH 2/2] syntax improve for wf changes --- .github/workflows/codeflash-optimize.yaml | 2 +- ...-to-end-test-bubblesort-pytest-no-git.yaml | 2 +- .../end-to-end-test-bubblesort-unittest.yaml | 4 +-- .../workflows/end-to-end-test-coverage.yaml | 6 ++-- .../end-to-end-test-futurehouse.yaml | 4 +-- .../workflows/end-to-end-test-init-optim.yaml | 4 +-- .../end-to-end-test-tracer-replay.yaml | 4 +-- .../end-to-end-topological-sort-test.yaml | 29 ++++++++++++++++++- 8 files changed, 41 insertions(+), 14 deletions(-) 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 ba1212c6c..d3764653d 100644 --- a/.github/workflows/end-to-end-test-coverage.yaml +++ b/.github/workflows/end-to-end-test-coverage.yaml @@ -19,7 +19,7 @@ jobs: POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }} MAX_RETRIES: 3 - RETRY_DELAY: 4 + RETRY_DELAY: 5 CODEFLASH_END_TO_END: 1 steps: - uses: actions/checkout@v4 @@ -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 }}"