Skip to content

Commit

Permalink
Add basis for CI
Browse files Browse the repository at this point in the history
  • Loading branch information
christophetd committed Apr 11, 2023
1 parent 030c2b4 commit 2573593
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 335 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: release

on:
push:
tags:
- "v*"

permissions:
contents: read

jobs:
goreleaser:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v2.5.0
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3.3.1
with:
go-version: 1.19
- name: Run GoReleaser
timeout-minutes: 60
uses: goreleaser/goreleaser-action@v3.2.0
with:
distribution: goreleaser
version: latest
args: release --rm-dist --config .goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "go static analysis"

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
static-analysis:
name: "Run Go static analysis"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- uses: dominikh/staticcheck-action@v1.2.0
with:
version: "2022.1"
install-go: false
27 changes: 27 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: read

jobs:
unit-test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Run unit tests
run: make test
41 changes: 41 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
ldflags:
- -X main.BuildVersion={{.Version}}

dir: cmd/managed-kubernetes-auditing-toolkit
binary: mkat
brews:
- name: managed-kubernetes-auditing-toolkit
tap:
owner: datadog
name: managed-kubernetes-auditing-toolkit
folder: Formula
url_template: "https://github.com/DataDog/managed-kubernetes-auditing-toolkit/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
license: Apache-2.0
homepage: "https://github.com/DataDog/managed-kubernetes-auditing-toolkit"
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
ROOT_DIR := $(dir $(MAKEFILE_PATH))
BUILD_VERSION=dev-snapshot

all:
mkdir -p bin
go build -o bin/mkat ./cmd/managed-kubernetes-auditing-toolkit/main.go
go build -ldflags="-X main.BuildVersion=$(BUILD_VERSION)" -o bin/mkat ./cmd/managed-kubernetes-auditing-toolkit/main.go

test:
go test ./... -v
Expand Down
2 changes: 1 addition & 1 deletion cmd/managed-kubernetes-auditing-toolkit/eks/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func BuildEksSubcommand() *cobra.Command {
figure.NewFigure("mkat", "", true).Print()
println()
if !utils.IsEKS() {
return errors.New("You do not seem to be connected to an EKS cluster. Connect to an EKS cluster and try again")
return errors.New("you do not seem to be connected to an EKS cluster. Connect to an EKS cluster and try again")
}
clusterName := utils.GetEKSClusterName()
if clusterName != "" {
Expand Down
9 changes: 6 additions & 3 deletions cmd/managed-kubernetes-auditing-toolkit/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package main
import (
"github.com/datadog/managed-kubernetes-auditing-toolkit/cmd/managed-kubernetes-auditing-toolkit/eks"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)

// BuildVersion is injected at compilation time
var BuildVersion = ""

var rootCmd = &cobra.Command{
Use: "mkat",
DisableFlagsInUseLine: true,
Expand All @@ -17,9 +19,10 @@ func init() {

rootCmd.AddCommand(eks.BuildEksSubcommand())
rootCmd.AddCommand(&cobra.Command{
Use: "autogen-docs",
Use: "version",
Short: "Display the current CLI version",
Run: func(cmd *cobra.Command, args []string) {
doc.GenMarkdownTree(rootCmd, "./docs")
println(BuildVersion)
},
})
}
Expand Down
17 changes: 0 additions & 17 deletions docs/mkat.md

This file was deleted.

19 changes: 0 additions & 19 deletions docs/mkat_autogen-docs.md

This file was deleted.

25 changes: 0 additions & 25 deletions docs/mkat_completion.md

This file was deleted.

44 changes: 0 additions & 44 deletions docs/mkat_completion_bash.md

This file was deleted.

35 changes: 0 additions & 35 deletions docs/mkat_completion_fish.md

This file was deleted.

32 changes: 0 additions & 32 deletions docs/mkat_completion_powershell.md

This file was deleted.

Loading

0 comments on commit 2573593

Please sign in to comment.