Skip to content

Commit

Permalink
🎉 Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zcubbs committed Sep 26, 2023
0 parents commit 6c58895
Show file tree
Hide file tree
Showing 35 changed files with 3,298 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
root = true

[*]
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_style = space
indent_size = 2

[{Makefile,go.mod,go.sum,*.go,.gitmodules}]
indent_style = tab
indent_size = 4

[*.md]
indent_size = 4
trim_trailing_whitespace = false

[Taskfile.yaml]
indent_style = tab
44 changes: 44 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lint

on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/**'
- 'LICENSE'
- 'Taskfile.yaml'
- '.gitignore'
- '.gosec.config.json'
- '.editorconfig'
- '.goreleaser.yaml'

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3

- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
go-version: '1.20'

- name: Install Task
uses: arduino/setup-task@v1.0.3
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Linter
run: task tools:install:golangci-lint

- name: Lint
run: task lint
56 changes: 56 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release

on:
workflow_dispatch:
inputs:
semver:
type: string
description: 'Semver (eg: v1.2.3)'
required: true
permissions:
contents: write
jobs:
release:
if: github.triggering_actor == 'zcubbs'
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3

- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
go-version: '1.21'

# remove tests in order to clean dependencies
- name: Remove xxx_test.go files
run: rm -rf *_test.go ./examples ./images

# cleanup test dependencies
- name: Cleanup dependencies
run: go mod tidy

- name: List files
run: tree -Cfi
- name: Write new go.mod into logs
run: cat go.mod
- name: Write new go.sum into logs
run: cat go.sum

- name: Create tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name '${{ github.triggering_actor }}'
git config --global user.email "${{ github.triggering_actor}}@users.noreply.github.com"
git add .
git commit --allow-empty -m 'bump ${{ inputs.semver }}'
git tag ${{ inputs.semver }}
git push origin ${{ inputs.semver }}
- name: Release
uses: softprops/action-gh-release@v1
with:
name: ${{ inputs.semver }}
tag_name: ${{ inputs.semver }}
44 changes: 44 additions & 0 deletions .github/workflows/scan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Scan

on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/**'
- 'LICENSE'
- 'Taskfile.yaml'
- '.gitignore'
- '.gosec.config.json'
- '.editorconfig'
- '.goreleaser.yaml'

jobs:
scan:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3

- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
go-version: '1.20'

- name: Install Task
uses: arduino/setup-task@v1.0.3
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Security Scanner
run: task tools:install:gosec

- name: Run Go Security Scanner
run: task scan
47 changes: 47 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Test

on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
branches:
- main
paths-ignore:
- 'README.md'
- 'docs/**'
- '.github/**'
- 'LICENSE'
- 'Taskfile.yaml'
- '.gitignore'
- '.gosec.config.json'
- '.editorconfig'
- '.goreleaser.yaml'

jobs:
test:
runs-on: ubuntu-latest
services:
mailhog:
image: mailhog/mailhog
ports:
- 1025:1025
- 8025:8025

steps:
- name: Checkout Code
uses: actions/checkout@v3.5.3

- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
go-version: '1.20'

- name: Install Task
uses: arduino/setup-task@v1.0.3
with:
version: 3.x
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test
run: task test
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/.idea/
*.iml
9 changes: 9 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
linters-settings:
gosec:
# To specify a set of rules to explicitly exclude.
# Available rules: https://github.com/securego/gosec#available-rules
excludes:
- G204 # Audit use of command execution
- G304 # File path provided as taint input
- G303 # Creating tempfile using a predictable path
- G306 # Poor file permissions used when writing to a new file
5 changes: 5 additions & 0 deletions .gosec.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"global": {
"exclude": "G204,G302,G303,G304,G306,G404,G402"
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Zakaria EL BOUWAB

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Go K8s

A K8s collection of Go Packages.

[![tag](https://img.shields.io/github/tag/zcubbs/go-k8s)](https://github.com/zcubbs/go-k8s/releases)
![Go Version](https://img.shields.io/badge/Go-%3E%3D%201.21-%23007d9c)
[![GoDoc](https://godoc.org/github.com/zcubbs/go-k8s?status.svg)](https://pkg.go.dev/github.com/zcubbs/go-k8s)
[![Lint](https://github.com/zcubbs/go-k8s/actions/workflows/lint.yaml/badge.svg)](https://github.com/zcubbs/go-k8s/actions/workflows/lint.yaml)
[![Scan](https://github.com/zcubbs/go-k8s/actions/workflows/scan.yaml/badge.svg?branch=main)](https://github.com/zcubbs/go-k8s/actions/workflows/scan.yaml)
![Build Status](https://github.com/zcubbs/go-k8s/actions/workflows/test.yaml/badge.svg)
[![Go Report Card](https://goreportcard.com/badge/github.com/zcubbs/go-k8s)](https://goreportcard.com/report/github.com/zcubbs/go-k8s)
[![Contributors](https://img.shields.io/github/contributors/zcubbs/go-k8s)](https://github.com/zcubbs/go-k8s/graphs/contributors)
[![License](https://img.shields.io/github/license/zcubbs/go-k8s.svg)](./LICENSE)
41 changes: 41 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
version: '3'

env:
GOOS: "{{OS}}"

tasks:
build:
desc: Build Go Binaries
cmds:
- go build -v ./...

test:
desc: Run tests
cmds:
- go test -v ./...

lint:
desc: Run linter
cmds:
- golangci-lint run ./... -v --timeout 5m

scan:
desc: Run security scan
cmds:
- gosec -conf .gosec.config.json "./..."

tools:
desc: Install tools
cmds:
- task: tools:install:golangci-lint
- task: tools:install:gosec

tools:install:golangci-lint:
desc: Install golangci-lint
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

tools:install:gosec:
desc: Install gosec
cmds:
- go install github.com/securego/gosec/v2/cmd/gosec@latest
Loading

0 comments on commit 6c58895

Please sign in to comment.