Skip to content

Commit 0a9d523

Browse files
authored
Merge branch 'main' into get_repo_owner_fix
2 parents ca9a836 + 731ec66 commit 0a9d523

13 files changed

+77
-13
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ jobs:
2828
- name: 🛎️ Checkout
2929
uses: actions/checkout@v4
3030
with:
31+
ref: ${{ github.event.pull_request.head.ref }}
32+
repository: ${{ github.event.pull_request.head.repo.full_name }}
3133
fetch-depth: 0
3234
- name: Validate PR
3335
run: |

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
name: end-to-end-test
22

33
on:
4-
pull_request:
4+
# Use pull_request_target for everything to ensure access to secrets
5+
pull_request_target:
6+
paths:
7+
- '**' # Trigger for all paths
8+
59
workflow_dispatch:
610

711
jobs:
812
benchmark-bubble-sort-optimization:
13+
# Dynamically determine if environment is needed only when workflow files change and contributor is external
14+
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' || '' }}
15+
916
runs-on: ubuntu-latest
1017
env:
1118
CODEFLASH_AIS_SERVER: prod
@@ -17,11 +24,37 @@ jobs:
1724
EXPECTED_IMPROVEMENT_PCT: 5
1825
CODEFLASH_END_TO_END: 1
1926
steps:
20-
- uses: actions/checkout@v4
27+
- name: 🛎️ Checkout
28+
uses: actions/checkout@v4
2129
with:
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2232
fetch-depth: 0
2333
token: ${{ secrets.GITHUB_TOKEN }}
2434

35+
- name: Validate PR
36+
run: |
37+
# Check for any workflow changes
38+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" | grep -q "^.github/workflows/"; then
39+
echo "⚠️ Workflow changes detected."
40+
41+
# Get the PR author
42+
AUTHOR="${{ github.event.pull_request.user.login }}"
43+
echo "PR Author: $AUTHOR"
44+
45+
# Allowlist check
46+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
47+
echo "✅ Authorized user ($AUTHOR). Proceeding."
48+
elif [[ "${{ github.event.pull_request.state }}" == "open" ]]; then
49+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
50+
else
51+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
52+
exit 1
53+
fi
54+
else
55+
echo "✅ No workflow file changes detected. Proceeding."
56+
fi
57+
2558
- name: Set up Python 3.11 for CLI
2659
uses: astral-sh/setup-uv@v5
2760
with:

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
EXPECTED_IMPROVEMENT_PCT: 300
2525
CODEFLASH_END_TO_END: 1
2626
steps:
27-
- uses: actions/checkout@v4
27+
- name: 🛎️ Checkout
28+
uses: actions/checkout@v4
2829
with:
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2932
fetch-depth: 0
3033
token: ${{ secrets.GITHUB_TOKEN }}
3134
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
EXPECTED_IMPROVEMENT_PCT: 300
2525
CODEFLASH_END_TO_END: 1
2626
steps:
27-
- uses: actions/checkout@v4
27+
- name: 🛎️ Checkout
28+
uses: actions/checkout@v4
2829
with:
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2932
fetch-depth: 0
3033
token: ${{ secrets.GITHUB_TOKEN }}
3134
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ jobs:
2222
RETRY_DELAY: 5
2323
CODEFLASH_END_TO_END: 1
2424
steps:
25-
- uses: actions/checkout@v4
25+
- name: 🛎️ Checkout
26+
uses: actions/checkout@v4
2627
with:
28+
ref: ${{ github.event.pull_request.head.ref }}
29+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2730
fetch-depth: 0
2831
token: ${{ secrets.GITHUB_TOKEN }}
2932
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,11 @@ jobs:
2424
EXPECTED_IMPROVEMENT_PCT: 10
2525
CODEFLASH_END_TO_END: 1
2626
steps:
27-
- uses: actions/checkout@v4
27+
- name: 🛎️ Checkout
28+
uses: actions/checkout@v4
2829
with:
30+
ref: ${{ github.event.pull_request.head.ref }}
31+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2932
fetch-depth: 0
3033
token: ${{ secrets.GITHUB_TOKEN }}
3134
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ jobs:
2323
EXPECTED_IMPROVEMENT_PCT: 300
2424
CODEFLASH_END_TO_END: 1
2525
steps:
26-
- uses: actions/checkout@v4
26+
- name: 🛎️ Checkout
27+
uses: actions/checkout@v4
2728
with:
29+
ref: ${{ github.event.pull_request.head.ref }}
30+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2831
fetch-depth: 0
2932
token: ${{ secrets.GITHUB_TOKEN }}
3033
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ jobs:
2323
EXPECTED_IMPROVEMENT_PCT: 10
2424
CODEFLASH_END_TO_END: 1
2525
steps:
26-
- uses: actions/checkout@v4
26+
- name: 🛎️ Checkout
27+
uses: actions/checkout@v4
2728
with:
29+
ref: ${{ github.event.pull_request.head.ref }}
30+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2831
fetch-depth: 0
2932
token: ${{ secrets.GITHUB_TOKEN }}
3033
- name: Validate PR

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ jobs:
2323
EXPECTED_IMPROVEMENT_PCT: 5
2424
CODEFLASH_END_TO_END: 1
2525
steps:
26-
- uses: actions/checkout@v4
26+
- name: 🛎️ Checkout
27+
uses: actions/checkout@v4
2728
with:
29+
ref: ${{ github.event.pull_request.head.ref }}
30+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2831
fetch-depth: 0
2932
token: ${{ secrets.GITHUB_TOKEN }}
3033
- name: Debug Environment Decision

codeflash/benchmarking/trace_benchmarks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import os
34
import re
45
import subprocess
56
from pathlib import Path
@@ -9,6 +10,11 @@
910

1011

1112
def trace_benchmarks_pytest(benchmarks_root: Path, tests_root:Path, project_root: Path, trace_file: Path, timeout:int = 300) -> None:
13+
benchmark_env = os.environ.copy()
14+
if "PYTHONPATH" not in benchmark_env:
15+
benchmark_env["PYTHONPATH"] = str(project_root)
16+
else:
17+
benchmark_env["PYTHONPATH"] += os.pathsep + str(project_root)
1218
result = subprocess.run(
1319
[
1420
SAFE_SYS_EXECUTABLE,
@@ -21,7 +27,7 @@ def trace_benchmarks_pytest(benchmarks_root: Path, tests_root:Path, project_root
2127
check=False,
2228
capture_output=True,
2329
text=True,
24-
env={"PYTHONPATH": str(project_root)},
30+
env=benchmark_env,
2531
timeout=timeout,
2632
)
2733
if result.returncode != 0:

0 commit comments

Comments
 (0)