Skip to content

Commit

Permalink
refactor: use k6pack library
Browse files Browse the repository at this point in the history
  • Loading branch information
szkiba committed Mar 30, 2024
1 parent db64f9c commit bd043cc
Show file tree
Hide file tree
Showing 21 changed files with 356 additions and 509 deletions.
38 changes: 3 additions & 35 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,5 @@
# MIT License
#
# Copyright (c) 2023 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: Build
on:
pull_request:
workflow_dispatch:
push:
branches:
- feature/*
on: [pull_request]

jobs:
build:
Expand All @@ -35,17 +8,12 @@ jobs:

steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Lint Go Code
# uses: golangci/golangci-lint-action@v3
# with:
# version: v1.50.1

- name: Build
id: build
uses: szkiba/xk6bundler@v0
with:
with: github.com/szkiba/xk6-enhanced=/github/workspace
with: github.com/szkiba/xk6-ts=/github/workspace
32 changes: 32 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
pull_request:
workflow_dispatch:
push:
paths-ignore:
- "docs/**"
- README.md
- "releases/**"

permissions:
contents: read

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: "1.21"
cache: false
- name: Go linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.55
args: --timeout=30m
install-mode: binary
39 changes: 6 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
# MIT License
#
# Copyright (c) 2023 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: Release
on:
push:
Expand All @@ -38,37 +16,32 @@ jobs:
IMAGE_NAME: ${{ github.repository }}

steps:
- name: Check out code
uses: actions/checkout@v3
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

# - name: Lint Go Code
# uses: golangci/golangci-lint-action@v3
# with:
# version: v1.50.1

- name: Build
id: build
uses: szkiba/xk6bundler@v0
with:
with: github.com/szkiba/xk6-enhanced=/github/workspace
with: github.com/szkiba/xk6-ts=/github/workspace

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/*.tar.gz

- name: Log in to the Container registry
uses: docker/login-action@v2
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
Expand All @@ -77,7 +50,7 @@ jobs:
type=semver,pattern={{major}}
- name: Build and push Docker image
uses: docker/build-push-action@v4
uses: docker/build-push-action@v5
with:
push: true
context: ./${{ steps.build.outputs.dockerdir }}
Expand Down
16 changes: 3 additions & 13 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# custom binary
k6
/k6
/k6.exe
/build

# taskfile.io
.task

# Editor directories and files
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
171 changes: 126 additions & 45 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,135 @@
# MIT License
#
# Copyright (c) 2023 Iván Szkiba
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# v1.55.2
# Please don't remove the first line. It uses in CI to determine the golangci version
run:
deadline: 5m

issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

# We want to try and improve the comments in the k6 codebase, so individual
# non-golint items from the default exclusion list will gradually be added
# to the exclude-rules below
exclude-use-default: false

exclude-rules:
# Exclude duplicate code and function length and complexity checking in test
# files (due to common repeats and long functions in test code)
- path: _(test|gen)\.go
linters:
- cyclop
- dupl
- gocognit
- funlen
- lll
- path: js\/modules\/k6\/http\/.*_test\.go
linters:
# k6/http module's tests are quite complex because they often have several nested levels.
# The module is in maintainance mode, so we don't intend to port the tests to a parallel version.
- paralleltest
- tparallel
- linters:
- staticcheck # Tracked in https://github.com/grafana/xk6-grpc/issues/14
text: "The entire proto file grpc/reflection/v1alpha/reflection.proto is marked as deprecated."
- linters:
- forbidigo
text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden'

linters-settings:
nolintlint:
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: false
exhaustive:
default-signifies-exhaustive: true
govet:
check-shadowing: true
cyclop:
max-complexity: 25
maligned:
suggest-new: true
dupl:
threshold: 150
goconst:
min-len: 10
min-occurrences: 4
funlen:
lines: 80
statements: 60
forbidigo:
forbid:
- '^(fmt\\.Print(|f|ln)|print|println)$'
# Forbid everything in os, except os.Signal and os.SyscalError
- '^os\.(.*)$(# Using anything except Signal and SyscallError from the os package is forbidden )?'
# Forbid everything in syscall except the uppercase constants
- '^syscall\.[^A-Z_]+$(# Using anything except constants from the syscall package is forbidden )?'
- '^logrus\.Logger$'

linters:
presets:
- bugs
- style
- unused
- complexity
- format
- performance
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- cyclop
- dogsled
- dupl
- durationcheck
- errcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
disable:
- nolintlint
- forbidigo
- forcetypeassert
- funlen
- gocheckcompilerdirectives
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- gocritic
- gofmt
- gofumpt
- goimports
- gomoddirectives
- goprintffuncname
- gosec
- gosimple
- govet
- importas
- ineffassign
- interfacebloat
- lll
- maligned
- interfacer
- scopelint
- wrapcheck
- depguard
# deprecated
- deadcode
- nosnakecase
- exhaustivestruct
- ifshort
- structcheck
- varcheck
- golint
# generics
- makezero
- misspell
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- paralleltest
- prealloc
- predeclared
- promlinter
- revive
- reassign
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- tenv
- tparallel
- typecheck
- unconvert
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
fast: false
Loading

0 comments on commit bd043cc

Please sign in to comment.