Add initial project setup with Go modules and CI/CD workflows
All checks were successful
Go CI/CD / go-ci (push) Successful in 11m13s

This commit initializes the project with Go module support and a basic `StoneError` struct. It also introduces .gitignore, SonarQube configuration, and multiple CI/CD workflows for branch, tag, and protected branch scenarios to automate testing, static analysis, and builds.
This commit is contained in:
Rene Nochebuena 2025-04-12 16:51:32 -06:00
parent 58e6c066be
commit e65fc49b8e
Signed by: Rene Nochebuena
GPG Key ID: A9FD83117EA538D8
7 changed files with 233 additions and 0 deletions

View File

@ -0,0 +1,50 @@
name: Go CI/CD
run-name: ${{ github.actor }} is running CI/CD basic
on:
push:
branches-ignore:
- main
- release/**
- develop
pull_request:
branches-ignore:
- main
- release/**
- develop
jobs:
go-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Download dependencies
shell: bash
run: |
go mod tidy -x
- name: Run tests
shell: bash
run: |
go test -json > test-report.out
go test -coverprofile=coverage.out
- name: SonarQube Analysis
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
- name: Build binary
shell: bash
run: |
go build ./...

View File

@ -0,0 +1,50 @@
name: Go CI/CD
run-name: ${{ github.actor }} is running CI/CD protected
on:
push:
branches:
- main
- release/**
- develop
pull_request:
branches:
- main
- release/**
- develop
jobs:
go-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Download dependencies
shell: bash
run: |
go mod tidy -x
- name: Run tests
shell: bash
run: |
go test -json > test-report.out
go test -coverprofile=coverage.out
- name: SonarQube Analysis
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
- name: Build binary
shell: bash
run: |
go build ./...

View File

@ -0,0 +1,43 @@
name: Go CI/CD
run-name: ${{ github.actor }} is running CI/CD Tag
on:
push:
tags:
- '*'
jobs:
go-ci:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Download dependencies
shell: bash
run: |
go mod tidy -x
- name: Run tests
shell: bash
run: |
go test -json > test-report.out
go test -coverprofile=coverage.out
- name: SonarQube Analysis
uses: SonarSource/sonarqube-scan-action@v5
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ vars.SONAR_HOST_URL }}
- name: Build binary
shell: bash
run: |
go build ./...

64
.gitignore vendored Normal file
View File

@ -0,0 +1,64 @@
# Binaries for programs and plugins
bin
*.exe
*.dll
*.so
*.dylib
*.test
# Output of the 'go tool cover' command
*.out
coverage.xml
test-report.xml
# Directory for Go modules
/vendor/
# Go workspace file
go.work
go.work.sum
# Editor configs
*.swp
*.swo
*.bak
*.tmp
*.log
*.viminfo
*.un~
Session.vim
# JetBrains Rider specific
.idea/
*.iml
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/shelf/
# Sublime Text specific
*.sublime-workspace
*.sublime-project
# VSCode specific
.vscode/
.vscode/settings.json
.vscode/tasks.json
.vscode/launch.json
# Emacs specific
*~
\#*\#
.#*
# MacOS specific
.DS_Store
.AppleDouble
.LSOverride
# Node modules (in case of tools/scripts)
node_modules/
# Python virtual environments (for dev tools/scripts)
venv/
*.pyc
__pycache__/

13
error.go Normal file
View File

@ -0,0 +1,13 @@
package stoneerror
import (
"time"
)
type StoneError struct {
Code int `json:"code"`
Message string `json:"message"`
Time time.Time `json:"time"`
Metadata map[string]interface{} `json:"metadata"`
Err error `json:"-"`
}

3
go.mod Normal file
View File

@ -0,0 +1,3 @@
module stoneerror
go 1.24

10
sonar-project.properties Normal file
View File

@ -0,0 +1,10 @@
sonar.projectKey=f91c1ade-619a-4d18-b7c9-5143b0c7bd47
sonar.projectName=stone-utils/stoneerror
sonar.language=go
sonar.sources=.
sonar.exclusions=**/*_test.go
sonar.tests=.
sonar.test.inclusions=**/*_test.go
sonar.go.tests.reportPaths=test-report.out
sonar.go.coverage.reportPaths=coverage.out
sonar.qualitygate.wait=true