Skip to content

Commit

Permalink
Adding staticcheck to the CI
Browse files Browse the repository at this point in the history
This commit adds static check to our CI and fixes all of its complaints.
  • Loading branch information
ricardomaraschini committed Feb 11, 2022
1 parent c54db6a commit a0efb02
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/pullrequest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ jobs:
- name: run linter
run: golint -set_exit_status ./cmd/kubectl-image ./cmd/imgctrl ./controllers/... ./services/...

staticcheck:
name: staticcheck
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
steps:
- name: check out code
uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: run staticcheck
run: staticcheck ./...

unit:
name: unit
runs-on: ubuntu-latest
Expand All @@ -47,6 +62,7 @@ jobs:
needs:
- lint
- unit
- staticcheck
runs-on: ubuntu-latest
container:
image: quay.io/tagger/actions-image:latest
Expand All @@ -65,6 +81,7 @@ jobs:
needs:
- lint
- unit
- staticcheck
runs-on: ubuntu-latest
steps:
- name: check out code
Expand Down
4 changes: 2 additions & 2 deletions infra/images/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ func (t *ImageImport) FlaggedAsConsumedDuration() (time.Duration, error) {
}

strsince := t.Annotations[ImageImportConsumedFlagAnnotation]
since, err := time.Parse(time.ANSIC, strsince)
flagtime, err := time.Parse(time.ANSIC, strsince)
if err != nil {
return 0, fmt.Errorf(
"bogus %s annotation: %w", ImageImportConsumedFlagAnnotation, err,
)
}

return time.Now().Sub(since), nil
return time.Since(flagtime), nil
}

// CurrentReferenceForImage looks through provided Image and returns the most recent imported
Expand Down
2 changes: 1 addition & 1 deletion services/imageimport.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func (t *ImageImport) Import(
return nil, fmt.Errorf("fail to mirror image: %w", err)
}

latency := time.Now().Sub(start).Seconds()
latency := time.Since(start).Seconds()
metrics.MirrorLatency.Observe(latency)
}

Expand Down
4 changes: 2 additions & 2 deletions services/imageio.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (t *ImageIO) Push(ctx context.Context, ns, name string, fpath string) error
metrics.PushFailures.Inc()
return
}
latency := time.Now().Sub(start).Seconds()
latency := time.Since(start).Seconds()
metrics.PushLatency.Observe(latency)
metrics.PushSuccesses.Inc()
}()
Expand Down Expand Up @@ -126,7 +126,7 @@ func (t *ImageIO) Pull(ctx context.Context, ns, name string) (*os.File, func(),
return
}

latency := time.Now().Sub(start).Seconds()
latency := time.Since(start).Seconds()
metrics.PullLatency.Observe(latency)
metrics.PullSuccesses.Inc()
}()
Expand Down

0 comments on commit a0efb02

Please sign in to comment.