Skip to content

Commit

Permalink
Setup basic CI pipeline as a GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Sep 8, 2023
1 parent 2f04a86 commit febd74e
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 39 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CI
on: [pull_request]

env:
GO_VERSION: '1.21'

jobs:
linters:
name: Linters
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Install vendors
run: make deps

- name: Run golangci-lint
run: make lint

tests:
name: Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-go@v3
with:
go-version: 1.21
cache: true

- name: Install vendors
run: make deps

- name: Tests
run: make tests
40 changes: 40 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
linters:
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- gochecknoinits
- gocritic
- gocyclo
- gofmt
- goimports
- misspell
- nakedret
- prealloc
- exportloopref
- stylecheck
- unconvert
- unparam
- gosec
- revive
- gochecknoglobals
disable:
- dupl
- lll
- maligned
- goconst
- depguard

linters-settings:
errcheck:
ignore: fmt:.*

run:
modules-download-mode: vendor
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GOLANGCI_LINT_VERSION='v1.54.2'

.PHONY: lint
lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION} golangci-lint run -c .golangci.yaml

.PHONY: tests
tests:
go test -v ./...

.PHONY: deps
deps:
go mod vendor
72 changes: 33 additions & 39 deletions sandbox/builder/main.go
Original file line number Diff line number Diff line change
@@ -1,46 +1,40 @@
package main

import (
"fmt"

"github.com/grafana/cog/generated/dashboard/dashboard"
"github.com/grafana/cog/generated/dashboard/timepicker"
types "github.com/grafana/cog/generated/types/dashboard"
)

func main() {
refresh := "1m"
/*
refresh := "1m"
builder, err := dashboard.New(
"Some title",
dashboard.Uid("test-dashboard-codegen"),
dashboard.Description("Some description"),
dashboard.Time("now-3h", "now"),
dashboard.Timepicker(
timepicker.RefreshIntervals([]string{"30s", "1m", "5m"}),
),
dashboard.Style(types.StyleDark),
dashboard.Timezone("utc"),
dashboard.Tooltip(types.Crosshair),
dashboard.Tags([]string{"generated", "from", "cue"}),
dashboard.Links([]types.DashboardLink{
{
Title: "Some link",
Url: "http://google.com",
AsDropdown: false,
TargetBlank: true,
},
}),
builder, err := dashboard.New(
"Some title",
dashboard.Uid("test-dashboard-codegen"),
dashboard.Description("Some description"),
dashboard.Time("now-3h", "now"),
dashboard.Timepicker(
timepicker.RefreshIntervals([]string{"30s", "1m", "5m"}),
),
dashboard.Style(types.StyleDark),
dashboard.Timezone("utc"),
dashboard.Tooltip(types.Crosshair),
dashboard.Tags([]string{"generated", "from", "cue"}),
dashboard.Links([]types.DashboardLink{
{
Title: "Some link",
Url: "http://google.com",
AsDropdown: false,
TargetBlank: true,
},
}),
dashboard.Refresh(types.StringOrBool{ValString: &refresh}),
)
if err != nil {
panic(err)
}
dashboard.Refresh(types.StringOrBool{ValString: &refresh}),
)
if err != nil {
panic(err)
}
dashboardJson, err := builder.Internal().MarshalIndentJSON()
if err != nil {
panic(err)
}
fmt.Println(string(dashboardJson))
dashboardJson, err := builder.Internal().MarshalIndentJSON()
if err != nil {
panic(err)
}
fmt.Println(string(dashboardJson))
*/
}

0 comments on commit febd74e

Please sign in to comment.