mirror of
https://github.com/TecharoHQ/anubis.git
synced 2025-08-03 01:38:14 -04:00
Add staticheck to CI (#152)
* Add staticheck to CI Signed-off-by: Xe Iaso <me@xeiaso.net> * fix staticcheck warnings Signed-off-by: Xe Iaso <me@xeiaso.net> * oh, right, playwright is broken Signed-off-by: Xe Iaso <me@xeiaso.net> --------- Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
parent
6b2ae30bae
commit
52ca5390c2
8
.github/workflows/go.yml
vendored
8
.github/workflows/go.yml
vendored
@ -11,7 +11,7 @@ permissions:
|
||||
actions: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
go_tests:
|
||||
#runs-on: alrest-techarohq
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@ -67,7 +67,7 @@ jobs:
|
||||
- name: install playwright browsers
|
||||
run: |
|
||||
npx --yes playwright@1.50.1 install --with-deps
|
||||
npx --yes playwright@1.50.1 run-server --port 3000 &
|
||||
npx --yes playwright@1.50.1 run-server --port 9001 &
|
||||
|
||||
- name: install node deps
|
||||
run: |
|
||||
@ -79,3 +79,7 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
run: npm run test
|
||||
|
||||
- uses: dominikh/staticcheck-action@v1
|
||||
with:
|
||||
version: "latest"
|
||||
|
@ -16,7 +16,6 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
@ -25,7 +24,6 @@ import (
|
||||
"github.com/TecharoHQ/anubis/internal"
|
||||
libanubis "github.com/TecharoHQ/anubis/lib"
|
||||
"github.com/TecharoHQ/anubis/lib/policy/config"
|
||||
"github.com/TecharoHQ/anubis/web"
|
||||
"github.com/facebookgo/flagenv"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
)
|
||||
@ -267,24 +265,3 @@ func metricsServer(ctx context.Context, done func()) {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func serveMainJSWithBestEncoding(w http.ResponseWriter, r *http.Request) {
|
||||
priorityList := []string{"zstd", "br", "gzip"}
|
||||
enc2ext := map[string]string{
|
||||
"zstd": "zst",
|
||||
"br": "br",
|
||||
"gzip": "gz",
|
||||
}
|
||||
|
||||
for _, enc := range priorityList {
|
||||
if strings.Contains(r.Header.Get("Accept-Encoding"), enc) {
|
||||
w.Header().Set("Content-Type", "text/javascript")
|
||||
w.Header().Set("Content-Encoding", enc)
|
||||
http.ServeFileFS(w, r, web.Static, "static/js/main.mjs."+enc2ext[enc])
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "text/javascript")
|
||||
http.ServeFileFS(w, r, web.Static, "static/js/main.mjs")
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ var (
|
||||
dockerLabels = flag.String("docker-labels", os.Getenv("DOCKER_METADATA_OUTPUT_LABELS"), "Docker image labels")
|
||||
dockerRepo = flag.String("docker-repo", "registry.int.xeserv.us/techaro/anubis", "Docker image repository for Anubis")
|
||||
dockerTags = flag.String("docker-tags", os.Getenv("DOCKER_METADATA_OUTPUT_TAGS"), "newline separated docker tags including the registry name")
|
||||
githubActor = flag.String("github-actor", "", "GitHub actor")
|
||||
githubEventName = flag.String("github-event-name", "", "GitHub event name")
|
||||
pullRequestID = flag.Int("pull-request-id", -1, "GitHub pull request ID")
|
||||
slogLevel = flag.String("slog-level", "INFO", "logging level (see https://pkg.go.dev/log/slog#hdr-Levels)")
|
||||
@ -113,11 +112,6 @@ type image struct {
|
||||
tag string
|
||||
}
|
||||
|
||||
func newlineSep2Comma(inp string) string {
|
||||
lines := strings.Split(inp, "\n")
|
||||
return strings.Join(lines, ",")
|
||||
}
|
||||
|
||||
func parseImageList(imageList string) ([]image, error) {
|
||||
images := strings.Split(imageList, "\n")
|
||||
var result []image
|
||||
|
@ -26,7 +26,7 @@ func UnchangingCache(next http.Handler) http.Handler {
|
||||
// RemoteXRealIP sets the X-Real-Ip header to the request's real IP if
|
||||
// the setting is enabled by the user.
|
||||
func RemoteXRealIP(useRemoteAddress bool, bindNetwork string, next http.Handler) http.Handler {
|
||||
if useRemoteAddress == false {
|
||||
if !useRemoteAddress {
|
||||
slog.Debug("skipping middleware, useRemoteAddress is empty")
|
||||
return next
|
||||
}
|
||||
|
@ -30,9 +30,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
serverBindAddr = flag.String("bind", "localhost:3923", "test server bind address")
|
||||
playwrightPort = flag.Int("playwright-port", 3000, "Playwright port")
|
||||
playwrightServer = flag.String("playwright", "ws://localhost:3000", "Playwright server URL")
|
||||
playwrightPort = flag.Int("playwright-port", 9001, "Playwright port")
|
||||
playwrightServer = flag.String("playwright", "ws://localhost:9001", "Playwright server URL")
|
||||
playwrightMaxTime = flag.Duration("playwright-max-time", 5*time.Second, "maximum time for Playwright requests")
|
||||
playwrightMaxHardTime = flag.Duration("playwright-max-hard-time", 5*time.Minute, "maximum time for hard Playwright requests")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user