Skip to content

Commit 8f7b3a0

Browse files
committed
chore: add repo templates and codeql
1 parent 7542209 commit 8f7b3a0

8 files changed

Lines changed: 136 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug report
3+
about: Report a reproducible problem
4+
labels: bug
5+
---
6+
7+
## Summary
8+
9+
## Steps to Reproduce
10+
1.
11+
2.
12+
3.
13+
14+
## Expected
15+
16+
## Actual
17+
18+
## Environment
19+
- Go version:
20+
- OS:
21+
- Commit/Tag:
22+
23+
## Additional Context
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Documentation
3+
about: Request documentation changes or additions
4+
labels: documentation
5+
---
6+
7+
## Summary
8+
9+
## Proposed Change
10+
11+
## References
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
name: Feature request
3+
about: Propose an enhancement
4+
labels: enhancement
5+
---
6+
7+
## Problem
8+
9+
## Proposal
10+
11+
## Alternatives Considered
12+
13+
## Additional Context

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
- package-ecosystem: "gomod"
8+
directory: "/examples/hello-mysql"
9+
schedule:
10+
interval: "weekly"

.github/pull_request_template.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Summary
2+
-
3+
4+
## Changes
5+
-
6+
7+
## Testing
8+
-
9+
10+
## Notes
11+
-

.github/workflows/codeql.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: codeql
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
analyze:
11+
name: Analyze
12+
runs-on: ubuntu-latest
13+
permissions:
14+
actions: read
15+
contents: read
16+
security-events: write
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
language: ["go"]
21+
steps:
22+
- uses: actions/checkout@v4
23+
- uses: github/codeql-action/init@v3
24+
with:
25+
languages: ${{ matrix.language }}
26+
- uses: github/codeql-action/autobuild@v3
27+
- uses: github/codeql-action/analyze@v3

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ modkit is a Go-idiomatic backend service framework built around an explicit modu
66

77
This repository is in early MVP implementation. APIs and structure may change before v0.1.0.
88

9+
## API Stability
10+
11+
Until `v0.1.0`, public APIs may change without notice. After `v0.1.0`, changes will follow semantic versioning.
12+
913
## What Is modkit?
1014

1115
modkit provides:

examples/hello-mysql/internal/seed/seed_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func TestSeed_InsertsDefaultUsersIfEmpty(t *testing.T) {
1818
_ = container.Terminate(ctx)
1919
}()
2020

21+
if err := waitForMySQL(ctx, dsn); err != nil {
22+
t.Fatalf("mysql not ready: %v", err)
23+
}
24+
2125
db, err := mysql.Open(dsn)
2226
if err != nil {
2327
t.Fatalf("open db: %v", err)
@@ -88,3 +92,36 @@ func startMySQL(t *testing.T, ctx context.Context) (testcontainers.Container, st
8892
dsn := "root:password@tcp(" + host + ":" + port.Port() + ")/app?parseTime=true&multiStatements=true"
8993
return container, dsn
9094
}
95+
96+
func waitForMySQL(ctx context.Context, dsn string) error {
97+
deadline, ok := ctx.Deadline()
98+
if !ok {
99+
deadline = time.Now().Add(30 * time.Second)
100+
}
101+
102+
for {
103+
db, err := mysql.Open(dsn)
104+
if err == nil {
105+
pingCtx, cancel := context.WithTimeout(ctx, 2*time.Second)
106+
pingErr := db.PingContext(pingCtx)
107+
cancel()
108+
_ = db.Close()
109+
if pingErr == nil {
110+
return nil
111+
}
112+
}
113+
114+
if time.Now().After(deadline) {
115+
if err != nil {
116+
return err
117+
}
118+
return context.DeadlineExceeded
119+
}
120+
121+
select {
122+
case <-ctx.Done():
123+
return ctx.Err()
124+
case <-time.After(500 * time.Millisecond):
125+
}
126+
}
127+
}

0 commit comments

Comments
 (0)