ci: upgrade action versions, add uv cache, fix broken paths, DRY publish

- Bump actions/checkout v4/v5 → v6, setup-node v4 → v6, setup-java v4 → v5,
  prek-action v1 → v2, github-script v6 → v7, aws-credentials v4 → v6,
  claude-code-action v1.0.89 → v1
- Add enable-cache: true to all astral-sh/setup-uv steps
- Remove redundant uv venv --seed (uv sync creates venvs automatically)
- Merge double uv sync steps in unit-tests into single conditional
- Fix codeflash.yaml: broken path filter and working-directory
- Consolidate duplicate publish jobs into a single matrix job
- Remove generate_release_notes overridden by manual body
This commit is contained in:
Kevin Turcios 2026-04-09 22:06:41 -05:00
parent 153097b9a3
commit be4c459d01
6 changed files with 90 additions and 120 deletions

View file

@ -38,7 +38,7 @@ jobs:
e2e_js: ${{ github.event_name != 'pull_request' || steps.check.outputs.e2e_js == 'true' }}
e2e_java: ${{ github.event_name != 'pull_request' || steps.check.outputs.e2e_java == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
if: github.event_name == 'pull_request'
with:
fetch-depth: 0
@ -127,7 +127,7 @@ jobs:
env:
PYTHONIOENCODING: utf-8
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
@ -136,13 +136,15 @@ jobs:
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
- name: Install dependencies
run: uv sync
- name: Install test-only dependencies (Python 3.9 and 3.13)
if: matrix.python-version == '3.9' || matrix.python-version == '3.13'
run: uv sync --group tests
run: |
if [[ "${{ matrix.python-version }}" == "3.9" || "${{ matrix.python-version }}" == "3.13" ]]; then
uv sync --group tests
else
uv sync
fi
- name: Unit tests
run: uv run pytest tests/
@ -155,18 +157,18 @@ jobs:
if: needs.determine-changes.outputs.type_check == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: 1
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
- name: Install dependencies
run: |
uv venv --seed
uv sync
run: uv sync
- name: Run mypy
run: uv run mypy --non-interactive --config-file pyproject.toml @mypy_allowlist.txt
@ -184,11 +186,13 @@ jobs:
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
- name: Auto-fix formatting
run: |
@ -204,7 +208,7 @@ jobs:
git commit -m "style: auto-format with ruff"
git push
- uses: j178/prek-action@v1
- uses: j178/prek-action@v2
with:
extra-args: '--from-ref origin/${{ github.base_ref }} --to-ref HEAD'
@ -260,7 +264,7 @@ jobs:
RETRY_DELAY: 5
CODEFLASH_END_TO_END: 1
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref || '' }}
repository: ${{ github.event.pull_request.head.repo.full_name || '' }}
@ -280,6 +284,7 @@ jobs:
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: 3.11.6
enable-cache: true
- name: Install dependencies
run: uv sync
@ -348,7 +353,7 @@ jobs:
EXPECTED_IMPROVEMENT_PCT: ${{ matrix.expected_improvement }}
CODEFLASH_END_TO_END: 1
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref || '' }}
repository: ${{ github.event.pull_request.head.repo.full_name || '' }}
@ -365,7 +370,7 @@ jobs:
pr_state: ${{ github.event.pull_request.state }}
- name: Set up Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '20'
cache: 'npm'
@ -387,6 +392,7 @@ jobs:
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: 3.11.6
enable-cache: true
- name: Install dependencies
run: uv sync
@ -427,7 +433,7 @@ jobs:
EXPECTED_IMPROVEMENT_PCT: ${{ matrix.expected_improvement }}
CODEFLASH_END_TO_END: 1
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref || '' }}
repository: ${{ github.event.pull_request.head.repo.full_name || '' }}
@ -444,7 +450,7 @@ jobs:
pr_state: ${{ github.event.pull_request.state }}
- name: Set up JDK 11
uses: actions/setup-java@v4
uses: actions/setup-java@v5
with:
java-version: '11'
distribution: 'temurin'
@ -454,6 +460,7 @@ jobs:
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: 3.11.6
enable-cache: true
- name: Install dependencies
run: uv sync

View file

@ -51,28 +51,28 @@ jobs:
actions: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref || github.ref }}
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
- name: Install dependencies
run: |
uv venv --seed
uv sync
run: uv sync
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1.0.89
uses: anthropics/claude-code-action@v1
with:
use_bedrock: "true"
use_sticky_comment: true
@ -311,28 +311,28 @@ jobs:
fi
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ steps.pr-ref.outputs.ref }}
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
- name: Install dependencies
run: |
uv venv --seed
uv sync
run: uv sync
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1.0.89
uses: anthropics/claude-code-action@v1
with:
use_bedrock: "true"
claude_args: '--model us.anthropic.claude-sonnet-4-6 --allowedTools "Read,Edit,Write,Glob,Grep,Bash(git status*),Bash(git diff*),Bash(git add *),Bash(git commit *),Bash(git push*),Bash(git log*),Bash(git merge*),Bash(git fetch*),Bash(git checkout*),Bash(git branch*),Bash(uv run prek *),Bash(prek *),Bash(uv run ruff *),Bash(uv run pytest *),Bash(uv run mypy *),Bash(uv run coverage *),Bash(gh pr comment*),Bash(gh pr view*),Bash(gh pr diff*),Bash(gh pr merge*),Bash(gh pr close*)"'

View file

@ -26,7 +26,7 @@ jobs:
COLUMNS: 110
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
@ -34,6 +34,7 @@ jobs:
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: 3.11.6
enable-cache: true
- name: 📦 Install dependencies (CLI)
run: |

View file

@ -4,7 +4,7 @@ on:
pull_request:
paths:
# So that this workflow only runs when code within the target module is modified
- 'code_to_optimize_js_esm/**'
- 'code_to_optimize/js/code_to_optimize_js_esm/**'
workflow_dispatch:
concurrency:
@ -23,19 +23,20 @@ jobs:
CODEFLASH_API_KEY: ${{ secrets.CODEFLASH_API_KEY }}
defaults:
run:
working-directory: ./code_to_optimize_js_esm
working-directory: ./code_to_optimize/js/code_to_optimize_js_esm
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: 🟢 Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: '22'
cache: 'npm'
cache-dependency-path: code_to_optimize/js/code_to_optimize_js_esm/package-lock.json
- name: 📦 Install Dependencies
run: npm ci
- name: ⚡️ Codeflash Optimization
run: npx codeflash

View file

@ -13,7 +13,7 @@ jobs:
pull-requests: write
steps:
- name: Label PR with workflow changes
uses: actions/github-script@v6
uses: actions/github-script@v7
with:
script: |
const labelName = 'workflow-modified';

View file

@ -16,7 +16,7 @@ jobs:
benchmark: ${{ steps.filter.outputs.benchmark }}
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 2
@ -34,9 +34,27 @@ jobs:
echo "benchmark=false" >> $GITHUB_OUTPUT
fi
publish-codeflash:
publish:
needs: detect-changes
if: needs.detect-changes.outputs.codeflash == 'true'
if: >-
needs.detect-changes.outputs.codeflash == 'true'
|| needs.detect-changes.outputs.benchmark == 'true'
strategy:
fail-fast: false
matrix:
include:
- package: codeflash
version_file: codeflash/version.py
tag_prefix: v
build_cmd: uv build
flag: codeflash
release_name_prefix: "Release"
- package: codeflash-benchmark
version_file: codeflash-benchmark/codeflash_benchmark/version.py
tag_prefix: benchmark-v
build_cmd: uv build --package codeflash-benchmark
flag: benchmark
release_name_prefix: "codeflash-benchmark"
runs-on: ubuntu-latest
environment:
name: pypi
@ -44,92 +62,34 @@ jobs:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Extract version from version.py
id: extract_version
- name: Check if this matrix leg should run
id: should_run
run: |
VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash/version.py)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=v$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Check if tag already exists
id: check_tag
run: |
if git rev-parse "v${{ steps.extract_version.outputs.version }}" >/dev/null 2>&1; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.extract_version.outputs.version }} already exists, skipping release"
if [[ "${{ matrix.flag }}" == "codeflash" && "${{ needs.detect-changes.outputs.codeflash }}" == "true" ]]; then
echo "run=true" >> $GITHUB_OUTPUT
elif [[ "${{ matrix.flag }}" == "benchmark" && "${{ needs.detect-changes.outputs.benchmark }}" == "true" ]]; then
echo "run=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "Tag v${{ steps.extract_version.outputs.version }} does not exist, proceeding with release"
echo "run=false" >> $GITHUB_OUTPUT
fi
- name: Create and push git tag
if: steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${{ steps.extract_version.outputs.tag }}" -m "Release ${{ steps.extract_version.outputs.tag }}"
git push origin "${{ steps.extract_version.outputs.tag }}"
- name: Install uv
if: steps.check_tag.outputs.exists == 'false'
uses: astral-sh/setup-uv@v8.0.0
- name: Build
if: steps.check_tag.outputs.exists == 'false'
run: uv build
- name: Publish to PyPI
if: steps.check_tag.outputs.exists == 'false'
run: uv publish
- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.extract_version.outputs.tag }}
name: Release ${{ steps.extract_version.outputs.tag }}
body: |
## What's Changed
Release ${{ steps.extract_version.outputs.version }} of codeflash.
**Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.extract_version.outputs.tag }}
draft: false
prerelease: false
generate_release_notes: true
files: |
dist/*
publish-benchmark:
needs: detect-changes
if: needs.detect-changes.outputs.benchmark == 'true'
runs-on: ubuntu-latest
environment:
name: pypi
permissions:
id-token: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v5
if: steps.should_run.outputs.run == 'true'
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Extract version from version.py
if: steps.should_run.outputs.run == 'true'
id: extract_version
run: |
VERSION=$(grep -oP '__version__ = "\K[^"]+' codeflash-benchmark/codeflash_benchmark/version.py)
VERSION=$(grep -oP '__version__ = "\K[^"]+' ${{ matrix.version_file }})
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=benchmark-v$VERSION" >> $GITHUB_OUTPUT
echo "tag=${{ matrix.tag_prefix }}$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Check if tag already exists
if: steps.should_run.outputs.run == 'true'
id: check_tag
run: |
if git rev-parse "${{ steps.extract_version.outputs.tag }}" >/dev/null 2>&1; then
@ -141,7 +101,7 @@ jobs:
fi
- name: Create and push git tag
if: steps.check_tag.outputs.exists == 'false'
if: steps.should_run.outputs.run == 'true' && steps.check_tag.outputs.exists == 'false'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
@ -149,31 +109,32 @@ jobs:
git push origin "${{ steps.extract_version.outputs.tag }}"
- name: Install uv
if: steps.check_tag.outputs.exists == 'false'
if: steps.should_run.outputs.run == 'true' && steps.check_tag.outputs.exists == 'false'
uses: astral-sh/setup-uv@v8.0.0
with:
enable-cache: true
- name: Build
if: steps.check_tag.outputs.exists == 'false'
run: uv build --package codeflash-benchmark
if: steps.should_run.outputs.run == 'true' && steps.check_tag.outputs.exists == 'false'
run: ${{ matrix.build_cmd }}
- name: Publish to PyPI
if: steps.check_tag.outputs.exists == 'false'
if: steps.should_run.outputs.run == 'true' && steps.check_tag.outputs.exists == 'false'
run: uv publish
- name: Create GitHub Release
if: steps.check_tag.outputs.exists == 'false'
if: steps.should_run.outputs.run == 'true' && steps.check_tag.outputs.exists == 'false'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.extract_version.outputs.tag }}
name: codeflash-benchmark ${{ steps.extract_version.outputs.tag }}
name: ${{ matrix.release_name_prefix }} ${{ steps.extract_version.outputs.tag }}
body: |
## What's Changed
Release ${{ steps.extract_version.outputs.version }} of codeflash-benchmark.
Release ${{ steps.extract_version.outputs.version }} of ${{ matrix.package }}.
**Full Changelog**: https://github.com/${{ github.repository }}/commits/${{ steps.extract_version.outputs.tag }}
draft: false
prerelease: false
generate_release_notes: true
files: |
dist/*