Skip to content

Commit

Permalink
Merge pull request #99 from grafana/98-update-k6lint-to-v0.2.0
Browse files Browse the repository at this point in the history
update k6lint to v0.2.0
  • Loading branch information
szkiba authored Nov 8, 2024
2 parents 6da198b + ceab819 commit da01813
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 9 deletions.
8 changes: 7 additions & 1 deletion cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ import (
"log/slog"
"os"
"path/filepath"
"time"

"github.com/go-git/go-git/v5"
"github.com/grafana/k6lint"
)

// complianceCacheTTL is a TTL for compliance cahhe, 1 week
const complianceCacheTTL = 60 * 60 * 24 * 7

//nolint:forbidigo
func loadCompliance(ctx context.Context, module string, timestamp float64) (*k6lint.Compliance, bool, error) {
base, err := checksDir(ctx)
Expand All @@ -36,7 +40,9 @@ func loadCompliance(ctx context.Context, module string, timestamp float64) (*k6l
return nil, false, err
}

if comp.Timestamp >= timestamp {
age := float64(time.Now().Unix()) - comp.Timestamp

if comp.Timestamp >= timestamp && age <= complianceCacheTTL {
return &comp, true, nil
}

Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/google/go-github/v62 v62.0.0
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/grafana/clireadme v0.1.0
github.com/grafana/k6lint v0.1.0
github.com/grafana/k6lint v0.2.0
github.com/narqo/go-badge v0.0.0-20230821190521-c9a75c019a59
github.com/samber/slog-logrus/v2 v2.5.0
github.com/sirupsen/logrus v1.9.3
Expand Down Expand Up @@ -40,6 +40,7 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/grafana/k6foundry v0.3.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/henvic/httpretty v0.0.6 // indirect
Expand Down Expand Up @@ -70,7 +71,7 @@ require (
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/exp v0.0.0-20221006183845-316c7553db56 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.6.0 // indirect
golang.org/x/sync v0.7.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcej
github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE=
github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8=
Expand Down Expand Up @@ -79,8 +79,10 @@ github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaU
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/grafana/clireadme v0.1.0 h1:KYEYSnYdSzmHf3bufaK6fQZ5j4dzvM/T+G6Ba+qNnAM=
github.com/grafana/clireadme v0.1.0/go.mod h1:Wy4KIG2ZBGMYAYyF9l7qAy+yoJVasqk/txsRgoRI3gc=
github.com/grafana/k6lint v0.1.0 h1:egUuy8Dmc1Wi5eXBnbGC2QkZIt71KTrOnMr/B5bgkzk=
github.com/grafana/k6lint v0.1.0/go.mod h1:/KU+Ws4QIlNN50cxkRHM7h6dIw7c9nXrFvqzQqq29hY=
github.com/grafana/k6foundry v0.3.0 h1:C+6dPbsOv7Uq4hEhBFNuYqmTdE9jQ0VqhXqBDtMkVTE=
github.com/grafana/k6foundry v0.3.0/go.mod h1:/NtBSQQgXup5SVbfInl0Q8zKVx08xgvXIZ0xncqexEs=
github.com/grafana/k6lint v0.2.0 h1:dEClo580VYmni/QHzF8m8svzdkY7XSYsbZovtDKD7Oo=
github.com/grafana/k6lint v0.2.0/go.mod h1:BQKSiLzZSniqZid6dW6/TX83Cm3Jt+n+1fa6VbSTg0A=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
Expand Down Expand Up @@ -199,8 +201,8 @@ golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
Expand Down
35 changes: 35 additions & 0 deletions releases/v0.1.33.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
k6registry `v0.1.33` is here 🎉!

This is an internal maintenance release.
- Update k6lint to v0.2.0
- Compliance check TTL

## k6lint v0.2.0

k6lint v0.2.0 includes two new checkers:

- build checker
- smoke checker

### build checker

The check is successful if the extension can be built with the latest k6 release.

### smoke checker

The check is successful if there is a smoke test script and it runs successfully with the k6 built with the extension.

Obviously, a prerequisite for a successful run is that the build checker runs successfully, otherwise k6 cannot be built with the extension.

The smoke test script file is searched for in the root of the repository and in the `test`,`tests`,`examples` directories. The name of the smoke test script is one of the following:
- `smoke.js`
- `smoke.ts`
- `smoke.test.js`
- `smoke.test.ts`

## Compliance check TTL

The result of the compliance check was previously cached until the source code of the given extension was changed.

The result of the build check depends not only on the source code of the given extension, but also on the latest k6 release. This made it necessary to introduce a TTL (time to live) value in the compliance check cache.

0 comments on commit da01813

Please sign in to comment.