Skip to content

Commit 40e416e

Browse files
committed
Merge branch 'refs/heads/main' into codeflash-trace-decorator
# Conflicts: # codeflash/code_utils/config_parser.py # codeflash/optimization/function_optimizer.py
2 parents a4c4c2d + 21f09ab commit 40e416e

21 files changed

+231
-120
lines changed

.github/workflows/codeflash-optimize.yaml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,25 @@ jobs:
2929
fetch-depth: 0
3030
- name: Validate PR
3131
run: |
32-
# Checking for any workflow changes for security risks
33-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
34-
echo "Workflow changes detected."
32+
# Check for any workflow changes
33+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
34+
echo "⚠️ Workflow changes detected."
3535
36-
# Check if the PR author is allowed
36+
# Get the PR author
3737
AUTHOR="${{ github.event.pull_request.user.login }}"
38-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
39-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
40-
exit 1
38+
echo "PR Author: $AUTHOR"
39+
40+
# Allowlist check
41+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
42+
echo "✅ Authorized user ($AUTHOR). Proceeding."
43+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
44+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
4145
else
42-
echo "Authorized user ($AUTHOR). Proceeding."
46+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
47+
exit 1
4348
fi
49+
else
50+
echo "✅ No workflow file changes detected. Proceeding."
4451
fi
4552
4653
- name: 🐍 Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,25 @@ jobs:
2222
token: ${{ secrets.GITHUB_TOKEN }}
2323
- name: Validate PR
2424
run: |
25-
# Checking for any workflow changes for security risks
26-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
27-
echo "Workflow changes detected."
25+
# Check for any workflow changes
26+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
27+
echo "⚠️ Workflow changes detected."
2828
29-
# Check if the PR author is allowed
29+
# Get the PR author
3030
AUTHOR="${{ github.event.pull_request.user.login }}"
31-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
32-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
33-
exit 1
31+
echo "PR Author: $AUTHOR"
32+
33+
# Allowlist check
34+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
35+
echo "✅ Authorized user ($AUTHOR). Proceeding."
36+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
37+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3438
else
35-
echo "Authorized user ($AUTHOR). Proceeding."
39+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
40+
exit 1
3641
fi
42+
else
43+
echo "✅ No workflow file changes detected. Proceeding."
3744
fi
3845
3946
- name: Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148
- name: Set up Python 3.11 for CLI

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

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ jobs:
2424
token: ${{ secrets.GITHUB_TOKEN }}
2525
- name: Validate PR
2626
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
27+
# Check for any workflow changes
28+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
29+
echo "⚠️ Workflow changes detected."
3030
31-
# Check if the PR author is allowed
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
35+
# Allowlist check
36+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
37+
echo "✅ Authorized user ($AUTHOR). Proceeding."
38+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
39+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3640
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
41+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
42+
exit 1
3843
fi
44+
else
45+
echo "✅ No workflow file changes detected. Proceeding."
3946
fi
4047
4148

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,26 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424
token: ${{ secrets.GITHUB_TOKEN }}
25+
2526
- name: Validate PR
2627
run: |
27-
# Checking for any workflow changes for security risks
28-
if git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "^.github/workflows/"; then
29-
echo "Workflow changes detected."
30-
31-
# Check if the PR author is allowed
28+
# Check for any workflow changes
29+
if git diff --name-only "${{ github.event.pull_request.base.sha }}" "${{ github.sha }}" | grep -q "^.github/workflows/"; then
30+
echo "⚠️ Workflow changes detected."
31+
# Get the PR author
3232
AUTHOR="${{ github.event.pull_request.user.login }}"
33-
if [[ "$AUTHOR" != "misrasaurabh1" && "$AUTHOR" != "KRRT7" ]]; then
34-
echo "Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
35-
exit 1
33+
echo "PR Author: $AUTHOR"
34+
# Allowlist check
35+
if [[ "$AUTHOR" == "misrasaurabh1" || "$AUTHOR" == "KRRT7" ]]; then
36+
echo "✅ Authorized user ($AUTHOR). Proceeding."
37+
elif [[ "${{ github.event_name }}" == "pull_request_target" && "${{ github.event.pull_request.state }}" == "open" ]]; then
38+
echo "✅ PR triggered by 'pull_request_target' and is open. Assuming protection rules are in place. Proceeding."
3639
else
37-
echo "Authorized user ($AUTHOR). Proceeding."
40+
echo "⛔ Unauthorized user ($AUTHOR) attempting to modify workflows. Exiting."
41+
exit 1
3842
fi
39-
fiif git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | grep -q "end-to-end-topological-sort-test.yaml"; then
40-
echo "This workflow file has been modified. Exiting for security."
41-
exit 1
43+
else
44+
echo "✅ No workflow file changes detected. Proceeding."
4245
fi
4346
4447
- name: Set up Python 3.11 for CLI
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: PR Labeler
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- ".github/workflows/**"
7+
types: [opened, synchronize, reopened]
8+
9+
jobs:
10+
label-workflow-changes:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- name: Label PR with workflow changes
16+
uses: actions/github-script@v6
17+
with:
18+
script: |
19+
const labelName = 'workflow-modified';
20+
21+
// Check if the label exists
22+
try {
23+
const labels = await github.rest.issues.listLabelsForRepo({
24+
owner: context.repo.owner,
25+
repo: context.repo.repo
26+
});
27+
28+
const labelExists = labels.data.some(label => label.name === labelName);
29+
30+
if (!labelExists) {
31+
// Create the label if it doesn't exist
32+
await github.rest.issues.createLabel({
33+
owner: context.repo.owner,
34+
repo: context.repo.repo,
35+
name: labelName,
36+
color: 'f9d0c4',
37+
description: 'This PR modifies GitHub Actions workflows'
38+
});
39+
console.log(`Label "${labelName}" created`);
40+
} else {
41+
console.log(`Label "${labelName}" already exists`);
42+
}
43+
} catch (error) {
44+
console.error(`Failed to check or create label: ${error.message}`);
45+
throw error;
46+
}
47+
48+
// Add the label to the PR
49+
await github.rest.issues.addLabels({
50+
issue_number: context.issue.number,
51+
owner: context.repo.owner,
52+
repo: context.repo.repo,
53+
labels: [labelName]
54+
});
55+
console.log(`Label "${labelName}" added to the PR.`);

codeflash/code_utils/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def parse_config_file(
8383
else: # Default to empty list
8484
config[key] = []
8585

86-
assert config["test-framework"] in ["pytest", "unittest"], (
86+
assert config["test-framework"] in {"pytest", "unittest"}, (
8787
"In pyproject.toml, Codeflash only supports the 'test-framework' as pytest and unittest."
8888
)
8989
if len(config["formatter-cmds"]) > 0:

0 commit comments

Comments
 (0)