-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
137 changed files
with
19,378 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/app" | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "docker" | ||
directory: "/app" | ||
schedule: | ||
interval: "weekly" | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
--- | ||
name: app | ||
|
||
on: [push, pull_request] | ||
|
||
defaults: | ||
run: | ||
working-directory: ./app | ||
|
||
jobs: | ||
prepare: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: jdx/mise-action@v2 | ||
with: | ||
version: 2024.10.7 | ||
install: true | ||
experimental: true | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23.2' | ||
cache-dependency-path: 'app/go.sum' | ||
- run: go mod tidy | ||
- run: task gen | ||
- name: Save task cache | ||
uses: actions/cache/save@v4 | ||
with: | ||
path: ./.task | ||
key: task-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.task/checksum/*') }} | ||
- name: Check git status | ||
run: if [[ -n $(git status --porcelain) ]]; then git status --porcelain && exit 1; fi | ||
|
||
lint: | ||
needs: [prepare] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore task cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ./.task | ||
key: task-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.task/checksum/*') }} | ||
- uses: jdx/mise-action@v2 | ||
with: | ||
version: 2024.10.7 | ||
install: false | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23.2' | ||
cache-dependency-path: 'app/go.sum' | ||
- uses: golangci/golangci-lint-action@v6 | ||
with: | ||
version: v1.61.0 | ||
working-directory: ./app | ||
args: --path-prefix=./ | ||
|
||
test: | ||
needs: [prepare] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore task cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ./.task | ||
key: task-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.task/checksum/*') }} | ||
- uses: jdx/mise-action@v2 | ||
with: | ||
version: 2024.10.7 | ||
install: false | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23.2' | ||
cache-dependency-path: 'app/go.sum' | ||
- run: task test | ||
|
||
build: | ||
needs: [prepare] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Restore task cache | ||
uses: actions/cache/restore@v4 | ||
with: | ||
path: ./.task | ||
key: task-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('.task/checksum/*') }} | ||
- uses: jdx/mise-action@v2 | ||
with: | ||
version: 2024.10.7 | ||
install: false | ||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.23.2' | ||
cache-dependency-path: 'app/go.sum' | ||
- run: task build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Misc | ||
.DS_Store | ||
|
||
# Environment | ||
.env | ||
.env.local | ||
.env.*.local | ||
|
||
# Editor | ||
.idea | ||
.vscode | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
|
||
# Go | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
*.test | ||
*.out | ||
go.work | ||
|
||
# Dist | ||
dist/ | ||
|
||
# Task | ||
.task/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[tools] | ||
atlas = "0.28.0" | ||
golang = "1.23.2" | ||
golangci-lint = "1.61.0" | ||
protoc = "28.2" | ||
protoc-gen-go = "1.35.1" | ||
protoc-gen-go-grpc = "1.5.1" | ||
task = "3.39.2" | ||
|
||
"go:github.com/sqlc-dev/sqlc/cmd/sqlc" = "1.27.0" | ||
"go:goa.design/goa/v3/cmd/goa" = "3.19.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
# Count Up | ||
|
||
A little web app game, consolidating the best practices from my years of experience building production-ready software and infrastructure. | ||
A little web app game, consolidating the best practices from my years of experience building production-ready software and infrastructure. | ||
|
||
Probably way overengineered for incrementing a counter, but thought this will be a good exercise to codify my learnings! | ||
|
||
## Features | ||
|
||
- Async, transactional worker system for processing background jobs using [River](https://riverqueue.com/). | ||
- Compiled SQL queries into type-safe application code using [sqlc](https://sqlc.dev/). | ||
- Declarative database schema and migrations using a combination of [Atlas](https://atlasgo.io/) + [Goose](https://pressly.github.io/goose/). | ||
- DDD-lite, interface-driven approach to writing decoupled and testable business logic. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
version: '3' | ||
|
||
vars: | ||
VERSION: | ||
sh: git describe --tags --exact-match HEAD 2>/dev/null || echo "0.0.0" | ||
GIT_COMMIT: | ||
sh: git rev-parse --short HEAD | ||
LDFLAGS: | ||
- '-X github.com/jace-ys/countup/internal/versioninfo.Version={{ .VERSION }}' | ||
- '-X github.com/jace-ys/countup/internal/versioninfo.CommitSHA={{ .GIT_COMMIT }}' | ||
|
||
tasks: | ||
run:server: | ||
deps: ['gen'] | ||
dir: app | ||
cmds: | ||
- go run ./cmd/countup/... server {{ .CLI_ARGS }} | ||
env: | ||
DEBUG: true | ||
OTEL_GO_X_EXEMPLAR: true | ||
OTEL_RESOURCE_ATTRIBUTES: tier=app,environment=dev | ||
DATABASE_CONNECTION_URI: postgresql://countup:countup@localhost:5432/countup | ||
|
||
run:client: | ||
deps: ['gen'] | ||
dir: app | ||
cmds: | ||
- go run ./cmd/countup-cli/... {{ .CLI_ARGS }} | ||
|
||
test: | ||
deps: ['gen'] | ||
dir: app | ||
cmds: | ||
- go test -race ./... | ||
|
||
lint: | ||
deps: ['gen'] | ||
dir: app | ||
cmds: | ||
- golangci-lint run ./... | ||
|
||
gen: | ||
dir: app | ||
cmds: | ||
- task: gen:api:v1 | ||
- task: gen:sqlc | ||
|
||
gen:api:*: | ||
internal: true | ||
dir: app | ||
vars: | ||
API_VERSION: '{{ index .MATCH 0 }}' | ||
cmds: | ||
- goa gen github.com/jace-ys/countup/api/{{ .API_VERSION }} -o api/{{ .API_VERSION }} | ||
sources: | ||
- api/{{ .API_VERSION }}/*.go | ||
generates: | ||
- api/{{ .API_VERSION }}/gen/**/*.go | ||
|
||
gen:sqlc: | ||
internal: true | ||
deps: ['migration:plan'] | ||
dir: app | ||
cmds: | ||
- sqlc generate | ||
sources: | ||
- schema/*.sql | ||
|
||
migration:new: | ||
dir: app | ||
cmds: | ||
- atlas migrate new --env dev {{ .NAME }} | ||
requires: | ||
vars: [NAME] | ||
|
||
migration:plan: | ||
dir: app | ||
cmds: | ||
- atlas migrate diff --env dev {{ .NAME }} | ||
sources: | ||
- schema/schema.sql | ||
- schema/migrations/*.sql | ||
generates: | ||
- schema/migrations/*.sql | ||
|
||
migration:hash: | ||
dir: app | ||
cmds: | ||
- atlas migrate hash --env dev | ||
|
||
build: | ||
deps: ['gen'] | ||
dir: app | ||
cmds: | ||
- task: build:server | ||
- task: build:client | ||
- task: build:image | ||
|
||
build:server: | ||
internal: true | ||
dir: app | ||
cmds: | ||
- go build -ldflags='{{ .LDFLAGS | join " " }}' -o ./dist/ ./cmd/countup/... | ||
|
||
build:client: | ||
internal: true | ||
dir: app | ||
cmds: | ||
- go build -ldflags='{{ .LDFLAGS | join " " }}' -o ./dist/ ./cmd/countup-cli/... | ||
|
||
build:image: | ||
internal: true | ||
dir: app | ||
cmds: | ||
- docker build --build-arg LDFLAGS='{{ .LDFLAGS | join " " }}' -t jace-ys/countup:{{ .VERSION }} . | ||
|
||
compose: | ||
ignore_error: true | ||
deps: ['gen'] | ||
cmds: | ||
- docker compose --profile apps up --build {{ .CLI_ARGS }} | ||
- defer: {task: 'compose:down'} | ||
|
||
compose:infra: | ||
ignore_error: true | ||
deps: ['gen'] | ||
cmds: | ||
- docker compose up {{ .CLI_ARGS }} | ||
- defer: {task: 'compose:down'} | ||
|
||
compose:down: | ||
ignore_error: true | ||
cmds: | ||
- docker compose down -v --remove-orphans |
Oops, something went wrong.