Skip to content

Commit

Permalink
create unified lint CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed May 25, 2024
1 parent 0d627fe commit b3d4c37
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 98 deletions.
44 changes: 1 addition & 43 deletions .github/workflows/autogpt-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: AutoGPT Python CI
name: AutoGPT CI

on:
push:
Expand All @@ -24,48 +24,6 @@ defaults:
working-directory: autogpt

jobs:
lint:
runs-on: ubuntu-latest
env:
min-python-version: "3.10"

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.min-python-version }}

- id: get_date
name: Get date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Set up Python dependency cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles('autogpt/pyproject.toml') }}-${{ steps.get_date.outputs.date }}

- name: Install Python dependencies
run: |
curl -sSL https://install.python-poetry.org | python3 -
poetry install
- name: Lint with flake8
run: poetry run flake8

- name: Check black formatting
run: poetry run black . --check
if: success() || failure()

- name: Check isort formatting
run: poetry run isort . --check
if: success() || failure()

test:
permissions:
contents: read
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/autogpts-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: AutoGPTs smoke test CI
name: Agents smoke tests

on:
workflow_dispatch:
Expand Down Expand Up @@ -28,7 +28,7 @@ on:
- '!**/*.md'

jobs:
run-tests:
serve-agent-protocol:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
55 changes: 2 additions & 53 deletions .github/workflows/benchmark-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Benchmark CI
name: AGBenchmark CI

on:
push:
Expand All @@ -18,58 +18,7 @@ env:
min-python-version: '3.10'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.min-python-version }}

- id: get_date
name: Get date
working-directory: ./benchmark/
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Install Poetry
working-directory: ./benchmark/
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies
working-directory: ./benchmark/
run: |
export POETRY_VIRTUALENVS_IN_PROJECT=true
poetry install -vvv
- name: Lint with flake8
working-directory: ./benchmark/
run: poetry run flake8

- name: Check black formatting
working-directory: ./benchmark/
run: poetry run black . --exclude test.py --check
if: success() || failure()

- name: Check isort formatting
working-directory: ./benchmark/
run: poetry run isort . --check
if: success() || failure()

- name: Check for unused imports and pass statements
working-directory: ./benchmark/
run: |
cmd="poetry run autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports --ignore-pass-after-docstring agbenchmark"
$cmd --check || (echo "You have unused imports or pass statements, please run '${cmd} --in-place'" && exit 1)
if: success() || failure()

tests-agbenchmark:
self-test-with-agent:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
151 changes: 151 additions & 0 deletions .github/workflows/python-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
name: Python checks

on:
push:
branches: [ master, development, ci-test* ]
paths:
- '.github/workflows/lint-ci.yml'
- 'autogpt/**'
- 'forge/**'
- 'benchmark/**'
- '**.py'
- '!autogpt/tests/vcr_cassettes'
pull_request:
branches: [ master, development, release-* ]
paths:
- '.github/workflows/lint-ci.yml'
- 'autogpt/**'
- 'forge/**'
- 'benchmark/**'
- '**.py'
- '!autogpt/tests/vcr_cassettes'

concurrency:
group: ${{ format('lint-ci-{0}', github.head_ref && format('{0}-{1}', github.event_name, github.event.pull_request.number) || github.sha) }}
cancel-in-progress: ${{ startsWith(github.event_name, 'pull_request') }}

defaults:
run:
shell: bash

jobs:
get-changed-parts:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- id: changes-in
name: Determine affected subprojects
uses: dorny/paths-filter@v3
with:
filters: |
autogpt:
- autogpt/autogpt/**
- autogpt/tests/**
- autogpt/poetry.lock
forge:
- forge/forge/**
- forge/tests/**
- forge/poetry.lock
benchmark:
- benchmark/agbenchmark/**
- benchmark/tests/**
- benchmark/poetry.lock
outputs:
changed-parts: ${{ steps.changes-in.outputs.changes }}

lint:
needs: get-changed-parts
runs-on: ubuntu-latest
env:
min-python-version: "3.10"

strategy:
matrix:
sub-package: ${{ fromJson(needs.get-changed-parts.outputs.changed-parts) }}
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.min-python-version }}

- name: Set up Python dependency cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles(format('{0}/poetry.lock', matrix.sub-package)) }}

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -

# Install dependencies

- name: Install Python dependencies
run: poetry -C ${{ matrix.sub-package }} install

# Lint

- name: Lint (isort)
run: poetry run isort --check .
working-directory: ${{ matrix.sub-package }}

- name: Lint (Black)
if: success() || failure()
run: poetry run black --check .
working-directory: ${{ matrix.sub-package }}

- name: Lint (Flake8)
if: success() || failure()
run: poetry run flake8 .
working-directory: ${{ matrix.sub-package }}

types:
needs: get-changed-parts
runs-on: ubuntu-latest
env:
min-python-version: "3.10"

strategy:
matrix:
sub-package: ${{ fromJson(needs.get-changed-parts.outputs.changed-parts) }}
fail-fast: false

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.min-python-version }}

- name: Set up Python dependency cache
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: ${{ runner.os }}-poetry-${{ hashFiles(format('{0}/poetry.lock', matrix.sub-package)) }}

- name: Install Poetry
run: curl -sSL https://install.python-poetry.org | python3 -

# Install dependencies

- name: Install Python dependencies
run: poetry -C ${{ matrix.sub-package }} install

# Typecheck

- name: Typecheck
if: success() || failure()
run: poetry run pyright
working-directory: ${{ matrix.sub-package }}

0 comments on commit b3d4c37

Please sign in to comment.