Skip to content

Commit

Permalink
added linting to CI (#11)
Browse files Browse the repository at this point in the history
* added linting to CI

* added node to install ci

* remove test ci

* fix bug in go lint ci

* removed safe repo

* renaming of handler files

* changed order of build make file command + installer for templ in ci cd

* fix rename from swaggo to templ

* addded build tempol to lint

* addressed linting issue

* added installer for templ to the lint action

* make repo safe!

* vcs disable false
  • Loading branch information
RabbITCybErSeC authored Jun 21, 2024
1 parent 4cbf153 commit adbc03b
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 10 deletions.
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")
}

0 comments on commit adbc03b

Please sign in to comment.