Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
djschleen committed Apr 19, 2022
0 parents commit 11385b9
Show file tree
Hide file tree
Showing 38 changed files with 2,382 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @devops-kung-fu/the-incredibles
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /.github/workflows
schedule:
interval: daily
time: "05:00"
timezone: UTC
- package-ecosystem: gomod
directory: /
schedule:
interval: daily
time: "05:00"
timezone: UTC
67 changes: 67 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '32 16 * * 1'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: [ 'go' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
34 changes: 34 additions & 0 deletions .github/workflows/go-quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Go Quality Checks
on: push
jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'
- name: Install Dependencies
run: |
go version
go get -u golang.org/x/lint/golint
go get -u github.com/fzipp/gocyclo/cmd/gocyclo
- name: Tests
run: |
go test -v -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
- name: CodeCov
run: bash <(curl -s https://codecov.io/bash)
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Build
run: go build
- name: Vet
run: go vet -v
- name: Lint
run: golint ./...
- name: gocyclo
run: gocyclo .

150 changes: 150 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
name: gardener Release

on:
push:
tags:
- 'v*'

jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.upload_url.outputs.upload_url }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
This release has the following changes:
- README Updates.
draft: false
prerelease: false

- name: Fix Upload URL
id: upload_url
run: echo ::set-output name=upload_url::$(echo "${{ steps.create_release.outputs.upload_url }}" | cut -d"{" -f1)

- name: Echo upload url
run: echo "${{ steps.upload_url.outputs.upload_url }}"

build:
needs: release
strategy:
matrix:
os: ["darwin", "freebsd", "linux", "netbsd", "openbsd", "windows"]
arch: ["amd64", "arm64", "arm"]

env:
UPLOAD_URL: ${{ needs.release.outputs.upload_url }}

name: Build and Upload Assets
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: '1.16'

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\/v/}

- name: Generate SBOM
uses: CycloneDX/[email protected]
with:
include-stdlib: true
json: true
output: sbom.json
resolve-licenses: true
version: "^v0"

- name: Build amd64 Assets
if: matrix.arch == 'amd64'
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Build arm64 Assets
if: matrix.arch == 'arm64' && matrix.os == 'linux'
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Build arm Assets
if: matrix.arch == 'arm' && (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd')
run: |
echo "${{ matrix.os }} ${{ matrix.arch }}"
env GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o $FILE github.com/devops-kung-fu/gardener
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Upload SBoM
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: sbom.json

- name: Upload amd64 Non-Windows
if: matrix.os != 'windows' && matrix.arch == 'amd64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Upload amd64 Windows
if: matrix.os == 'windows' && matrix.arch == 'amd64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}.exe

- name: Upload arm64
if: matrix.os == 'linux' && matrix.arch == 'arm64'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}

- name: Upload arm
if: (matrix.os == 'freebsd' || matrix.os == 'netbsd' || matrix.os == 'openbsd') && matrix.arch == 'arm'
run: |
curl \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type $FILE)" \
--data-binary @$FILE \
"$UPLOAD_URL?name=$(basename $FILE)"
env:
FILE: build/gardener-${{ steps.get_version.outputs.VERSION }}-${{ matrix.os }}-${{ matrix.arch }}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

gardener.DS_Store
46 changes: 46 additions & 0 deletions .hookz.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
version: 2.3.0
hooks:
- type: pre-commit
actions:
- name: "git: Pull (Ensure there are no upstream changes that are not local)"
exec: git
args: ["pull"]
- name: "go: Tidy (Recursive)"
script: "
#!/bin/bash \n
echo -e Tidying all found go.mod occurrences\n
find . -name go.mod -print0 | xargs -0 -n1 dirname | xargs -L 1 bash -c 'cd \"$0\" && pwd && go mod tidy' \n
"
- name: "go: Update all dependencies to latest"
exec: go
args: ["get", "-u", "./..."]
- name: "gofmt: Run gofmt to format the code"
exec: gofmt
args: ["-s", "-w", "**/*.go"]
- name: "golint: Lint all go files"
exec: golint
args: ["./..."] #to error out, add the arg "-set_exit_status"
- name: "errcheck: Check that errors are checked"
exec: errcheck
args: ["-ignoretests", "./..."]
- name: "gocyclo: Check cyclomatic complexities"
exec: gocyclo
args: ["-over", "7", "."]
- name: "go: Build (Ensure pulled modules do not break the build)"
exec: go
args: ["build", "-v"]
- name: "go: Run all tests"
exec: go
args: ["test", "-v", "-coverprofile=coverage.out", "./..."]
- name: "go: Test coverage"
exec: go
args: ["tool", "cover", "-func=coverage.out"]
- name: "cyclone-dx: Generate a Software Bill of Materials (SBoM)"
exec: cyclonedx-gomod
args: ["app", "-json", "-output", "gardener-sbom.json"]
- name: Hinge
url: https://github.com/devops-kung-fu/hinge/releases/download/v0.1.1/hinge-0.1.1-%%PLATFORM%%-amd64
args: ["."]
- name: "git: Add all changed files during the pre-commit stage"
exec: git
args: ["add", "."]
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${workspaceFolder}/main.go",
"args": ["generate", "."]
}
]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cSpell.words": [
"afero",
"PLANTUML"
]
}
Loading

0 comments on commit 11385b9

Please sign in to comment.