diff --git a/.github/workflows/admin.yml b/.github/workflows/admin.yml new file mode 100644 index 000000000..d6c09d50f --- /dev/null +++ b/.github/workflows/admin.yml @@ -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 diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml new file mode 100644 index 000000000..321242bf4 --- /dev/null +++ b/.github/workflows/api.yml @@ -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 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index f539171a5..000000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Lint & Build - -on: - pull_request: - branches: - - main - paths: - - ui/admin/** - -jobs: - lint: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: "20.17.0" - - - name: Install dependencies - run: | - cd ui/admin - npm install - - - name: Run linter - run: | - cd ui/admin - npm run lint diff --git a/Makefile b/Makefile index 37d919cc2..8fcda9bfe 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/ui/admin/app/lib/routers/apiRoutes.ts b/ui/admin/app/lib/routers/apiRoutes.ts index 9d49e0962..77eeffb37 100644 --- a/ui/admin/app/lib/routers/apiRoutes.ts +++ b/ui/admin/app/lib/routers/apiRoutes.ts @@ -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,