Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added linting to CI #11

Merged
merged 13 commits into from
Jun 21, 2024
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Ci

on:
pull_request:
branches: [ master, development ]

jobs:
build:
name: Build binary
runs-on: ubuntu-latest
container:
image: golangci/golangci-lint:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Make repo safe
run: git config --global --add safe.directory /__w/SOARCA-GUI/SOARCA-GUI
- name: Install Templ
run: go install github.com/a-h/templ/cmd/templ@latest

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
- run: npm ci

- name: Build with make
run: make build

lint:
name: Lint go code with golangci
runs-on: ubuntu-latest
container:
image: golangci/golangci-lint:latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Templ
run: go install github.com/a-h/templ/cmd/templ@latest

- name: lint
run: |
ls -la
make lint
shell: bash
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: dev-server dev-tailwind dev-templ dev build-server build-tailwind build-templ build launch deploy
.PHONY: dev-server dev-tailwind dev-templ dev build-server build-tailwind build-templ build launch deploy clean

#-----------------------------------------------------
# DEV
Expand Down Expand Up @@ -41,7 +41,7 @@ dev-tailwind:
# BUILD
#-----------------------------------------------------

build: build-tailwind build-server build-templ
build: build-templ build-tailwind build-server

build-server:
@go build -o bin/server ./server/main.go
Expand All @@ -52,4 +52,11 @@ build-templ:
build-tailwind:
@npx tailwindcss -m -i ./views/assets/app.css -o ./public/public/styles.css $(ARGS)

lint: build-templ
GOFLAGS=-buildvcs=false golangci-lint run --timeout 5m0s -v

clean:
find . -type f -name '*_templ.go' -exec rm -f {} ls **/*_templ.go


.DEFAULT_GOAL := dev
File renamed without changes.
12 changes: 6 additions & 6 deletions handlers/dashboard.handler.go → handlers/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ func HomeDashboard(context *gin.Context) {
}

func ReportingDashboard(context *gin.Context) {

render := utils.NewTempl(context, http.StatusOK,
reporting.ReportingIndex())

context.Render(http.StatusOK, render)
}

func ReportingCard(context *gin.Context) {

id := context.Param("id")
fmt.Println(id)
updatedCard := components.ReportingCardData{Loaded: true,
ID: fmt.Sprint(id),
Value: 10,
Name: "Executed Playbooks"}
updatedCard := components.ReportingCardData{
Loaded: true,
ID: fmt.Sprint(id),
Value: 10,
Name: "Executed Playbooks",
}
render := utils.NewTempl(context, http.StatusOK, components.ReportingCard(updatedCard))

context.Render(http.StatusOK, render)
Expand Down
2 changes: 1 addition & 1 deletion public/public/styles.css

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion server/main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"fmt"

"soarca-gui/routes"

"github.com/gin-gonic/gin"
Expand All @@ -15,5 +17,9 @@ func main() {
app := gin.Default()
routes.Setup(app)

app.Run(":8081")
err := app.Run(":8081")
if err != nil {
fmt.Println("failed to start server")
}
fmt.Println("exit")
}