From c13a741d64111c3ba012e04aee3b4ffac7c66148 Mon Sep 17 00:00:00 2001 From: dhawos Date: Wed, 1 Jul 2026 21:16:20 +0200 Subject: [PATCH] ci: add linter --- .gitlab-ci.yml | 36 ---------------------------------- .tangled/workflows/checks.yaml | 15 ++++++++++++++ LICENCE => LICENSE | 0 cmd/publish/main.go | 2 +- flake.nix | 7 +++++++ main.go | 11 +++++++++-- server/controller.go | 7 +++---- 7 files changed, 35 insertions(+), 43 deletions(-) delete mode 100644 .gitlab-ci.yml create mode 100644 .tangled/workflows/checks.yaml rename LICENCE => LICENSE (100%) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 55dd511..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -stages: - - build - - release - -build-docker: - image: docker:24.0.5 - services: - - name: docker:24.0.5 - alias: docker - only: - - main - stage: build - script: - - apk add --update git - - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin - - docker build -t registry.gitlab.com/dhawos/bluesky-custom-feeds:main . - - docker tag registry.gitlab.com/dhawos/bluesky-custom-feeds:main registry.gitlab.com/dhawos/bluesky-custom-feeds:$CI_COMMIT_SHA - - docker push registry.gitlab.com/dhawos/bluesky-custom-feeds:main - - docker push registry.gitlab.com/dhawos/bluesky-custom-feeds:$CI_COMMIT_SHA - -release: - image: docker:24.0.5 - services: - - name: docker:24.0.5 - alias: docker - only: - - tags - except: - - branches - stage: release - script: - - apk add --update git - - echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin - - docker build -t registry.gitlab.com/dhawos/bluesky-custom-feeds:$CI_COMMIT_TAG . - - docker push registry.gitlab.com/dhawos/bluesky-custom-feeds:$CI_COMMIT_TAG - diff --git a/.tangled/workflows/checks.yaml b/.tangled/workflows/checks.yaml new file mode 100644 index 0000000..a093679 --- /dev/null +++ b/.tangled/workflows/checks.yaml @@ -0,0 +1,15 @@ +when: + - event: ["pull_request"] + branch: ["main"] +engine: "microvm" +clone: + depth: 1 +dependencies: + - go + - golangci-lint + - gcc +environment: + CGO_ENABLED: 1 +steps: + - name: "Lint" + command: "golangci-lint run" diff --git a/LICENCE b/LICENSE similarity index 100% rename from LICENCE rename to LICENSE diff --git a/cmd/publish/main.go b/cmd/publish/main.go index e6c4938..6b9359d 100644 --- a/cmd/publish/main.go +++ b/cmd/publish/main.go @@ -106,7 +106,7 @@ var PublishCmd = &cobra.Command{ } ownerPDS, err := atprotoutil.ResolveUserPDS(ctx, publisherConfig.Feed.OwnerDID) - if err := config.Loader.Unmarshal(&publisherConfig); err != nil { + if err != nil { return fmt.Errorf("resolving user PDS: %w", err) } slog.Info("Found user PDS", slog.String("pds", ownerPDS.Host)) diff --git a/flake.nix b/flake.nix index 8c8fd62..34adaef 100644 --- a/flake.nix +++ b/flake.nix @@ -114,6 +114,13 @@ ''); meta.description = "Start indexer"; }; + lint= { + type = "app"; + program = toString (pkgs.writeShellScript "lint" '' + ${pkgs.golangci-lint}/bin/golangci-lint run; + ''); + meta.description = "Start indexer"; + }; }; }) systems ); diff --git a/main.go b/main.go index a5c33fa..c5c62f1 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,14 @@ package main -import "tangled.org/dhawos.dev/bskyfeedctl/cmd" +import ( + "os" + + "tangled.org/dhawos.dev/bskyfeedctl/cmd" +) func main() { - cmd.RootCmd.Execute() + err := cmd.RootCmd.Execute() + if err != nil { + os.Exit(1) + } } diff --git a/server/controller.go b/server/controller.go index 6542752..19cffa1 100644 --- a/server/controller.go +++ b/server/controller.go @@ -35,10 +35,9 @@ type BlueskyFeedGeneratorConfig struct { } type BlueskyFeedGenerator struct { - serverConfig ServerConfig - feedConfig feeds.FeedConfig - elasticConfig indexer.ElasticsearchConfig - feeds map[string]feeds.Feed + serverConfig ServerConfig + feedConfig feeds.FeedConfig + feeds map[string]feeds.Feed } func NewBlueskyFeedGenerator(serverConfig ServerConfig, feedConfig feeds.FeedConfig, esConfig indexer.ElasticsearchConfig) (*BlueskyFeedGenerator, error) { -- 2.51.2