Skip to content

Commit f9683a6

Browse files
authored
Setup Codeflash Github Actions to optimize all future code (#596)
- This Pull Request sets up the `codeflash.yml` file which will run on every new Pull Request that modifies the source code for `unstructured-ingest` directory. - We setup the codeflash config in the pyproject.toml file. This defines basic project config for codeflash. - Please take a look at the requirements that are being installed. Feel free to add more to the install list. Codeflash tries to execute code and if it is missing a dependency needed to make something run, it will fail to optimize. - Codeflash is being installed everytime in the CI. This helps the workflow always use the latest version of codeflash as it improves rapidly. Feel free to add codeflash to dev dependency as well, since we are about to release more local optimization tools like VS Code and claude code extensions. - Feel free to modify this Github action anyway you want **Actions Required to make this work-** - Install the Codeflash Github app from [this link](https://github.com/apps/codeflash-ai/installations/select_target) to this repo. This is required for our github-bot to comment and create suggestions on the github repo. - Create a new `CODEFLASH_API_KEY` after signing up to [Codeflash from our website](https://www.codeflash.ai/). The onboarding will ask you to create an API Key and show instructions on how to save the api key on your repo secrets. Then, after this PR is merged in it will start generating new optimizations 🎉
1 parent 5d19593 commit f9683a6

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

.github/workflows/codeflash.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Codeflash / Optimize new Python code
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'unstructured_ingest/**'
7+
8+
9+
concurrency:
10+
group: "${{ github.workflow }}-${{ github.ref }}"
11+
cancel-in-progress: true
12+
13+
14+
jobs:
15+
optimize:
16+
name: Codeflash / Optimize new Python code
17+
if: ${{ github.actor != 'codeflash-ai[bot]' }}
18+
runs-on: ubuntu-latest
19+
env:
20+
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
21+
NLTK_DATA: ${{ github.workspace }}/nltk_data
22+
steps:
23+
- uses: 'actions/checkout@v4'
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
with:
27+
enable-cache: true
28+
python-version: 3.12
29+
30+
- name: Set up Python
31+
run: uv python install
32+
33+
- name: Codeflash
34+
run: |
35+
uv sync --all-groups --all-extras --upgrade
36+
uv pip install unstructured
37+
uv pip install codeflash
38+
uv run python -m nltk.downloader -d $NLTK_DATA punkt_tab averaged_perceptron_tagger_eng
39+
uv run codeflash

pyproject.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,11 @@ fail_under = 0
202202

203203
[tool.hatch.build.targets.sdist]
204204
packages = ["/unstructured_ingest"]
205+
206+
[tool.codeflash]
207+
# All paths are relative to this pyproject.toml's directory.
208+
module-root = "unstructured_ingest"
209+
tests-root = "test"
210+
test-framework = "pytest"
211+
ignore-paths = []
212+
formatter-cmds = ["ruff check --exit-zero --fix $file", "ruff format $file"]

0 commit comments

Comments
 (0)