Skip to content

Commit adbc03b

Browse files
added linting to CI (#11)
* 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
1 parent 4cbf153 commit adbc03b

File tree

6 files changed

+72
-10
lines changed

6 files changed

+72
-10
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Ci
2+
3+
on:
4+
pull_request:
5+
branches: [ master, development ]
6+
7+
jobs:
8+
build:
9+
name: Build binary
10+
runs-on: ubuntu-latest
11+
container:
12+
image: golangci/golangci-lint:latest
13+
steps:
14+
- name: Checkout Code
15+
uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- name: Make repo safe
19+
run: git config --global --add safe.directory /__w/SOARCA-GUI/SOARCA-GUI
20+
- name: Install Templ
21+
run: go install github.com/a-h/templ/cmd/templ@latest
22+
23+
- name: Setup node
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: 18
27+
- run: npm ci
28+
29+
- name: Build with make
30+
run: make build
31+
32+
lint:
33+
name: Lint go code with golangci
34+
runs-on: ubuntu-latest
35+
container:
36+
image: golangci/golangci-lint:latest
37+
steps:
38+
- name: Checkout Code
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
- name: Install Templ
43+
run: go install github.com/a-h/templ/cmd/templ@latest
44+
45+
- name: lint
46+
run: |
47+
ls -la
48+
make lint
49+
shell: bash

Makefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: dev-server dev-tailwind dev-templ dev build-server build-tailwind build-templ build launch deploy
1+
.PHONY: dev-server dev-tailwind dev-templ dev build-server build-tailwind build-templ build launch deploy clean
22

33
#-----------------------------------------------------
44
# DEV
@@ -41,7 +41,7 @@ dev-tailwind:
4141
# BUILD
4242
#-----------------------------------------------------
4343

44-
build: build-tailwind build-server build-templ
44+
build: build-templ build-tailwind build-server
4545

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

55+
lint: build-templ
56+
GOFLAGS=-buildvcs=false golangci-lint run --timeout 5m0s -v
57+
58+
clean:
59+
find . -type f -name '*_templ.go' -exec rm -f {} ls **/*_templ.go
60+
61+
5562
.DEFAULT_GOAL := dev
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ func HomeDashboard(context *gin.Context) {
1818
}
1919

2020
func ReportingDashboard(context *gin.Context) {
21-
2221
render := utils.NewTempl(context, http.StatusOK,
2322
reporting.ReportingIndex())
2423

2524
context.Render(http.StatusOK, render)
2625
}
2726

2827
func ReportingCard(context *gin.Context) {
29-
3028
id := context.Param("id")
3129
fmt.Println(id)
32-
updatedCard := components.ReportingCardData{Loaded: true,
33-
ID: fmt.Sprint(id),
34-
Value: 10,
35-
Name: "Executed Playbooks"}
30+
updatedCard := components.ReportingCardData{
31+
Loaded: true,
32+
ID: fmt.Sprint(id),
33+
Value: 10,
34+
Name: "Executed Playbooks",
35+
}
3636
render := utils.NewTempl(context, http.StatusOK, components.ReportingCard(updatedCard))
3737

3838
context.Render(http.StatusOK, render)

public/public/styles.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

server/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package main
22

33
import (
4+
"fmt"
5+
46
"soarca-gui/routes"
57

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

18-
app.Run(":8081")
20+
err := app.Run(":8081")
21+
if err != nil {
22+
fmt.Println("failed to start server")
23+
}
24+
fmt.Println("exit")
1925
}

0 commit comments

Comments
 (0)