Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add linting and acceptance test workflow #56

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/10-test-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "10 - Test: Linting"
on:
push:
tags:
- v*
branches:
- main
- "v*"
workflow_dispatch:
pull_request:

jobs:
golangci:
name: Test Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Tailpipe plugin SDK repository
uses: actions/checkout@v4
with:
repository: turbot/tailpipe-plugin-sdk
path: tailpipe-plugin-sdk
token: ${{ secrets.GH_ACCESS_TOKEN }}

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v4
with:
repository: turbot/pipe-fittings
path: pipe-fittings
ref: tp

# this is required, check golangci-lint-action docs
- uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false # setup-go v4 caches by default, do not change this parameter, check golangci-lint-action doc: https://github.com/golangci/golangci-lint-action/pull/704

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0
args: --timeout=10m
working-directory: tailpipe-plugin-sdk
skip-cache: true
49 changes: 49 additions & 0 deletions .github/workflows/11-test-acceptance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: "11 - Test: Acceptance"
on:
workflow_call:
push:
tags:
- v*
branches:
- main
workflow_dispatch:
pull_request:

env:
TAILPIPE_UPDATE_CHECK: false
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}

jobs:
goreleaser:
name: Build
runs-on: ubuntu-latest
steps:

- name: Checkout Pipe Fittings Components repository
uses: actions/checkout@v4
with:
repository: turbot/pipe-fittings
path: pipe-fittings
ref: tp

- name: Checkout Tailpipe plugin SDK repository
uses: actions/checkout@v4
with:
repository: turbot/tailpipe-plugin-sdk
path: tailpipe-plugin-sdk
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: develop

# this is required, check golangci-lint-action docs
- uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false # setup-go v4 caches by default, do not change this parameter, check golangci-lint-action doc: https://github.com/golangci/golangci-lint-action/pull/704

- name: Run CLI Unit Tests
run: |
cd tailpipe-plugin-sdk
go clean -testcache
go test -timeout 30s ./... -test.v

# TODO - add SDK acceptance tests
42 changes: 42 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
linters:
disable-all: true
enable:
# default rules
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- typecheck
- unused
# other rules
- asasalint
- asciicheck
- bidichk
- durationcheck
- exportloopref
- forbidigo
- gocritic
- gocheckcompilerdirectives
- gosec
- makezero
- nilerr
- nolintlint
- reassign
- sqlclosecheck
- unconvert

linters-settings:
nolintlint:
require-explanation: true
require-specific: true

gocritic:
disabled-checks:
- ifElseChain # style
- singleCaseSwitch # style & it's actually not a bad idea to use single case switch in some cases
- assignOp # style
- commentFormatting # style

run:
timeout: 5m
5 changes: 4 additions & 1 deletion artifact_source/artifact_source_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func (a *ArtifactSourceImpl[S, T]) OnArtifactDownloaded(ctx context.Context, inf
}

func (a *ArtifactSourceImpl[S, T]) GetTiming() types.TimingCollection {
return types.TimingCollection{a.DiscoveryTiming, a.DownloadTiming, a.ExtractTiming}
return types.TimingCollection{a.DiscoveryTiming, a.DownloadTiming, a.ExtractTiming} //nolint: govet // TODO Timing contains sync.Mutex, find a nice way of handling this
}

// convert a downloaded artifact to a set of raw rows, with optional metadata
Expand All @@ -287,6 +287,9 @@ func (a *ArtifactSourceImpl[S, T]) processArtifact(ctx context.Context, info *ty
slog.Debug("RowSourceImpl processArtifact", "artifact", info.Name)

executionId, err := context_values.ExecutionIdFromContext(ctx)
if err != nil {
return err
}
// load artifact data
// resolve the loader - if one has not been specified, create a default for the file tyoe
loader, err := a.resolveLoader(info)
Expand Down
Loading
Loading