From 6994d1e713a85cb05d94e82b7f179afeb6e212df Mon Sep 17 00:00:00 2001 From: tylerslaton Date: Wed, 16 Oct 2024 16:36:59 -0400 Subject: [PATCH] feat: add better linting targets and CI Signed-off-by: tylerslaton --- .github/workflows/admin.yml | 32 ++++++++++++++++++++++++++++++++ .github/workflows/main.yml | 31 ------------------------------- Makefile | 18 +++++++++++++++++- go.mod | 1 - go.sum | 2 -- 5 files changed, 49 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/admin.yml delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/admin.yml b/.github/workflows/admin.yml new file mode 100644 index 000000000..04bffef57 --- /dev/null +++ b/.github/workflows/admin.yml @@ -0,0 +1,32 @@ +name: admin + +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 + + - name: Verify no changes + run: make no-changes 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..d0367c964 100644 --- a/Makefile +++ b/Makefile @@ -23,4 +23,20 @@ dev: ui @echo "Starting dev otto server and admin UI..." ./dev.sh -.PHONY: ui build all clean dev +# Lint the project +lint: lint-admin + +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-admin lint-api no-changes fmt tidy diff --git a/go.mod b/go.mod index bf587669b..a21641ecf 100644 --- a/go.mod +++ b/go.mod @@ -61,7 +61,6 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/NYTimes/gziphandler v1.1.1 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect - github.com/a-h/templ v0.2.778 // indirect github.com/a8m/envsubst v1.4.2 // indirect github.com/acorn-io/broadcaster v0.0.0-20240105011354-bfadd4a7b45d // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect diff --git a/go.sum b/go.sum index 2548d7d55..b0d1e0543 100644 --- a/go.sum +++ b/go.sum @@ -69,8 +69,6 @@ github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63n github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= -github.com/a-h/templ v0.2.778 h1:VzhOuvWECrwOec4790lcLlZpP4Iptt5Q4K9aFxQmtaM= -github.com/a-h/templ v0.2.778/go.mod h1:lq48JXoUvuQrU0VThrK31yFwdRjTCnIE5bcPCM9IP1w= github.com/a8m/envsubst v1.4.2 h1:4yWIHXOLEJHQEFd4UjrWDrYeYlV7ncFWJOCBRLOZHQg= github.com/a8m/envsubst v1.4.2/go.mod h1:MVUTQNGQ3tsjOOtKCNd+fl8RzhsXcDvvAEzkhGtlsbY= github.com/acorn-io/baaah v0.0.0-20240912163758-8f7c537609d1 h1:JobENeM/SoGMlR1/K6DCirRRwBA90FRlynqqqYchOXQ=