Skip to content

Commit e909c44

Browse files
committed
ci(github): enhance workflows and repository configuration
1 parent bc05f0d commit e909c44

25 files changed

+584
-169
lines changed

.github/.env.shared

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,25 @@ SECONDARY_RUNNER=ubuntu-24.04 # Set identical to PRIMARY_RUNNER if you
4040
# ───────────────────────────────────────────────────────────────────────────────
4141
ENABLE_CODE_COVERAGE=true # Enable code coverage reporting (upload to Codecov)
4242
ENABLE_FUZZ_TESTING=true # Enable fuzz running tests (requires Go 1.18+)
43-
ENABLE_LINT=true # Enable linting steps (golangci-lint)
43+
ENABLE_GO_LINT=true # Enable Go code linting steps (golangci-lint)
4444
ENABLE_RACE_DETECTION=true # Enable Go's race detector in tests (-race flag)
4545
ENABLE_SECURITY_SCANS=true # Enable tools like gitleaks, govulncheck, nancy
4646
ENABLE_STATIC_ANALYSIS=true # Enable static analysis jobs (go vet)
47-
ENABLE_VERBOSE_TEST_OUTPUT=true # Enable verbose output for test runs (can slow down CI)
47+
ENABLE_VERBOSE_TEST_OUTPUT=false # Enable verbose output for test runs (can slow down CI)
48+
ENABLE_YAML_LINT=true # Enable YAML format validation (prettier with editorconfig)
4849
MAKEFILE_REQUIRED=true # Enforce the presence of Makefile for builds (future feature)
4950

5051
# ───────────────────────────────────────────────────────────────────────────────
5152
# ENV: Tool Versions & Config
5253
# ───────────────────────────────────────────────────────────────────────────────
5354
GITLEAKS_NOTIFY_USER_LIST=@mrz1836 # User(s) to notify when gitleaks secrets are found (user,user2)
54-
GITLEAKS_VERSION=8.27.2 # Version of gitleaks to install and use (X.Y.Z)
55-
GORELEASER_VERSION=v2.10.2 # Version of goreleaser to install and use (vX.Y.Z)
56-
GOVULNCHECK_VERSION=v1.1.4 # Version of govulncheck to use for Go vuln scanning (vX.Y.Z)
55+
GITLEAKS_VERSION=8.27.2 # Version of gitleaks to install and use (X.Y.Z) (https://github.com/gitleaks/gitleaks)
56+
GORELEASER_VERSION=v2.11.0 # Version of goreleaser to install and use (vX.Y.Z) (https://github.com/goreleaser/goreleaser)
57+
GOVULNCHECK_VERSION=v1.1.4 # Version of govulncheck to use for Go vuln scanning (vX.Y.Z) (https://pkg.go.dev/golang.org/x/vuln)
5758
NANCY_EXCLUDES=CVE-2024-38513,CVE-2022-21698,CVE-2023-45142 # Known acceptable CVEs (cve,cve2,...)
58-
NANCY_VERSION=v1.0.51 # Version of nancy to install and use (vX.Y.Z)
59+
NANCY_VERSION=v1.0.51 # Version of nancy to install and use (vX.Y.Z) (https://github.com/sonatype-nexus-community/nancy)
60+
NODE_VERSION=20 # Node.js version for prettier and other tools (major version)
61+
PRETTIER_VERSION=3.6.2 # Version of prettier to use for YAML validation (X.Y.Z) (https://www.npmjs.com/package/prettier)
5962

6063
# ───────────────────────────────────────────────────────────────────────────────
6164
# ENV: Stale Workflow Configuration

.github/.prettierignore

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Directories managed by package managers or VCS
2+
node_modules/
3+
vendor/
4+
.git/
5+
6+
# Build outputs
7+
dist/
8+
build/
9+
10+
# Coverage artifacts
11+
coverage/
12+
*.cover
13+
*.cov
14+
coverage.txt
15+
coverage.html
16+
17+
# Minified assets
18+
*.min.js
19+
*.min.css
20+
21+
# Generated source code
22+
*.generated.*
23+
**gen.go
24+
mock**.go
25+
*.pb.go
26+
*.pb.gw.go
27+
**/packaged.yaml
28+
29+
# Compiled binaries
30+
*.exe
31+
*.dll
32+
*.so
33+
*.dylib
34+
*.test
35+
*.out
36+
37+
# Temporary / swap files
38+
*.tmp
39+
*.temp
40+
*.swp
41+
*.swo
42+
*~
43+
44+
# IDE metadata
45+
.idea/
46+
.vscode/
47+
*.iml
48+
49+
# Dependency locks
50+
go.sum
51+
package-lock.json
52+
yarn.lock
53+
54+
# Data exports
55+
*.json
56+
*.csv
57+
*.tsv
58+
*.sql
59+
60+
# Documentation & licenses
61+
*.md
62+
LICENSE
63+
CHANGELOG
64+
CITATION.cff
65+
66+
# Build & lint configs
67+
**/.golangci.json
68+
**/.golangci.yml
69+
**/.golangci.yaml
70+
**/.env.shared
71+
**/Makefile
72+
**/makefile
73+
**/*.mk

.github/.prettierrc.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ------------------------------------------------------------------------------------
2+
# Prettier Configuration
3+
#
4+
# Purpose: Ensures consistent YAML formatting across all tools (Prettier, IDEs)
5+
# Location: .github directory (preferred for project-specific configs)
6+
#
7+
# Maintainer: @mrz1836
8+
#
9+
# ------------------------------------------------------------------------------------
10+
11+
# Print width (line length limit)
12+
printWidth: 80
13+
14+
# Indentation
15+
tabWidth: 2
16+
useTabs: false
17+
18+
# Quotes
19+
singleQuote: false # Use double quotes for consistency
20+
21+
# Brackets and spacing (applies to JS/JSON objects, not YAML arrays)
22+
bracketSpacing: false # Keep consistent with YAML array formatting
23+
bracketSameLine: false
24+
25+
# Array and object formatting
26+
trailingComma: "none" # No trailing commas in YAML
27+
28+
# Line endings (should match .editorconfig)
29+
endOfLine: "lf"
30+
31+
# Prose formatting (for Markdown in YAML)
32+
proseWrap: "preserve"
33+
34+
# YAML-specific settings
35+
overrides:
36+
- files: "*.{yml,yaml}"
37+
options:
38+
printWidth: 120 # Allow longer lines for YAML workflow files
39+
bracketSpacing: false
40+
singleQuote: false

.github/AGENTS.md

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Code must be cleanly formatted and pass all linters before being committed.
469469
go fmt ./...
470470
goimports -w .
471471
gofumpt -w .
472-
golangci-lint run
472+
make lint
473473
go vet ./...
474474
```
475475

@@ -481,6 +481,33 @@ platforms.
481481

482482
<br/>
483483

484+
### 💄 Prettier (YAML Formatting)
485+
486+
YAML files must be formatted consistently using Prettier to ensure clean diffs and readable configuration files.
487+
488+
**Local Setup:**
489+
```bash
490+
# Install prettier locally
491+
npm init -y && npm install --save-dev prettier
492+
```
493+
494+
**Format YAML files:**
495+
```bash
496+
# Check formatting
497+
npx prettier "**/*.{yml,yaml}" --check --config .github/.prettierrc.yml --ignore-path .github/.prettierignore
498+
499+
# Fix formatting issues
500+
npx prettier "**/*.{yml,yaml}" --write --config .github/.prettierrc.yml --ignore-path .github/.prettierignore
501+
```
502+
503+
**Configuration Files:**
504+
* [`.github/.prettierrc.yml`](.prettierrc.yml) - Prettier configuration settings
505+
* [`.github/.prettierignore`](.prettierignore) - Files and patterns to ignore during formatting
506+
507+
> CI automatically validates YAML formatting using the same prettier configuration. All YAML files must pass formatting checks before merge.
508+
509+
<br/>
510+
484511
---
485512

486513
<br/>
@@ -505,13 +532,22 @@ We use the `testify` suite for unit tests. All tests must follow these conventio
505532
* Mock external dependencies — tests should be fast and deterministic
506533
* Use descriptive test names that explain the scenario being tested
507534
* Test error cases — ensure your error handling actually works
535+
* Handle all errors in tests properly:
536+
* `os.Setenv()` returns an error - use `require.NoError(t, err)`
537+
* `os.Unsetenv()` returns an error - use `require.NoError(t, err)`
538+
* `db.Close()` in defer statements - wrap in anonymous function: `defer func() { _ = db.Close() }()`
539+
* Deferred `os.Setenv()` for cleanup - wrap in anonymous function to ignore error
508540

509541
Run tests locally with:
510-
511542
```bash
512543
go test ./...
513544
```
514545

546+
Or use our makefile:
547+
```bash
548+
make test
549+
```
550+
515551
> All tests must pass in CI prior to merge.
516552
517553
<br/>
@@ -1049,7 +1085,7 @@ CI automatically runs on every PR to verify:
10491085
* Linting (`make lint`)
10501086
* Tests (`make test`)
10511087
* Fuzz tests (if applicable) (`make run-fuzz-tests`)
1052-
* This codebase uses GitHub Actions; test workflows reside in `.github/workflows/fortress.yml`
1088+
* This codebase uses GitHub Actions; test workflows reside in `.github/workflows/fortress.yml` and `.github/workflows/fortress-test-suite.yml`.
10531089
* Pin each external GitHub Action to a **full commit SHA** (e.g., `actions/checkout@2f3b4a2e0e471e13e2ea2bc2a350e888c9cf9b75`) as recommended by GitHub's [security hardening guidance](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-pinned-actions). Dependabot will track and update these pinned versions automatically.
10541090

10551091
Failing PRs will be blocked. AI agents should iterate until CI passes.

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Bug report
22
description: Report incorrect behavior, test failure, or unexpected output in this Go library
33
title: "[Bug] <brief description of the issue>"
4-
labels: [ "bug-p3" ]
4+
labels: ["bug-p3"]
55
assignees:
66
- icellan
77
body:

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Feature request
22
description: Suggest an idea or improvement for this project
33
title: "[Feature] <brief description of feature>"
4-
labels: [ "idea" ]
4+
labels: ["idea"]
55
assignees:
66
- icellan
77
body:

.github/ISSUE_TEMPLATE/question.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Question
22
description: General template for asking a question related to this project
33
title: "[Question] <your topic here>"
4-
labels: [ "question" ]
4+
labels: ["question"]
55
assignees:
66
- icellan
77
body:

.github/actions/load-env/action.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
#
1616
# ------------------------------------------------------------------------------------
1717

18-
name: 'Load Environment Variables'
19-
description: 'Loads environment variables from .github/.env.shared and outputs as JSON'
18+
name: "Load Environment Variables"
19+
description: "Loads environment variables from .github/.env.shared and outputs as JSON"
2020

2121
outputs:
2222
env-json:
23-
description: 'JSON object containing all environment variables'
23+
description: "JSON object containing all environment variables"
2424
value: ${{ steps.load-env.outputs.env-json }}
2525
primary-runner:
26-
description: 'Primary runner OS extracted from environment variables'
26+
description: "Primary runner OS extracted from environment variables"
2727
value: ${{ steps.load-env.outputs.primary-runner }}
2828

2929
runs:

.github/actions/warm-cache/action.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88
#
99
# ------------------------------------------------------------------------------------
1010

11-
name: 'Warm Go Caches'
12-
description: 'Warm Go module and build caches for the specified Go version and OS'
11+
name: "Warm Go Caches"
12+
description: "Warm Go module and build caches for the specified Go version and OS"
1313

1414
inputs:
1515
go-version:
16-
description: 'Go version to use'
16+
description: "Go version to use"
1717
required: true
1818
matrix-os:
19-
description: 'Operating system for the runner'
19+
description: "Operating system for the runner"
2020
required: true
2121
matrix-name:
22-
description: 'Display name for the matrix configuration'
22+
description: "Display name for the matrix configuration"
2323
required: true
2424
enable-verbose:
25-
description: 'Enable verbose output'
25+
description: "Enable verbose output"
2626
required: false
27-
default: 'false'
27+
default: "false"
2828
go-primary-version:
29-
description: 'Primary Go version for comparison'
29+
description: "Primary Go version for comparison"
3030
required: true
3131
go-secondary-version:
32-
description: 'Secondary Go version for comparison'
32+
description: "Secondary Go version for comparison"
3333
required: true
3434

3535
runs:
36-
using: 'composite'
36+
using: "composite"
3737
steps:
3838
# ————————————————————————————————————————————————————————————————
3939
# Checkout code, set up Go, and cache dependencies
@@ -59,7 +59,7 @@ runs:
5959
# ────────────────────────────────────────────────────────────────────────────
6060
- name: 💾 Restore Go module cache (shared)
6161
id: gomod-cache
62-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
62+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
6363
with:
6464
path: |
6565
~/go/pkg/mod
@@ -133,7 +133,7 @@ runs:
133133
# ────────────────────────────────────────────────────────────────────────────
134134
- name: 💾 Restore Go build cache (per-version)
135135
id: gobuild-cache
136-
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
136+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
137137
with:
138138
path: |
139139
~/.cache/go-build

.github/dependabot.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ updates:
4747
- "*auth*"
4848
- "*jwt*"
4949
- "*oauth*"
50-
update-types: [ "minor", "patch" ]
50+
update-types: ["minor", "patch"]
5151
open-pull-requests-limit: 10
52-
assignees: [ "galt-tr","mrz1836" ]
53-
labels: [ "chore", "dependencies", "gomod" ]
52+
assignees: ["galt-tr", "mrz1836"]
53+
labels: ["chore", "dependencies", "gomod"]
5454
commit-message:
5555
prefix: "chore"
5656
include: "scope"
@@ -70,10 +70,10 @@ updates:
7070
- dependency-type: "direct"
7171
groups:
7272
ghactions-all:
73-
patterns: [ "*" ]
73+
patterns: ["*"]
7474
open-pull-requests-limit: 10
75-
assignees: [ "galt-tr","mrz1836" ]
76-
labels: [ "chore", "dependencies", "github-actions" ]
75+
assignees: ["galt-tr", "mrz1836"]
76+
labels: ["chore", "dependencies", "github-actions"]
7777
commit-message:
7878
prefix: "chore"
7979
include: "scope"
@@ -93,10 +93,10 @@ updates:
9393
- dependency-type: "direct"
9494
groups:
9595
devcontainer-all:
96-
patterns: [ "*" ]
96+
patterns: ["*"]
9797
open-pull-requests-limit: 5
98-
assignees: [ "galt-tr","mrz1836" ]
99-
labels: [ "chore", "dependencies", "devcontainer" ]
98+
assignees: ["galt-tr", "mrz1836"]
99+
labels: ["chore", "dependencies", "devcontainer"]
100100
commit-message:
101101
prefix: "chore"
102102
include: "scope"

0 commit comments

Comments
 (0)