Skip to content
Merged
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
108 changes: 28 additions & 80 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,87 +33,42 @@ concurrency:
jobs:
check-license:
name: License header
if: (github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || (github.event_name != 'schedule')
if: github.repository == 'apache/skywalking-cli'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Check License Header
uses: apache/skywalking-eyes@5dfa68f93380a5e57259faaf95088b7f133b5778
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: "1.24"

- name: Check Dependencies License
run: make dependency-license


changes:
runs-on: ubuntu-latest
if: github.event_name != 'schedule'
timeout-minutes: 10
outputs:
cli: ${{ steps.filter-cli.outputs.any_modified }}
steps:
- uses: actions/checkout@v3 # required for push event
with:
fetch-depth: 0
- name: Check for CLI source changes
id: filter-cli
# The GHA version is pinned by infra
uses: tj-actions/changed-files@v43.0.0
with:
files_from_source_file: .github/file-filters.txt
- name: List all modified files
if: steps.filter-cli.outputs.any_modified == 'true'
run: |
echo "Files that have changed or modified:"
echo "Filter-cli: ${{ steps.filter-cli.outputs.all_changed_and_modified_files }}"


golang-lint:
name: Golang Lint
runs-on: ubuntu-latest
needs: [changes]
if: |
( always() && ! cancelled() ) &&
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.50.0
args: --timeout 5m


build:
name: Build
needs: [changes]
runs-on: ubuntu-latest
if: |
( always() && ! cancelled() ) &&
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
if: github.repository == 'apache/skywalking-cli'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.24

- name: Check code generation
run: make check-codegen

- uses: actions/upload-artifact@v3
- name: Lint
run: make lint

- uses: actions/upload-artifact@v4
if: failure()
with:
name: check-diff
Expand All @@ -129,20 +84,20 @@ jobs:
command-tests:
name: Command Tests
runs-on: ubuntu-latest
needs: [changes]
if: |
( always() && ! cancelled() ) &&
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
if: github.repository == 'apache/skywalking-cli'
strategy:
matrix:
oap:
- a65a6e0ff2ef9c716131b36172399076307c35f1 # Feb 27th, 2024
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.18
go-version: 1.24

- name: Install swctl
run: make install DESTDIR=/usr/local/bin

- name: Test commands
uses: apache/skywalking-infra-e2e@cf589b4a0b9f8e6f436f78e9cfd94a1ee5494180
Expand All @@ -155,16 +110,13 @@ jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
needs: [changes]
if: |
( always() && ! cancelled() ) &&
((github.event_name == 'schedule' && github.repository == 'apache/skywalking-cli') || needs.changes.outputs.cli == 'true')
if: github.repository == 'apache/skywalking-cli'
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: '1.18'
go-version: '1.24'

- name: run unit tests and report coverage
working-directory: ./
Expand All @@ -176,7 +128,6 @@ jobs:
name: Required
needs:
- check-license
- golang-lint
- build
- command-tests
- unit-tests
Expand All @@ -185,15 +136,12 @@ jobs:
steps:
- name: Merge Requirement
run: |
execute=${{ needs.changes.outputs.cli }}
checkLicense=${{ needs.check-license.result }}
[[ ${checkLicense} == 'success' ]] || exit -1;
golangLint=${{ needs.golang-lint.result }};
[[ ${checkLicense} == 'success' ]] || exit 1;
build=${{ needs.build.result }};
commandTests=${{ needs.command-tests.result }};
unitTests=${{ needs.unit-tests.result }};
[[ ${golangLint} == 'success' ]] || [[ ${execute} != 'true' && ${golangLint} == 'skipped' ]] || exit -2;
[[ ${build} == 'success' ]] || [[ ${execute} != 'true' && ${build} == 'skipped' ]] || exit -3;
[[ ${commandTests} == 'success' ]] || [[ ${execute} != 'true' && ${commandTests} == 'skipped' ]] || exit -4;
[[ ${unitTests} == 'success' ]] || [[ ${execute} != 'true' && ${unitTests} == 'skipped' ]] || exit -5;
exit 0;
[[ ${build} == 'success' ]] || [[ ${build} == 'skipped' ]] || exit 3;
[[ ${commandTests} == 'success' ]] || [[ ${commandTests} == 'skipped' ]] || exit 4;
[[ ${unitTests} == 'success' ]] || [[ ${unitTests} == 'skipped' ]] || exit 5;
exit 0;
4 changes: 2 additions & 2 deletions .github/workflows/publish-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.24
- name: Log in to the Container registry
uses: docker/login-action@v1.10.0
with:
registry: ${{ env.HUB }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker images
run: make docker.push || make docker.push
run: make docker.push || make docker.push
15 changes: 2 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,15 @@

linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
enable:
- shadow
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 200
goconst:
min-len: 2
min-occurrences: 2
depguard:
list-type: blacklist
packages:
-
include-go-root: true
packages-with-error-messages:
fmt: "logging is allowed only by logutils.Log"
misspell:
locale: US
lll:
Expand All @@ -60,7 +50,6 @@ linters-settings:
linters:
enable:
- bodyclose
- depguard
- dogsled
- dupl
- errcheck
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.18 AS builder
FROM golang:1.24 AS builder

ARG VERSION

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ deps:
@$(GO_GET) -v -t -d ./...

$(GO_LINT):
@$(GO_LINT) version > /dev/null 2>&1 || curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GO_PATH)/bin v1.50.0
@$(GO_LINT) version > /dev/null 2>&1 || go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.0
$(LICENSE_EYE):
@$(LICENSE_EYE) --version > /dev/null 2>&1 || go install github.com/apache/skywalking-eyes/cmd/license-eye@d38fe05

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/apache/skywalking-cli

go 1.18
go 1.24

require (
github.com/apache/skywalking-swck/operator v0.0.0-20220815142653-ed08076b7433
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/completion/bash.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var bashCommand = &cli.Command{
Aliases: []string{"b"},
Usage: "Output shell completion code for bash",
ArgsUsage: "[parameters...]",
Action: func(ctx *cli.Context) error {
Action: func(_ *cli.Context) error {
fmt.Print(bashScript)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/completion/fish.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var fishCommand = &cli.Command{
Aliases: []string{"f"},
Usage: "Output shell completion code for fish",
ArgsUsage: "[parameters...]",
Action: func(ctx *cli.Context) error {
Action: func(_ *cli.Context) error {
fmt.Print(fishScript)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/completion/powershell.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var powershellCommand = &cli.Command{
Aliases: []string{"p"},
Usage: "Output shell completion code for powershell",
ArgsUsage: "[parameters...]",
Action: func(ctx *cli.Context) error {
Action: func(_ *cli.Context) error {
fmt.Print(powershellScript)
return nil
},
Expand Down
2 changes: 1 addition & 1 deletion internal/commands/completion/zsh.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ var zshCommand = &cli.Command{
Aliases: []string{"z"},
Usage: "Output shell completion code for zsh",
ArgsUsage: "[parameters...]",
Action: func(ctx *cli.Context) error {
Action: func(_ *cli.Context) error {
fmt.Print(zshScript)
return nil
},
Expand Down
12 changes: 6 additions & 6 deletions internal/commands/interceptor/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func ParseDuration(start, end string, userStep api.Step) (startTime, endTime tim
var err error

// both are present
if len(start) > 0 && len(end) > 0 {
if start != "" && end != "" {
if userStep, startTime, err = TryParseTime(start, userStep); err != nil {
logger.Log.Fatalln("Unsupported time format:", start, err)
}
Expand All @@ -120,12 +120,12 @@ func ParseDuration(start, end string, userStep api.Step) (startTime, endTime tim
logger.Log.Fatalln("Unsupported time format:", start, err)
}
return startTime, startTime.Add(30 * utils.StepDuration[step]), step, utils.EndAbsent
} else { // start is absent
if step, endTime, err = TryParseTime(end, userStep); err != nil {
logger.Log.Fatalln("Unsupported time format:", end, err)
}
return endTime.Add(-30 * utils.StepDuration[step]), endTime, step, utils.StartAbsent
}
// start is absent
if step, endTime, err = TryParseTime(end, userStep); err != nil {
logger.Log.Fatalln("Unsupported time format:", end, err)
}
return endTime.Add(-30 * utils.StepDuration[step]), endTime, step, utils.StartAbsent
}

// AlignPrecision aligns the two time strings to same precision
Expand Down
4 changes: 2 additions & 2 deletions internal/commands/profiling/asyncprofiler/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $ swctl profiling async create --service-name=service-name --duration=60 --event
),
Action: func(ctx *cli.Context) error {
serviceID := ctx.String("service-id")
instanceIds := strings.Split(ctx.String("instance-id-list"), ",")
instanceIDs := strings.Split(ctx.String("instance-id-list"), ",")
duration := ctx.Int("duration")
eventTypes := ctx.Generic("events").(*asyncprofiler.ProfilerEventTypeEnumValue).Selected

Expand All @@ -80,7 +80,7 @@ $ swctl profiling async create --service-name=service-name --duration=60 --event

request := &query.AsyncProfilerTaskCreationRequest{
ServiceID: serviceID,
ServiceInstanceIds: instanceIds,
ServiceInstanceIds: instanceIDs,
Duration: duration,
Events: eventTypes,
ExecArgs: execArgs,
Expand Down
6 changes: 3 additions & 3 deletions pkg/heatmap/axes/axes.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type YDetails struct {

// RequiredWidth calculates the minimum width required
// in order to draw the Y axis and its labels.
func RequiredWidth(max string) int {
return runewidth.StringWidth(max) + AxisWidth
func RequiredWidth(mx string) int {
return runewidth.StringWidth(mx) + AxisWidth
}

// NewYDetails retrieves details about the Y axis required
Expand Down Expand Up @@ -100,7 +100,7 @@ type XDetails struct {
// plotted.
// customLabels are the desired labels for the X axis, these are preferred if
// provided.
func NewXDetails(cvsAr image.Rectangle, yEnd image.Point, stringLabels []string, cellWidth int) (*XDetails, error) {
func NewXDetails(_ image.Rectangle, yEnd image.Point, stringLabels []string, cellWidth int) (*XDetails, error) {
// The space between the start of the axis and the end of the canvas.
// graphWidth := cvsAr.Dx() - yEnd.X - 1
graphWidth := len(stringLabels) * cellWidth
Expand Down
8 changes: 4 additions & 4 deletions pkg/heatmap/axes/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ type Label struct {
// Labels are returned with Y coordinates in ascending order.
// Y coordinates grow down.
func yLabels(graphHeight, labelWidth int, stringLabels []string) ([]*Label, error) {
if min := 2; graphHeight < min {
return nil, fmt.Errorf("cannot place labels on a canvas with height %d, minimum is %d", graphHeight, min)
if mn := 2; graphHeight < mn {
return nil, fmt.Errorf("cannot place labels on a canvas with height %d, minimum is %d", graphHeight, mn)
}
if min := 0; labelWidth < min {
return nil, fmt.Errorf("cannot place labels in label area width %d, minimum is %d", labelWidth, min)
if mn := 0; labelWidth < mn {
return nil, fmt.Errorf("cannot place labels in label area width %d, minimum is %d", labelWidth, mn)
}

var labels []*Label
Expand Down
Loading
Loading