-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add github workflows, linters, and refactor code
- Loading branch information
Showing
25 changed files
with
296 additions
and
160 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Lines starting with '#' are comments. | ||
|
||
# Each line is a file pattern followed by one or more owners. | ||
|
||
# More details are here: https://help.github.com/articles/about-codeowners/ | ||
|
||
# The '\*' pattern is global owners. | ||
|
||
# Order is important. The last matching pattern has the most precedence. | ||
|
||
# The folders are ordered as follows: | ||
|
||
# In each subsection folders are ordered first by depth, then alphabetically. | ||
|
||
# This should make it easy to add new rules without breaking existing ones. | ||
|
||
# Global rule: | ||
|
||
* @nohehf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build Test | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "**.go" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
name: Test Builds | ||
strategy: | ||
matrix: | ||
go-version: [1.20.x] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Go Mod hygine | ||
run: | | ||
go clean -modcache | ||
go mod tidy | ||
- name: Build | ||
run: go build . | ||
working-directory: cmd/cli | ||
|
||
- name: Test | ||
run: go test ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Lint report | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- "**.go" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
report: | ||
name: Report | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.20" | ||
- name: Install report card | ||
run: | | ||
git clone https://github.com/gojp/goreportcard.git | ||
cd goreportcard | ||
make install | ||
go install ./cmd/goreportcard-cli | ||
cd .. | ||
rm -rf goreportcard | ||
- name: Report | ||
run: goreportcard-cli -v -t 100 | ||
|
||
golangci-lint: | ||
name: Lint (golangci-lint) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version: "1.22" | ||
cache: false | ||
- uses: actions/checkout@v3 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Release Binaries | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.20.x | ||
|
||
- uses: goreleaser/goreleaser-action@v4 | ||
with: | ||
args: "release --clean" | ||
version: latest | ||
env: | ||
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# update report card on push on main | ||
name: 🧚♀️ Update Report Card | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
report-card: | ||
name: Update Report Card | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Request Report Update | ||
run: | | ||
curl -X POST -F "repo=github.com/$GITHUB_REPOSITORY" https://goreportcard.com/checks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ go.work.sum | |
|
||
# env file | ||
.env | ||
|
||
# local binaries | ||
bin/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
linters: | ||
disable-all: true | ||
enable: | ||
# # default: https://golangci-lint.run/usage/linters/#enabled-by-default | ||
- errcheck | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- unused | ||
# # extras: https://golangci-lint.run/usage/linters/#disabled-by-default | ||
- gocyclo # Computes and checks the cyclomatic complexity of functions. | ||
- gocritic # Provides diagnostics that check for bugs, performance and style issues. | ||
# Extensible without recompilation through dynamic rules. | ||
# Dynamic rules are written declaratively with AST patterns, filters, report message and optional suggestion. | ||
- goconst # Finds repeated strings that could be replaced by a constant. | ||
- mnd # An analyzer to detect magic numbers. | ||
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint. | ||
- bodyclose # Checks whether HTTP response body is closed successfully. | ||
- durationcheck | ||
- gochecknoinits | ||
- containedctx | ||
- perfsprint | ||
- protogetter | ||
- spancheck | ||
- sloglint | ||
- noctx | ||
- exhaustive | ||
- contextcheck | ||
- whitespace | ||
fast: true | ||
linters-settings: | ||
exhaustive: | ||
check: | ||
- switch | ||
- map | ||
default-signifies-exhaustive: true | ||
severity: | ||
default-severity: error | ||
run: | ||
timeout: 5m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"recommendations": ["golang.go"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Go settings | ||
"go.lintTool": "golangci-lint", | ||
"go.useLanguageServer": true, | ||
"go.lintFlags": ["--fast", "--fix"], | ||
// Show logs even on test success | ||
"go.testFlags": ["-v"], | ||
"[go]": { | ||
"editor.defaultFormatter": "golang.go", | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": "explicit", | ||
"source.organizeImports": "explicit" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Developing | ||
|
||
## Dependencies | ||
|
||
- Go version >= 1.22.x | ||
- [golangci-lint](https://golangci-lint.run/welcome/install/#local-installation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.PHONY: lint | ||
lint: | ||
go run github.com/golangci/golangci-lint/cmd/[email protected] run --fast -- $(go list -f '{{.Dir}}/...' -m) | ||
|
||
.PHONY: pre-build | ||
pre-build: | ||
go run cmd/pre-build/pre-build.go | ||
|
||
.PHONY: build | ||
build: pre-build | ||
go build -o ./bin/cli ./cmd/cli/*.go | ||
|
||
.PHONY: test | ||
test: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"net" | ||
|
||
"escape.tech/cloudfinder/pkg/cloud" | ||
"escape.tech/cloudfinder/pkg/provider" | ||
) | ||
|
||
func main() { | ||
r := cloud.NewResolver() | ||
ip, err := net.LookupIP("escape.tech") | ||
if err != nil { | ||
// do something with your error | ||
} | ||
if len(ip) == 0 { | ||
// do something with your error | ||
} | ||
for _, i := range ip { | ||
p := r.GetProviderForIP(i) | ||
switch p { | ||
case provider.Aws: | ||
println("Yay got AWS as expected") | ||
case provider.Unknown: | ||
println("Seems like we could not find the provider... Thats weird.") | ||
default: | ||
println("Mmmmh seems like the provider is wrong...") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,3 @@ | ||
module escape.tech/cloudfinder | ||
|
||
go 1.22.5 | ||
|
||
require ( | ||
golang.org/x/mod v0.21.0 // indirect | ||
golang.org/x/sync v0.8.0 // indirect | ||
golang.org/x/tools v0.25.0 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= | ||
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= | ||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= | ||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= | ||
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE= | ||
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg= | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
�Ŷ��6|���������6�u;d֨�JoN�� | ||
�o�T��]���O��!1{�W|�}�91��h |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.