Skip to content

Commit

Permalink
feat: Parallelize lint-and-format.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorrr authored Apr 15, 2024
1 parent 9b69abc commit 4bea894
Showing 1 changed file with 75 additions and 66 deletions.
141 changes: 75 additions & 66 deletions .github/workflows/lint-and-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,80 @@ name: Lint and format APIs and SDKs
run-name: ${{ github.actor }} is linting and formatting the code
on: [push, pull_request]
jobs:
Lint-And-Format-APIs-And-SDKs:

name: Lint and format APIs and SDKs

on: [push, pull_request]

jobs:
Lint-And-Format:
runs-on: ubuntu-latest

strategy:
matrix:
directory: [agents-api, model-serving, sdks/python]

steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Configure Poetry to use .venv
run: |
poetry config virtualenvs.in-project true
- name: Cache Poetry virtualenv for Agents API
uses: actions/cache@v3
with:
path: agents-api/.venv
key: ${{ runner.os }}-poetry-agents-api-${{ hashFiles('agents-api/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-agents-api-
- name: Cache Poetry virtualenv for Models API
uses: actions/cache@v3
with:
path: model-serving/.venv
key: ${{ runner.os }}-poetry-model-serving-${{ hashFiles('model-serving/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-model-serving-
- name: Cache Poetry virtualenv for Python SDK
uses: actions/cache@v3
with:
path: sdks/python/.venv
key: ${{ runner.os }}-poetry-python-sdk-${{ hashFiles('sdks/python/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-python-sdk-
- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: sdks/ts/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('sdks/ts/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Lint and format Agents API
run: |
cd agents-api
poetry install
poetry run poe check
- name: Lint and format Models API
run: |
cd model-serving
poetry install
poetry run poe check
- name: Lint and format Python SDK
run: |
cd sdks/python
poetry install
poetry run poe check
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "🎨 Auto-format code with black"
branch: ${{ github.head_ref }}
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install and configure Poetry
uses: snok/install-poetry@v1

- name: Configure Poetry to use .venv
run: |
cd ${{ matrix.directory }}
poetry config virtualenvs.in-project true
- name: Cache Poetry virtualenv
uses: actions/cache@v3
with:
path: ${{ matrix.directory }}/.venv
key: ${{ runner.os }}-poetry-${{ matrix.directory }}-${{ hashFiles(format('{0}/poetry.lock', matrix.directory)) }}
restore-keys: |
${{ runner.os }}-poetry-${{ matrix.directory }}-
- name: Lint and format
run: |
cd ${{ matrix.directory }}
poetry install
poetry run poe check
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "refactor: Lint ${{ matrix.directory }} (CI)"
branch: ${{ github.head_ref }}

Lint-And-Format-TS-SDK:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '14.x'

- name: Cache npm dependencies
uses: actions/cache@v3
with:
path: sdks/ts/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('sdks/ts/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Lint and format TypeScript SDK
run: |
cd sdks/ts
npm ci
npm run lint
npm run format
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "refactor: Lint sdks/ts (CI)"
branch: ${{ github.head_ref }}

0 comments on commit 4bea894

Please sign in to comment.