Add initial project setup with Go modules and CI/CD workflows
All checks were successful
Go CI/CD / go-ci (push) Successful in 11m13s
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:
parent
58e6c066be
commit
e65fc49b8e
50
.gitea/workflows/ci-basic.yml
Normal file
50
.gitea/workflows/ci-basic.yml
Normal 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 ./...
|
50
.gitea/workflows/ci-protected.yml
Normal file
50
.gitea/workflows/ci-protected.yml
Normal 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 ./...
|
43
.gitea/workflows/ci-tag.yml
Normal file
43
.gitea/workflows/ci-tag.yml
Normal 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
64
.gitignore
vendored
Normal 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
13
error.go
Normal 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:"-"`
|
||||
}
|
10
sonar-project.properties
Normal file
10
sonar-project.properties
Normal 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
|
Loading…
x
Reference in New Issue
Block a user