diff --git a/.github/workflows/buf.yaml b/.github/workflows/buf.yaml index 49c525e..f2d13c1 100644 --- a/.github/workflows/buf.yaml +++ b/.github/workflows/buf.yaml @@ -21,7 +21,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Buf build/lint/format/breaking + - name: Buf build/lint/format/breaking/push uses: bufbuild/buf-action@v1 with: - push: false # we don't use buf push + token: ${{ secrets.BUF_TOKEN }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 757ba99..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - merge_group: - branches: ["**"] - -jobs: - tests: - name: Run tests - strategy: - matrix: - os: [Ubuntu] - go-version: ["1.24.x"] - runs-on: ${{ matrix.os }}-latest - permissions: - contents: read # for golangci-lint-action - steps: - - uses: actions/checkout@v4 - with: - lfs: true - - name: Setup Go ${{ matrix.go-version }} - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Install dependencies - run: | - go get ./... - go install github.com/jstemmer/go-junit-report@latest - - name: Build - run: go build -v ./... - - name: Run Tests - run: go test -v ./... | go-junit-report -set-exit-code > test-report.xml - - name: Test Summary - uses: test-summary/action@v2 - with: - paths: "test-report.xml" - if: always() - - name: Lint - uses: golangci/golangci-lint-action@v7 - with: - version: v2.0.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 2793552..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Release - -on: - push: - tags: - - "v*" - -jobs: - goreleaser: - strategy: - matrix: - os: [ Ubuntu ] - go-version: [ "1.24.x" ] - runs-on: ${{ matrix.os }}-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go ${{ matrix.go-version }} - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - version: "~> v2" - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 10aa0f9..090a1f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,2 @@ .idea .DS_Store -tmp -scratch - -# SQLite databases -*.db -*.db-shm -*.db-wal - -# Ignore non-Go generated files -**/protogen/python/ -**/protogen/web/ - -# Added by goreleaser init: -dist/ diff --git a/.golangci.yaml b/.golangci.yaml deleted file mode 100644 index 687e4e9..0000000 --- a/.golangci.yaml +++ /dev/null @@ -1,167 +0,0 @@ -# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/golangci.jsonschema.json ---- -version: "2" -linters: - enable: # list taken from https://golangci-lint.run/usage/linters/ - last updated 2025-02-14 for v1.64.5 - # enabled by default, but list them here to be explicit - - errcheck - - govet - - ineffassign - - staticcheck - - unused - # other linters (that would be disabled by default) - - asasalint # checks for pass []any as any in variadic func(...any) - - asciicheck # checks that your code does not contain non-ASCII identifiers - - bidichk # checks for dangerous unicode character sequences - - bodyclose # checks whether HTTP response body is closed successfully - - canonicalheader # checks for canonical names in HTTP headers - - containedctx # detects struct contained context.Context field - #- contextcheck # checks for inherited context.Context - - copyloopvar # detects places where loop variables are copied - #- cyclop # checks function and package cyclomatic complexity - - decorder # check declaration order and count of types, constants, variables and functions - #- depguard # Go linter that checks if package imports are in a list of acceptable packages - - dogsled # Checks assignments with too many blank identifiers (e.g. x, _, _, _, := f()) - #- dupl # tool for code clone detection - - dupword # checks for duplicate words in the source code - - durationcheck # checks for two durations multiplied together - #- err113 # checks the errors handling expressions - - errchkjson # checks types passed to the json encoding functions. - - errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error - - errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13 - - exhaustive # checks exhaustiveness of enum switch statements - #- exhaustruct # checks if all structure fields are initialized - - exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions. - - fatcontext # finds nested context.WithValue calls in loops - - forbidigo # forbids identifiers - #- forcetypeassert # finds forced type assertions - #- funlen # Tool for detection of long functions - #- ginkgolinter # Enforces the Ginkgo testing package guidelines. - - gocheckcompilerdirectives # validates go compiler directive comments (//go:) - #- gochecknoglobals # checks that no global variables exist - - gochecknoinits # checks that no init functions are present in Go code - - gochecksumtype # checks exhaustiveness on Go "sum types" - #- gocognit # Computes and checks the cognitive complexity of functions - - goconst # finds repeated strings that could be replaced by a constant - - gocritic # provides diagnostics that check for bugs, performance and style issues - #- gocyclo # Computes and checks the cyclomatic complexity of functions - #- godot # Check if comments end in a period - #- godox # Tool for detection of FIXME, TODO and other comment keywords - #- goheader # Checks is file header matches to pattern - - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod - - gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations - - goprintffuncname # checks that printf-like functions are named with f at the end - - gosec # inspects source code for security problems - - gosmopolitan # Report certain i18n/l10n anti-patterns in your Go codebase. - - grouper # Analyze expression groups - - iface # Detect the incorrect use of interfaces, helping developers avoid interface pollution. - - importas # Enforces consistent import aliases. - #- inamedparam # Reports interfaces with unnamed method parameters. - - interfacebloat # Checks the number of methods in an interface - - intrange # finds places where for loops could make use of an integer range - #- ireturn # Accept Interfaces, Return Concrete Types - #- lll # Reports long lines - - loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap) - #- maintidx # measures the maintainability index of each function - - makezero # finds slice declarations with non-zero initial length - - mirror # reports wrong mirror patterns of bytes/strings usage - - misspell # finds commonly misspelled English words in comments - #- mnd # Detects magic numbers - - musttag # enforces field tags in (un)marshaled structs - - nakedret # finds naked returns in functions greater than a specified function length - #- nestif # Reports deeply nested if statements - - nilerr # finds the code that returns nil even if it checks that the error is not nil - - nilnesserr # Reports constructs that checks for err != nil, but returns a different nil value error. - - nilnil # checks that there is no simultaneous return of nil error and an invalid value - #- nlreturn # Checks for a new line before return and branch statements to increase code clarity - - noctx # finds sending http request without context.Context - - nolintlint # reports ill-formed or insufficient nolint directives - - nonamedreturns # reports all named returns - - nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL - - perfsprint # checks that fmt.Sprintf can be replaced with a faster alternative - #- paralleltest # detects missing usage of t.Parallel() method in your Go test - - perfsprint # Checks that fmt.Sprintf can be replaced with a faster alternative. - - prealloc # finds slice declarations that could potentially be preallocated - - predeclared # finds code that shadows one of Go's predeclared identifiers - - promlinter # checks Prometheus metrics naming via promlint - - protogetter # reports direct reads from proto message fields when getters should be used - - reassign # checks that package variables are not reassigned - - recvcheck # checks for receiver type consistency - - revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint - - rowserrcheck # checks whether Err of rows is checked successfully - - sloglint # ensure consistent code style when using log/slog - - spancheck # checks for mistakes with OpenTelemetry/Census spans - - sqlclosecheck # checks that sql.Rows and sql.Stmt are closed - - tagalign # checks that struct tags are well aligned - #- tagliatelle # Checks the struct tags. - #- testableexamples # checks if examples are testable (have an expected output) - - testifylint # checks usage of github.com/stretchr/testify - #- testpackage # makes you use a separate _test package - #- thelper # detects golang test helpers without t.Helper() call. - - tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes - - unconvert # removes unnecessary type conversions - - unparam # reports unused function parameters - - usestdlibvars # detects the possibility to use variables/constants from the Go standard library - - usetesting # reports uses of functions with replacement inside the testing package - #- varnamelen # checks that the length of a variable's name matches its scope - - wastedassign # finds wasted assignment statements - - whitespace # detects leading and trailing whitespace - #- wrapcheck # Checks that errors returned from external packages are wrapped - #- wsl # whitespace linter - add or remove empty lines - #- zerologlint # checks wrong usage of zerolog - #- tenv # deprecated in favor of usetesting - settings: - gosec: - excludes: - - G601 # Not relevant anymore with Go 1.22 and later - - G404 # Use of weak random number generator (math/rand instead of crypto/rand) - govet: - enable-all: true - disable: - - fieldalignment # too strict - - shadow # too strict - perfsprint: - strconcat: false - revive: - rules: - - name: var-naming - arguments: - - [] - - [] - - - skipPackageNameChecks: true - staticcheck: - checks: - - all - - -ST1003 # should not use underscores in package names - tagalign: - order: - - flag - - env - - default - - secret - - toml - - json - - validate - - global - - help - strict: false - exclusions: - generated: strict - warn-unused: true - presets: - - comments - - common-false-positives - - legacy - - std-error-handling - rules: - # Exclude some linters from running on tests files. - - linters: - - containedctx - - dogsled - path: _test.go -formatters: - enable: - - gci - - gofmt - - gofumpt - - goimports diff --git a/.goreleaser.yaml b/.goreleaser.yaml deleted file mode 100644 index f376443..0000000 --- a/.goreleaser.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# yaml-language-server: $schema=https://goreleaser.com/static/schema.json -# Documentation at https://goreleaser.com -version: 2 - -builds: - - skip: true - -changelog: - use: github-native diff --git a/README.md b/README.md index e8d3c55..993af7c 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,11 @@
- - PyPi Latest Release badge + + BSR - - MIT License - - - Build Status + + MIT License Join us on Discord @@ -22,143 +19,30 @@ Documentation | Console - | - Example Gallery

-# Tilebox Go +# Tilebox API -Go library for [Tilebox](https://tilebox.com), a lightweight space data management and orchestration software - on ground and in orbit. +Protocol Buffers used by [Tilebox](https://tilebox.com), a lightweight space data management and orchestration software - on ground and in orbit. ## Installation -Run the following command to add the library to your project: - -```bash -go get github.com/tilebox/tilebox-go -``` +### Pre-commit hooks -For Tilebox datasets type generation, you will need to install [tilebox-generate](https://github.com/tilebox/tilebox-generate) command-line tool. +We use [pre-commit](https://pre-commit.com/) to run linters before committing. Run the following command once to install the hooks: -## Examples - -For examples on how to use the library, see the [examples](examples) directory. +```bash +pre-commit install +```` ## Usage -### Writing a Task - -Here we define a simple task that prints "Hello World!" to the console: - -```go -package helloworld +Command to lock buf dependencies: -import ( - "context" - "log/slog" - - "github.com/tilebox/tilebox-go/workflows/v1" -) - -type HelloTask struct { - Name string // You can add any fields you need to the task struct. -} - -// The Execute method isn't needed to submit a task but is required to run a task. -func (t *HelloTask) Execute(context.Context) error { - slog.Info("Hello World!", "Name", t.Name) - return nil -} - -// The Identifier method is optional and will be generated if not provided. -func (t *HelloTask) Identifier() workflows.TaskIdentifier { - return workflows.NewTaskIdentifier("hello-world", "v1.0") -} +```shell +buf dep update ``` -### Submitting a Job - -Here we create a Workflows client and submit a job with a single task: - -```go -package main - -import ( - "context" - "log/slog" - - "github.com/tilebox/tilebox-go/workflows/v1" -) - -type HelloTask struct { - Name string -} - -func main() { - ctx := context.Background() - client := workflows.NewClient() - - job, err := client.Jobs.Submit(ctx, "hello-world", - []workflows.Task{ - &HelloTask{ - Name: "Tilebox", - }, - }, - ) - if err != nil { - slog.Error("Failed to submit job", slog.Any("error", err)) - return - } - - slog.Info("Job submitted", slog.String("job_id", job.ID.String())) -} -``` - -### Running a Worker - -Here we create a TaskRunner and run a worker that is capable of executing `HelloTask` tasks: - -```go -package main - -import ( - "context" - "log/slog" - - "github.com/tilebox/tilebox-go/workflows/v1" -) - -type HelloTask struct { - Name string -} - -// The Execute method is required to run a task. -func (t *HelloTask) Execute(context.Context) error { - slog.Info("Hello World!", "Name", t.Name) - return nil -} - -func main() { - ctx := context.Background() - client := workflows.NewClient() - - runner, err := client.NewTaskRunner(ctx) - if err != nil { - slog.Error("failed to create task runner", slog.Any("error", err)) - return - } - - err = runner.RegisterTasks(&HelloTask{}) - if err != nil { - slog.Error("failed to register tasks", slog.Any("error", err)) - return - } - - runner.RunForever(ctx) -} -``` - - ## License Distributed under the MIT License (`The MIT License`). diff --git a/buf.lock b/buf.lock new file mode 100644 index 0000000..9a4fa6c --- /dev/null +++ b/buf.lock @@ -0,0 +1,6 @@ +# Generated by buf. DO NOT EDIT. +version: v2 +deps: + - name: buf.build/googleapis/googleapis + commit: 61b203b9a9164be9a834f58c37be6f62 + digest: b5:7811a98b35bd2e4ae5c3ac73c8b3d9ae429f3a790da15de188dc98fc2b77d6bb10e45711f14903af9553fa9821dff256054f2e4b7795789265bc476bec2f088c diff --git a/buf.yaml b/buf.yaml index 1300d78..aa5a0a3 100644 --- a/buf.yaml +++ b/buf.yaml @@ -1,7 +1,7 @@ version: v2 modules: - path: apis - name: buf.build/tilebox/tilebox-go + name: buf.build/tilebox/api deps: - buf.build/googleapis/googleapis lint: # https://buf.build/docs/lint/rules/