Skip to content

feat(ci) Run codeflash in on PRs modifying the Python CDK #44427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/cdk-codeflash.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Run Codeflash on CDK PR

on:
pull_request:
paths:
- airbyte-cdk/python/airbyte_cdk/**
workflow_dispatch:

defaults:
run:
working-directory: ./airbyte-cdk/python/airbyte_cdk

jobs:
optimize:
name: Optimize new code in this PR
# Only run codeflash if
# 1. The contributor is not codeflash. To avoid infinite loops
# 2. The pull request is not from a forked repository
if: ${{ github.actor != 'codeflash-ai[bot]' && github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork != true}}
runs-on: ubuntu-latest
env:
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
CODEFLASH_PR_NUMBER: ${{ github.event.number }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install Airbyte CDK
id: install-airbyte-cdk
run: |
pip install --upgrade pip
pip install poetry
poetry install --all-extras --with dev
- name: Run Codeflash to optimize code
id: optimize_code
run: |
poetry env use python
poetry run codeflash
12 changes: 12 additions & 0 deletions airbyte-cdk/python/airbyte_cdk/bubble_sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.


def sorter(arr):
for i in range(len(arr)):
# This is a diff
for j in range(len(arr) - 1):
if arr[j] > arr[j + 1]:
temp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = temp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i in range(len(arr)):
# This is a diff
for j in range(len(arr) - 1):
if arr[j] > arr[j + 1]:
temp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = temp
arr.sort()

return arr
Loading
Loading