From 4852b27698cbd1b80c9decc077b3e15d151a636b Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 7 Apr 2024 12:07:20 -0700 Subject: [PATCH 1/2] ci(lint): fix linter for multi-module repo --- .github/workflows/lint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5bc35a6..d517c12 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,6 +11,9 @@ jobs: golangci: name: golangci runs-on: ubuntu-latest + strategy: + matrix: + modules: [ ".", "./functions/src/data/init", "./functions/src/data/fetch", "./functions/src/data/load", "./functions/src/handlers/lookup"] steps: - uses: actions/setup-go@v3 with: @@ -23,7 +26,7 @@ jobs: version: latest # Optional: working directory, useful for monorepos - # working-directory: somedir + working-directory: ${{ matrix.modules }} # Optional: golangci-lint command line arguments. args: -E misspell -E revive -E bodyclose -E errname -E gofmt --timeout=5m From 2dac40630d1123c2d891f90da11276997e2386a8 Mon Sep 17 00:00:00 2001 From: Benjamin Cane Date: Sun, 7 Apr 2024 12:11:30 -0700 Subject: [PATCH 2/2] chore: fixing linter errors with gofmt and goimports --- functions/src/data/fetch/main.go | 1 + functions/src/data/init/main.go | 1 + functions/src/data/load/main.go | 7 ++++--- functions/src/handlers/lookup/main.go | 7 ++++--- pkg/airport/airport.go | 1 + pkg/airport/parsers/csv/csv.go | 3 ++- pkg/airport/parsers/csv/csv_test.go | 5 +++-- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/functions/src/data/fetch/main.go b/functions/src/data/fetch/main.go index 6942ff4..c5dc509 100644 --- a/functions/src/data/fetch/main.go +++ b/functions/src/data/fetch/main.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "github.com/tarmac-project/tarmac/pkg/sdk" ) diff --git a/functions/src/data/init/main.go b/functions/src/data/init/main.go index e1e2557..89cee4b 100644 --- a/functions/src/data/init/main.go +++ b/functions/src/data/init/main.go @@ -7,6 +7,7 @@ package main import ( "fmt" + "github.com/tarmac-project/tarmac/pkg/sdk" ) diff --git a/functions/src/data/load/main.go b/functions/src/data/load/main.go index bb9a642..5c04e07 100644 --- a/functions/src/data/load/main.go +++ b/functions/src/data/load/main.go @@ -1,8 +1,8 @@ /* -The purpose of this function is to download the CSV data (by calling another function), parse it, enrich the data, and +The purpose of this function is to download the CSV data (by calling another function), parse it, enrich the data, and load the contents within the SQL database. -This function is called multiple times throughout the application. It's called by an "init" function and also set +This function is called multiple times throughout the application. It's called by an "init" function and also set as a scheduled task by itself. */ package main @@ -10,9 +10,10 @@ package main import ( "bytes" "fmt" + "html" + "github.com/tarmac-project/example-airport-lookup-go/pkg/airport/parsers/csv" "github.com/tarmac-project/tarmac/pkg/sdk" - "html" ) type Function struct { diff --git a/functions/src/handlers/lookup/main.go b/functions/src/handlers/lookup/main.go index 1418c62..017eafe 100644 --- a/functions/src/handlers/lookup/main.go +++ b/functions/src/handlers/lookup/main.go @@ -1,6 +1,6 @@ /* -This function is a lookup request handler function. When a request is received, this function is called and will parse -the incoming request, look up the requested airport from the cache, on cache miss, find the requested data in the +This function is a lookup request handler function. When a request is received, this function is called and will parse +the incoming request, look up the requested airport from the cache, on cache miss, find the requested data in the database, and provide it back as a response to the request. */ package main @@ -8,9 +8,10 @@ package main import ( "encoding/base64" "fmt" + "html" + "github.com/tarmac-project/tarmac/pkg/sdk" "github.com/valyala/fastjson" - "html" ) // Function is the main function object that will be initialized diff --git a/pkg/airport/airport.go b/pkg/airport/airport.go index 531aa2f..3c2087c 100644 --- a/pkg/airport/airport.go +++ b/pkg/airport/airport.go @@ -2,6 +2,7 @@ package airport import ( "fmt" + "github.com/enescakir/emoji" ) diff --git a/pkg/airport/parsers/csv/csv.go b/pkg/airport/parsers/csv/csv.go index 0c90aa8..05843b6 100644 --- a/pkg/airport/parsers/csv/csv.go +++ b/pkg/airport/parsers/csv/csv.go @@ -3,8 +3,9 @@ package csv import ( "encoding/csv" "fmt" - "github.com/tarmac-project/example-airport-lookup-go/pkg/airport" "io" + + "github.com/tarmac-project/example-airport-lookup-go/pkg/airport" ) var ( diff --git a/pkg/airport/parsers/csv/csv_test.go b/pkg/airport/parsers/csv/csv_test.go index c99c523..0cc2a5b 100644 --- a/pkg/airport/parsers/csv/csv_test.go +++ b/pkg/airport/parsers/csv/csv_test.go @@ -2,10 +2,11 @@ package csv import ( "bytes" - "github.com/enescakir/emoji" - "github.com/tarmac-project/example-airport-lookup-go/pkg/airport" "reflect" "testing" + + "github.com/enescakir/emoji" + "github.com/tarmac-project/example-airport-lookup-go/pkg/airport" ) type RecordToAirportTestCase struct {