Patched patchwork/common/utils/utils.py #850
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Tests | |
on: | |
pull_request: | |
types: | |
- ready_for_review | |
- review_requested | |
push: | |
branches-ignore: | |
- main | |
- autofix-* | |
- dependencyupgrade-* | |
- generatereadme-* | |
- generatedocstring-* | |
- generateunittests-* | |
- generatecodeusageexample-* | |
- resolveissue-* | |
- demo* | |
# Credits to https://blog.maximeheckel.com/posts/building-perfect-github-action-frontend-teams/#you-are-terminated | |
concurrency: | |
# Here the group is defined by the head_ref of the PR | |
group: ${{ github.head_ref || github.ref_name }} | |
# Here we specify that we'll cancel any "in progress" workflow of the same group. Thus if we push, ammend a commit and push | |
# again the previous workflow will be cancelled, thus saving us github action build minutes and avoid any conflicts | |
cancel-in-progress: true | |
jobs: | |
all-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: jwalton/gh-find-current-pr@master | |
id: findPr | |
- name: Set up node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./.venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --all-extras | |
- name: Run tests | |
run: poetry run pytest | |
security-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: jwalton/gh-find-current-pr@master | |
id: findPr | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./.venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --only main --extras security | |
- name: AutoFix Patchwork | |
run: | | |
source .venv/bin/activate | |
patchwork AutoFix --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--force_pr_creation \ | |
--disable_telemetry | |
- name: Dependency Upgrade | |
run: | | |
source .venv/bin/activate | |
patchwork DependencyUpgrade --log debug \ | |
--libraries_api_key=${{ secrets.LIBRARIES_KEY }} \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--language=python \ | |
--force_pr_creation \ | |
--disable_telemetry | |
rag-test: | |
# disabled because this currently takes too long | |
if: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: jwalton/gh-find-current-pr@master | |
id: findPr | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./.venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --only main --extras rag | |
- name: Resolve issue | |
run: | | |
source .venv/bin/activate | |
patchwork ResolveIssue --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--issue_url=https://github.com/patched-codes/patchwork/issues/1129 \ | |
--disable_telemetry | |
--max_llm_calls=10 | |
main-test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- uses: jwalton/gh-find-current-pr@master | |
id: findPr | |
- name: Set up python | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.9' | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Load cached venv | |
id: cached-poetry-dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ./.venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('./poetry.lock') }}-${{ github.job }} | |
- name: Install dependencies | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install --no-interaction --only main | |
- name: PR Review | |
run: | | |
source .venv/bin/activate | |
patchwork PRReview --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--pr_url=https://github.com/patched-codes/patchwork/pull/${{ steps.findPr.outputs.number }} \ | |
--disable_telemetry | |
- name: Generate Docstring | |
run: | | |
source .venv/bin/activate | |
patchwork GenerateDocstring --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--base_path=tests/cicd/generate_docstring \ | |
--disable_telemetry | |
- name : Generate Diagram | |
run: | | |
source .venv/bin/activate | |
patchwork GenerateDiagram --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--folder_path=patchwork/steps \ | |
--disable_telemetry | |
- name: Generate UnitTests | |
run: | | |
source .venv/bin/activate | |
patchwork GenerateUnitTests --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--folder_path=tests/cicd/generate_docstring \ | |
--disable_telemetry | |
- name: Generate Code Usage Example | |
run: | | |
source .venv/bin/activate | |
patchwork GenerateCodeUsageExample --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--folder_path=tests/cicd/generate_docstring \ | |
--disable_telemetry | |
- name: Generate README | |
run: | | |
source .venv/bin/activate | |
# Specify the parent folder you want to check | |
PARENT_FOLDER="./patchwork/steps" | |
# Command to run if README.md is not found | |
find "$PARENT_FOLDER" -mindepth 1 -maxdepth 1 -type d | grep -vE '/\.\.?/' | grep -vE '/__' | while read -r dir; do | |
if [[ ! -f "$dir/README.md" ]]; then | |
echo "No README.md in $dir" | |
# Extract the last part of the path to use as a base for the branch name | |
base_name=$(basename "$dir") | |
# Convert to a Git-friendly branch name: replace spaces with underscores, remove slashes, etc. | |
branch_name=$(echo "$base_name" | sed -e 's/[^a-zA-Z0-9]/_/g' -e 's/__*/_/g' -e 's/^_//g' -e 's/_$//g') | |
patchwork GenerateREADME --log debug \ | |
--patched_api_key=${{ secrets.PATCHED_API_KEY }} \ | |
--github_api_key=${{ secrets.SCM_GITHUB_KEY }} \ | |
--filter=*.py \ | |
--folder_path=$dir \ | |
--branch_prefix=generatereadme-$branch_name \ | |
--disable_telemetry | |
else | |
echo "Found README.md in $dir" | |
fi | |
done |