Skip to content

Commit

Permalink
ci: add code linting and formatting workflow (#12)
Browse files Browse the repository at this point in the history
* ci: add code linting and formatting workflow

* fix node cache dependency path

* install pipenv

* specify node v20 to try to suppress warning
  • Loading branch information
Charlie-XIAO authored Nov 18, 2024
1 parent 06fc9df commit 1563cbd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Formatting and Linting

on:
push:
branches:
- main
pull_request:
branches:
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Python setup
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: pipenv
cache-dependency-path: app/backend/Pipfile.lock

- name: Install pipenv
run: pip install pipenv

- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Node setup and cache
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: app/frontend/pnpm-lock.yaml

- name: Install development dependencies
run: cd app && make devinstall

- name: Check code formatting and linting
run: cd app && make devlintcheck
6 changes: 6 additions & 0 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ devlock:
@cd backend && pipenv lock && pipenv sync -d && pipenv clean
@cd frontend && pnpm install

# [DEV] Install development dependencies on the host machine based on the lock
# files without modifying them
devinstall:
@cd backend && pipenv sync -d
@cd frontend && pnpm install --frozen-lockfile

# [DEV] Format and lint the codebase
devlint:
@cd backend && pipenv run bash -c "black . && ruff check --select I --fix . && ruff format . && mypy ."
Expand Down

0 comments on commit 1563cbd

Please sign in to comment.