Skip to content

Commit 8e45f99

Browse files
author
agilira
committed
Initial release v1.0.0
Add reusable GitHub Actions workflows for Go projects: - Comprehensive CI/CD pipeline (go-ci-full.yml) - Fast PR validation workflow (go-pr-quick.yml) - Intelligent dependabot auto-merge workflow - Standardized configuration templates - Complete documentation and usage examples - Quality gates and security scanning - Cross-platform testing support - AGILira project standards
1 parent e9c50c4 commit 8e45f99

File tree

8 files changed

+659
-0
lines changed

8 files changed

+659
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Dependabot Auto-merge
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
ci-check-name:
7+
description: 'Name of the CI check to wait for'
8+
required: false
9+
default: 'ci'
10+
type: string
11+
timeout-seconds:
12+
description: 'Timeout in seconds for waiting CI'
13+
required: false
14+
default: 600
15+
type: number
16+
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
checks: read
21+
22+
jobs:
23+
dependabot:
24+
runs-on: ubuntu-latest
25+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
26+
steps:
27+
- name: Dependabot metadata
28+
id: metadata
29+
uses: dependabot/fetch-metadata@v2
30+
with:
31+
github-token: "${{ secrets.GITHUB_TOKEN }}"
32+
33+
- name: Wait for CI checks
34+
uses: fountainhead/action-wait-for-check@v1.2.0
35+
id: wait-for-ci
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
checkName: ${{ inputs.ci-check-name }}
39+
ref: ${{ github.event.pull_request.head.sha }}
40+
timeoutSeconds: ${{ inputs.timeout-seconds }}
41+
intervalSeconds: 10
42+
43+
- name: Auto-merge patch and minor updates
44+
if: |
45+
(steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
46+
steps.metadata.outputs.update-type == 'version-update:semver-minor') &&
47+
steps.wait-for-ci.outputs.conclusion == 'success'
48+
run: gh pr merge --auto --squash "$PR_URL"
49+
env:
50+
PR_URL: ${{ github.event.pull_request.html_url }}
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52+
53+
- name: Auto-merge GitHub Actions updates
54+
if: |
55+
steps.metadata.outputs.package-ecosystem == 'github_actions' &&
56+
steps.wait-for-ci.outputs.conclusion == 'success'
57+
run: gh pr merge --auto --squash "$PR_URL"
58+
env:
59+
PR_URL: ${{ github.event.pull_request.html_url }}
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Comment on major updates
63+
if: steps.metadata.outputs.update-type == 'version-update:semver-major'
64+
run: |
65+
gh pr comment "$PR_URL" --body "🔄 **Major version update detected!** This requires manual review before merging."
66+
env:
67+
PR_URL: ${{ github.event.pull_request.html_url }}
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/go-ci-full.yml

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Go CI/CD
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
go-version:
7+
description: 'Go version to use'
8+
required: false
9+
default: 'stable'
10+
type: string
11+
working-directory:
12+
description: 'Working directory for the project'
13+
required: false
14+
default: '.'
15+
type: string
16+
codecov-token:
17+
description: 'Codecov token for coverage upload'
18+
required: false
19+
default: ''
20+
type: string
21+
gosec-config:
22+
description: 'Path to gosec configuration file'
23+
required: false
24+
default: '.gosec.json'
25+
type: string
26+
27+
env:
28+
CGO_ENABLED: 1
29+
30+
jobs:
31+
test:
32+
name: Test Suite
33+
runs-on: ubuntu-latest
34+
defaults:
35+
run:
36+
working-directory: ${{ inputs.working-directory }}
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
41+
- name: Setup Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: ${{ inputs.go-version }}
45+
cache: true
46+
cache-dependency-path: ${{ inputs.working-directory }}/go.sum
47+
48+
- name: Install Dependencies
49+
run: |
50+
go install honnef.co/go/tools/cmd/staticcheck@latest
51+
go install github.com/securego/gosec/v2/cmd/gosec@latest
52+
go install golang.org/x/vuln/cmd/govulncheck@latest
53+
54+
- name: Go Format Check
55+
run: |
56+
if [ "$(gofmt -l . | wc -l)" -gt 0 ]; then
57+
echo "Code not formatted:"
58+
gofmt -l .
59+
exit 1
60+
fi
61+
62+
- name: Go Vet
63+
run: go vet ./...
64+
65+
- name: Verify Dependencies
66+
run: go mod verify
67+
68+
- name: Staticcheck
69+
run: staticcheck ./...
70+
71+
- name: Vulnerability Check
72+
run: govulncheck ./...
73+
74+
- name: Security Scan (gosec)
75+
continue-on-error: true
76+
run: |
77+
echo "Running security scan..."
78+
if [ -f "${{ inputs.gosec-config }}" ]; then
79+
gosec -conf ${{ inputs.gosec-config }} ./... || true
80+
else
81+
gosec ./... || true
82+
fi
83+
echo "Security scan completed"
84+
85+
- name: Test with Race Detection
86+
run: go test -race -timeout 5m -v ./...
87+
88+
- name: Test Coverage
89+
run: |
90+
go test -coverprofile=coverage.out ./...
91+
go tool cover -func=coverage.out
92+
93+
- name: Upload coverage to Codecov
94+
if: ${{ inputs.codecov-token != '' }}
95+
uses: codecov/codecov-action@v4
96+
with:
97+
file: ${{ inputs.working-directory }}/coverage.out
98+
flags: unittests
99+
name: codecov-umbrella
100+
fail_ci_if_error: false
101+
token: ${{ inputs.codecov-token }}
102+
103+
build:
104+
name: Build Matrix
105+
runs-on: ${{ matrix.os }}
106+
defaults:
107+
run:
108+
working-directory: ${{ inputs.working-directory }}
109+
strategy:
110+
fail-fast: false
111+
matrix:
112+
os: [ubuntu-latest, windows-latest, macos-latest]
113+
steps:
114+
- name: Checkout
115+
uses: actions/checkout@v4
116+
117+
- name: Setup Go
118+
uses: actions/setup-go@v5
119+
with:
120+
go-version: ${{ inputs.go-version }}
121+
cache: true
122+
cache-dependency-path: ${{ inputs.working-directory }}/go.sum
123+
124+
- name: Build
125+
run: go build -v ./...
126+
127+
- name: Short Test (no race, faster)
128+
run: go test -short -timeout 30s ./...

.github/workflows/go-pr-quick.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Go PR Quick Check
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
go-version:
7+
description: 'Go version to use'
8+
required: false
9+
default: 'stable'
10+
type: string
11+
gosec-excludes:
12+
description: 'Gosec rules to exclude (comma-separated)'
13+
required: false
14+
default: 'G104,G306,G301'
15+
type: string
16+
working-directory:
17+
description: 'Working directory for the project'
18+
required: false
19+
default: '.'
20+
type: string
21+
22+
env:
23+
CGO_ENABLED: 1
24+
25+
jobs:
26+
quick-test:
27+
name: Quick Validation
28+
runs-on: ubuntu-latest
29+
defaults:
30+
run:
31+
working-directory: ${{ inputs.working-directory }}
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Go
37+
uses: actions/setup-go@v5
38+
with:
39+
go-version: ${{ inputs.go-version }}
40+
cache: true
41+
cache-dependency-path: ${{ inputs.working-directory }}/go.sum
42+
43+
- name: Quick Quality Check
44+
run: |
45+
# Format check
46+
test -z "$(gofmt -l .)"
47+
48+
# Vet
49+
go vet ./...
50+
51+
# Basic test
52+
go test -short ./...
53+
54+
- name: Install Security Tools
55+
run: go install github.com/securego/gosec/v2/cmd/gosec@latest
56+
57+
- name: Security Scan
58+
run: gosec --exclude=${{ inputs.gosec-excludes }} ./...

CHANGELOG.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Changelog
2+
3+
All notable changes to AGILira Workflow Templates will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
## [1.0.0] - 2025-09-29
11+
12+
### Added
13+
- **Reusable Workflows:**
14+
- `go-ci-full.yml` - Comprehensive CI/CD pipeline for Go projects
15+
- `go-pr-quick.yml` - Fast PR validation workflow
16+
- `dependabot-auto-merge.yml` - Intelligent dependency auto-merging
17+
18+
- **Configuration Templates:**
19+
- `dependabot.yml` - Standard dependabot configuration for Go projects
20+
- `.gosec.json` - Security scanner configuration with AGILira standards
21+
- `.gitignore` - Comprehensive Go project gitignore template
22+
23+
- **Documentation:**
24+
- Complete README with usage examples
25+
- Quick start guide for immediate adoption
26+
- Template and workflow documentation
27+
28+
### Features
29+
- **Go Version Management:** Always use latest stable Go version
30+
- **Security Integration:** Vulnerability scanning, gosec analysis, dependency verification
31+
- **Quality Gates:** Format checking, static analysis, race detection
32+
- **Cross-platform Testing:** Linux, Windows, macOS build matrix
33+
- **Intelligent Auto-merge:** Safe dependency updates with CI validation
34+
- **AGILira Standards:** Consistent configuration across all projects
35+
- **European Timezone:** Dependabot scheduling optimized for Italian development
36+
37+
### Technical Details
38+
- Enterprise-grade workflow design
39+
- Configurable inputs for customization
40+
- Optimized for AGILira project structure
41+
- MIT licensed for maximum compatibility
42+
- Semantic versioning for stable API
43+
44+
[Unreleased]: https://github.com/agilira/workflow/compare/v1.0.0...HEAD
45+
[1.0.0]: https://github.com/agilira/workflow/releases/tag/v1.0.0

0 commit comments

Comments
 (0)