diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 2837c98..09b543a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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" diff --git a/cmd/anubis/main.go b/cmd/anubis/main.go index b634676..a7e7350 100644 --- a/cmd/anubis/main.go +++ b/cmd/anubis/main.go @@ -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") -} diff --git a/cmd/containerbuild/main.go b/cmd/containerbuild/main.go index 95194c6..18e879c 100644 --- a/cmd/containerbuild/main.go +++ b/cmd/containerbuild/main.go @@ -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 diff --git a/internal/headers.go b/internal/headers.go index d73fa33..a48ce54 100644 --- a/internal/headers.go +++ b/internal/headers.go @@ -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 } diff --git a/internal/test/playwright_test.go b/internal/test/playwright_test.go index 8a0d501..d81b86a 100644 --- a/internal/test/playwright_test.go +++ b/internal/test/playwright_test.go @@ -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")