-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
220 additions
and
1 deletion.
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 @@ | ||
@kmesiab |
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,33 @@ | ||
name: Build | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
|
||
build_go: | ||
name: "🏗 Compile" | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛒 Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🚀 Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.21.4' | ||
cache: true | ||
check-latest: true | ||
|
||
- name: 🧹 Tidy | ||
run: go mod tidy | ||
|
||
- name: 🤖 Build | ||
run: go build ./... |
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,52 @@ | ||
name: Lint | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
|
||
lint-markdown: | ||
|
||
name: "🧹 Markdown" | ||
continue-on-error: true | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛒 Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 📦 Install Node.js and npm | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.0.0' | ||
|
||
- name: 📚 Install markdownlint-cli | ||
run: npm install -g markdownlint-cli | ||
|
||
- name: 🖊️ Run markdownlint | ||
run: find . -name '*.md' -exec markdownlint {} + | ||
|
||
lint_go: | ||
name: "️️🕵️ Golang" | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 🛒 Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: 🚀 Set up Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.21.4' | ||
cache: true | ||
check-latest: true | ||
|
||
- name: 🕵️♂️ Run GolangCI-Lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v1.54 |
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,46 @@ | ||
name: Test | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
build: | ||
name: 🧪 Unit Tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21.4 | ||
|
||
- name: 🏗 Install dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y xorg-dev libgl1-mesa-dev | ||
- name: Set up gotestfmt | ||
run: go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest | ||
|
||
# Run tests with nice formatting. Save the original log in /tmp/gotest.log | ||
- name: 🧪 Execute Tests | ||
run: | | ||
set -euo pipefail | ||
go test -json -v ./... 2>&1 | tee /tmp/gotest.log | gotestfmt | ||
# Upload the original go test log as an artifact for later review. | ||
- name: Upload test log | ||
uses: actions/upload-artifact@v2 | ||
if: always() | ||
with: | ||
name: test-log | ||
path: /tmp/gotest.log | ||
if-no-files-found: error |
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 @@ | ||
.env | ||
.idea | ||
.DS_Store |
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,77 @@ | ||
# Phony Targets | ||
.PHONY: all build test install-tools lint run run-debug invoke | ||
|
||
# Meta Targets | ||
all: install-tools build test lint | ||
|
||
# Build Targets | ||
build: go-mod-tidy go-build | ||
|
||
# Build and run the application | ||
build-and-run: | ||
@echo ">>>>> Starting app" | ||
@go mod tidy -go=1.21 && go build -o cadre && ./cadre | ||
|
||
go-mod-tidy: | ||
@echo "🧹 Running go mod tidy" | ||
@go mod tidy -go=1.21 | ||
|
||
go-build: | ||
@echo "🔨 Building Go binaries" | ||
@go build -ldflags="-s -w" ./... | ||
|
||
# Test Targets | ||
test: test-basic | ||
|
||
test-basic: | ||
@echo "🧪 Running tests" | ||
@go test -cover ./... | ||
|
||
test-verbose: | ||
@echo "📝 Running tests with verbose output" | ||
@go test -v -cover ./... | ||
|
||
test-race: | ||
CGO_ENABLED=1 go test -race -cover ./... | ||
|
||
# Tooling | ||
install-tools: | ||
@echo "🛠️ Installing tools" | ||
@go install mvdan.cc/gofumpt@latest | ||
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest | ||
|
||
# Linting | ||
lint: lint-golangci lint-fumpt lint-markdown | ||
|
||
lint-fumpt: | ||
@echo "🧹 Running gofumpt linter" | ||
@gofumpt -l -w . | ||
|
||
lint-golangci: | ||
@echo "🐳 Running golangci linters" | ||
@golangci-lint run | ||
|
||
lint-go: | ||
@echo "🐳 Running Go linters in Docker" | ||
@docker run -t --rm -v $$(pwd):/app -w /app golangci/golangci-lint:v1.54.2 golangci-lint run -v \ | ||
-E bodyclose \ | ||
-E exportloopref \ | ||
-E forcetypeassert \ | ||
-E goconst \ | ||
-E gocritic \ | ||
-E misspell \ | ||
-E noctx \ | ||
-E nolintlint \ | ||
-E prealloc \ | ||
-E predeclared \ | ||
-E reassign \ | ||
-E sqlclosecheck \ | ||
-E stylecheck \ | ||
-E varnamelen \ | ||
-E wastedassign \ | ||
-E staticcheck | ||
|
||
lint-markdown: | ||
@echo "📚 Running Markdown linters with npm" | ||
@if [ -z $$(which markdownlint) ]; then npm install -g markdownlint-cli; fi | ||
@markdownlint $$(find ./. -name '*.md') |
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,8 @@ | ||
# cadre | ||
# Cadre 💻 | ||
|
||
![Golang](https://img.shields.io/badge/Go-00add8.svg?labelColor=171e21&style=for-the-badge&logo=go) | ||
|
||
![Build](https://github.com/kmesiab/cadre/actions/workflows/go-build.yml/badge.svg) | ||
![Build](https://github.com/kmesiab/cadre/actions/workflows/go-lint.yml/badge.svg) | ||
![Build](https://github.com/kmesiab/cadre/actions/workflows/go-test.yml/badge.svg) | ||
[![Go Report Card](https://goreportcard.com/badge/github.com/kmesiab/cadre)](https://goreportcard.com/report/github.com/kmesiab/cadre) |