Skip to content

Commit

Permalink
feat: add better linting targets and CI
Browse files Browse the repository at this point in the history
Signed-off-by: tylerslaton <[email protected]>
  • Loading branch information
tylerslaton committed Oct 16, 2024
1 parent faefe47 commit 88e077b
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 33 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/admin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ui

on:
pull_request:
branches:
- main
paths:
- ui/admin/**

jobs:
lint:
runs-on: ubuntu-latest

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

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "20.17.0"

- name: Install dependencies
run: |
cd ui/admin
npm install
- name: Run linter
run: |
make lint-admin
24 changes: 24 additions & 0 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: UI

on:
pull_request:
branches:
- main
paths:
- "**/*.go"

jobs:
lint:
runs-on: ubuntu-latest

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

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.3"

- name: Run linter
run: make lint-api
31 changes: 0 additions & 31 deletions .github/workflows/main.yml

This file was deleted.

22 changes: 21 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,24 @@ dev: ui
@echo "Starting dev otto server and admin UI..."
./dev.sh

.PHONY: ui build all clean dev
# Lint the project
lint: lint-ui lint-api no-changes

lint-api:
go fmt ./... && \
go vet ./...

lint-admin:
cd ui/admin && \
npm run format && \
npm run lint

no-changes:
@if [ -n "$$(git status --porcelain)" ]; then \
git status --porcelain; \
git --no-pager diff; \
echo "Encountered dirty repo!"; \
exit 1; \
fi

.PHONY: ui build all clean dev lint lint-ui no-changes
5 changes: 4 additions & 1 deletion ui/admin/app/lib/routers/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ const buildUrl = (path: string, params?: object) => {
? queryString.stringify(params, { skipNull: true })
: "";

if (process.env.NODE_ENV === "production" || import.meta.env.VITE_API_IN_BROWSER === "true") {
if (
process.env.NODE_ENV === "production" ||
import.meta.env.VITE_API_IN_BROWSER === "true"
) {
return {
url: prodBaseUrl + path + (query ? "?" + query : ""),
path,
Expand Down

0 comments on commit 88e077b

Please sign in to comment.