Add workflows and fix linter errors
This commit is contained in:
parent
4f594f7412
commit
3edcb0ad1b
19
.direnv/bin/nix-direnv-reload
Executable file
19
.direnv/bin/nix-direnv-reload
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
if [[ ! -d "/home/torjus/git/ghettoptt" ]]; then
|
||||
echo "Cannot find source directory; Did you move it?"
|
||||
echo "(Looking for "/home/torjus/git/ghettoptt")"
|
||||
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# rebuild the cache forcefully
|
||||
_nix_direnv_force_reload=1 direnv exec "/home/torjus/git/ghettoptt" true
|
||||
|
||||
# Update the mtime for .envrc.
|
||||
# This will cause direnv to reload again - but without re-building.
|
||||
touch "/home/torjus/git/ghettoptt/.envrc"
|
||||
|
||||
# Also update the timestamp of whatever profile_rc we have.
|
||||
# This makes sure that we know we are up to date.
|
||||
touch -r "/home/torjus/git/ghettoptt/.envrc" "/home/torjus/git/ghettoptt/.direnv"/*.rc
|
1
.direnv/flake-inputs/p2hby44a0qzrnd1vxcpcgfav6160rmcv-source
Symbolic link
1
.direnv/flake-inputs/p2hby44a0qzrnd1vxcpcgfav6160rmcv-source
Symbolic link
@ -0,0 +1 @@
|
||||
/nix/store/p2hby44a0qzrnd1vxcpcgfav6160rmcv-source
|
1
.direnv/flake-inputs/ri5q1bld0gwahdsrfs8ydcini09mx85i-source
Symbolic link
1
.direnv/flake-inputs/ri5q1bld0gwahdsrfs8ydcini09mx85i-source
Symbolic link
@ -0,0 +1 @@
|
||||
/nix/store/ri5q1bld0gwahdsrfs8ydcini09mx85i-source
|
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
@ -0,0 +1 @@
|
||||
/nix/store/4n7mpj43zcs1y74q231w94i3a3w56si2-nix-shell-env
|
1997
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
1997
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
File diff suppressed because it is too large
Load Diff
20
.github/workflows/go-test-build.yaml
vendored
Normal file
20
.github/workflows/go-test-build.yaml
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
name: go-test-build
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
go-test-build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/catthehacker/ubuntu:runner-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ "1.22", "1.21" ]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
- run: go test -v ./...
|
||||
- run: go build -o main main.go
|
19
.github/workflows/golangci-lint.yaml
vendored
Normal file
19
.github/workflows/golangci-lint.yaml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
name: golangci-lint
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
goglangci-lint:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/catthehacker/ubuntu:runner-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.22"
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v6
|
||||
with:
|
||||
version: v1.61
|
15
.github/workflows/nix-check-build.yaml
vendored
Normal file
15
.github/workflows/nix-check-build.yaml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
name: nix-check-build
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
nix-check-build:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ghcr.io/catthehacker/ubuntu:runner-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- run: nix flake check
|
||||
- run: nix build
|
19
main.go
19
main.go
@ -40,7 +40,10 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
defer input.Close()
|
||||
input.NonBlock()
|
||||
if err := input.NonBlock(); err != nil {
|
||||
slog.Error("Failed to set non-blocking mode", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Start metrics server
|
||||
srvCtx, srvCancel := context.WithCancel(context.Background())
|
||||
@ -54,12 +57,14 @@ func main() {
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
srv.Shutdown(context.Background())
|
||||
_ = srv.Shutdown(context.Background())
|
||||
srvCancel()
|
||||
}()
|
||||
|
||||
slog.Info("Starting metrics server", "addr", srv.Addr)
|
||||
srv.ListenAndServe()
|
||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
slog.Warn("Failed to start metrics server", "error", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// Listen for context cancellation
|
||||
@ -84,7 +89,7 @@ func main() {
|
||||
continue
|
||||
}
|
||||
slog.Error("Error reading from input device", "error", err)
|
||||
mbus.StopTalking()
|
||||
_ = mbus.StopTalking()
|
||||
os.Exit(1)
|
||||
}
|
||||
if ev.Code == evdev.KEY_F24 && ev.Value == 1 {
|
||||
@ -104,15 +109,15 @@ func main() {
|
||||
|
||||
for v := range debouncer.C {
|
||||
if v {
|
||||
mbus.StartTalking()
|
||||
_ = mbus.StartTalking()
|
||||
slog.Info("Started talking")
|
||||
} else {
|
||||
mbus.StopTalking()
|
||||
_ = mbus.StopTalking()
|
||||
slog.Info("Stopped talking")
|
||||
}
|
||||
}
|
||||
|
||||
mbus.StopTalking()
|
||||
_ = mbus.StopTalking()
|
||||
<-srvCtx.Done()
|
||||
slog.Info("Exiting")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user