Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/rewrite #32

Merged
merged 46 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
18f5a9e
chore: template
Topvennie Nov 13, 2024
f7a89a1
chore: template
Topvennie Nov 14, 2024
91cbc61
feat: buzzer
Topvennie Nov 14, 2024
e416983
feat: add bash run scripts
Topvennie Nov 14, 2024
1111346
chore: add db template
Topvennie Nov 14, 2024
910a880
feat: add messages api
Topvennie Nov 14, 2024
715ae2a
chore: add & remove config options
Topvennie Nov 14, 2024
cc1cbe1
feat: add spotify integration
Topvennie Nov 14, 2024
893f617
feat: tap integration
Topvennie Nov 14, 2024
e7ed1f0
chore: replace air with bash script
Topvennie Nov 15, 2024
25031a6
feat: add tui template
Topvennie Nov 18, 2024
086b13b
feat: tap view
Topvennie Nov 18, 2024
e649034
chore: finalisation of tap
Topvennie Nov 20, 2024
9aad0cf
feat: add cammie chat
Topvennie Nov 21, 2024
9f81f65
feat: add zess package
Topvennie Nov 21, 2024
d92422a
chore: update readme
Topvennie Nov 21, 2024
ca5015a
feat: add zess stats
Topvennie Nov 24, 2024
469a801
chore: move data update out of tui loop
Topvennie Nov 24, 2024
73258bf
chore: finish zess view
Topvennie Nov 24, 2024
d707b6e
feat: add gamification integration
Topvennie Nov 25, 2024
6561e34
feat: added gamication view
Topvennie Nov 25, 2024
5bd1a1a
chore: small view refactor
Topvennie Nov 25, 2024
119420f
feat: add website events integration
Topvennie Nov 27, 2024
f54fa51
feat(song): history
Topvennie Nov 27, 2024
6415eba
feat(song): genre
Topvennie Nov 27, 2024
25e8579
feat(song): lyrics
Topvennie Nov 28, 2024
0a6eb38
chore(workflow): update sqlc diff
Topvennie Nov 28, 2024
56de0fd
feat(lyric): add package
Topvennie Nov 30, 2024
31ec12a
feat(lyric): add view
Topvennie Dec 1, 2024
e176f04
feat(event): fetch poster
Topvennie Dec 3, 2024
de3e0a9
chore(gammification): store avatar in db
Topvennie Dec 3, 2024
99befcb
feat(event): add view
Topvennie Dec 4, 2024
5f443fb
chore(tap): enhance view
Topvennie Dec 4, 2024
db49b3b
chore(zess): enhance view
Topvennie Dec 4, 2024
7245f2e
feat(view): enhance cammie view
Topvennie Dec 7, 2024
fd6715a
chore(song): enhance view
Topvennie Dec 7, 2024
acdd8f6
feat(db): switch to postgres
Topvennie Dec 8, 2024
c8aca69
deps: cleanup
Topvennie Dec 8, 2024
649371d
chore(config): make multi threaded safe
Topvennie Dec 8, 2024
02c156c
chore(config): switch to yaml
Topvennie Dec 8, 2024
97ef20c
feat(config): yeet thread safety, just hope for the best
Topvennie Dec 8, 2024
290cf7d
fix(zess): season validation
Topvennie Dec 8, 2024
1346c52
chore(event): adjust default config value
Topvennie Dec 8, 2024
40b80cb
feat(progress): add a progression bar
Topvennie Dec 10, 2024
97fcd10
feat(song): finish view
Topvennie Dec 10, 2024
dbefc43
feat(zess): bar colors
Topvennie Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
APP_ENV = development
SONG_SPOTIFY_CLIENT_ID = your_client_id
SONG_SPOTIFY_CLIENT_SECRET = your_client_secret
8 changes: 8 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

echo "Linting"
golangci-lint run
if [ $? -ne 0 ]; then
echo "golangci-lint failed. Please fix the errors before committing."
exit 1
fi
28 changes: 0 additions & 28 deletions .github/workflows/go.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: golangci-lint

on:
push:
branches:
- main
pull_request:

permissions:
contents: read
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23.1

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.60
12 changes: 12 additions & 0 deletions .github/workflows/sqlc-diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: sqlc
on: [push]

jobs:
diff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: '1.27.0'
- run: sqlc diff
27 changes: 17 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
# Test binary, built with "go test -c"
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
Expand All @@ -19,12 +16,22 @@

# Go workspace file
go.work
tmp/

tmp.go
# IDE specific files
.vscode
.idea

config.yaml
# .env file
.env
.env.*
!.env.example

# Binary
scc
# Log file
scc.log
# Project build
backend_bin
tui_bin

.data/

# Log files
logs/
35 changes: 35 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
run:
timeout: 5m
modules-download-mode: readonly

linters:
enable:
- bodyclose # checks whether HTTP response body is closed successfully
- copyloopvar # detects copy loop variable
- errcheck # checks for unchecked errors in go programs
- errname # checks that sentinel errors are prefixed with the `Err` and error types are suffixed with the `Error`
- gochecknoinits # checks that no init functions are present in Go code
- goimports # check import statements are formatted correctly
- gosimple # checks for code simplifications in Go code
- govet # runs the go vet tool
- importas # enforces consistent import aliases
- ineffassign # detects when assignments to existing variables are not used
- noctx # finds sending http request without context.Context
- paralleltest # detects missing usage of t.Parallel() method in go tests
- prealloc # finds slice declarations that could potentially be preallocated
- revive # checks for golang coding style
- rowserrcheck # checks whether Err of rows is checked successfully
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
- staticcheck # Applies static code analysis
- tenv # detects using os.Setenv instead of t.Setenv
- testpackage # makes you use a separate _test package
- thelper # detects golang test helpers without t.Helper() call and checks consistency of test helpers
- unconvert # removes unnecessary type conversions
- unparam # removes unused function parameters
- unused # finds unused variables
fast: true

issues:
exclude-use-default: false
max-issues-per-linter: 0
max-same-issues: 0
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
golang 1.22.0
golang 1.23.1
69 changes: 66 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,70 @@
# Screen Cammie Chat

Go 1.22.0
Displays the cammie chat along with some other statistics.

- `go mod tidy`
## Development Setup

- `go run .` of `go build .`
### Prerequisites

1. Go: Check the [.tool-versions](.tool-versions) file for the required Go version.
2. Pre-commit hooks: `git config --local core.hooksPath .githooks/`.
3. Goose (DB migrations): `go install github.com/pressly/goose/v3/cmd/goose@latest`.
4. SQLC (Statically typed queries): `go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest`
5. Make (Optional)

### Configuration

1. Create a `.env` file specifying
- `APP_ENV`. Available options are:
- `development`
- `production`
- `BACKEND_SONG_SPOTIFY_CLIENT_ID`
- `BACKEND_SONG_SPOTIFY_CLIENT_SECRET`
2. Configure the appropriate settings in the corresponding configuration file located in the [config directory](./config). you can either set them as environment variables or inside the configuration file.

## DB

This project uses a postgres database.
SQLC is used to generate statically typed queries and goose is responsible for the database migrations.

### Usefull commands

- `make db`: Start the database
- `make migrate`: Run database migrations to update your database schema (watch out, migrations might result in minor data loss).
- `make create-migration`: Create a new migration in the [db/migrations](./db/migrations/) directory.
- `make sqlc`: Generate statically typed queries based on the .sql files in the [db/queries](./db/queries/) directory. Add new queries to this directory as needed.

## Backend

The backend is responsible for fetching and processing external data, which is then stored in the database.
Data can either received by exposing an API or by actively fetching them.

### Running the backend

To build and run the backend, use the following commands:

- `make build-backend`: Build the backend binary.
- `make run-backend`: Run the backend.

### Logs

Backend logs are saved to `./logs/backend.log` (created on first start) and written to `stdout`.

## TUI

The TUI (Text User Interface) displays data retrieved from the database. This flexibility allows for running multiple instances of the TUI, each displaying different data.

### Running the TUI

To build and run the TUI, use the following commands:

- `make build-tui`: Build the TUI binary.
- `make run-tui`: Run the TUI.
-
The TUI requires one argument: the screen name to display. You can create new screens in the [screens directory](./tui/screen/), and you must add them to the startup command list in [tui.go](./internal/cmd/tui.go).

A screen is responsible for creating and managing the layout, consisting of various [views](./tui/view/).

### Logs

TUI logs are written to `./logs/tui.log` and _not_ to `stdout`.
41 changes: 0 additions & 41 deletions api/api.go

This file was deleted.

84 changes: 0 additions & 84 deletions api/cammie.go

This file was deleted.

Loading
Loading