Skip to content

Commit

Permalink
GHA/CI
Browse files Browse the repository at this point in the history
  • Loading branch information
okashansky-mdsol committed Jul 9, 2024
1 parent 1bf9c5f commit 348d823
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 13 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build_artifact.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build Artifact

on:
workflow_dispatch:
push:
tags:
- v*

permissions:
contents: read

jobs:
build:
runs-on: [ ubuntu-latest ]

concurrency:
# Cancel intermediate builds
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env: {}

steps:
- name: CI
uses: ./github/workflows/ci.yaml

- name: Build
run: make clean lint prepare build pack ß

- name: Environment
run: |
echo "GOARCH=$(go env GOARCH)" >> $GITHUB_ENV
echo "GOOS=$(go env GOOS)" >> $GITHUB_ENV
echo "BRANCH=$(echo ${{ github.ref_name }} | tr -C '[a-z0-9-\n]' '_')" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: k6-${{env.GOARCH}}-${{env.GOOS}}-${{ env.BRANCH }}.tar.gz
path: ./bin/*.tar.gz
if-no-files-found: warn
overwrite: true
retention-days: 3 # we need it just for releases
compression-level: 0 # this is already a gzipped archive
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI

on:
push:
paths:
- .github/workflows/ci.yml
- pkg/**
- go.mod
- go.sum
- Makefile
- register.go

permissions:
contents: read

jobs:
verify:
runs-on: [ ubuntu-latest ]

concurrency:
# Cancel intermediate builds
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env: {}

steps:
- uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.58.2
args: --verbose --concurrency=2 --timeout=600s

- name: Test with the Go CLI
run: go test -v ./...
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
MAKEFLAGS += --silent
GOLANGCI_CONFIG ?= .golangci.yml
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

clean:
rm -f ./bin/k6
echo Remove old binary if it exists...
rm -f ./bin/*

build:
echo Build...
xk6 build --output ./bin/k6 --with github.com/mdsol/xk6-output-otlp=.

pack:
echo Packing...
cd ./bin/; \
tar -czvf k6-$(GOARCH)-$(GOOS).tar.gz ./k6; \
rm ./k6

format:
echo Format...
go fmt ./...

.PHONY: build clean format
prepare:
echo Installing XK6...
go install go.k6.io/xk6/cmd/xk6@latest

lint:
echo Linter...
golangci-lint run

.PHONY: prepare build clean format lint pack
8 changes: 3 additions & 5 deletions pkg/extension/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ import (
)

const (
defaultServerURL = "http://localhost:8080/v1/metrics"
defaultTimeout = 5 * time.Second
defaultPushInterval = 5 * time.Second
defaultRateConversion = "counters"
defaultTrendConversion = "gauges"
defaultServerURL = "http://localhost:8080/v1/metrics"
defaultTimeout = 5 * time.Second
defaultPushInterval = 5 * time.Second
)

type Config struct {
Expand Down
8 changes: 3 additions & 5 deletions pkg/otlp/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ var (
)

type wrapParams struct {
ctx context.Context
script string
trendConversion string
rateConversion string
log logrus.FieldLogger
ctx context.Context
script string
log logrus.FieldLogger
}

func Init(conf *Config, expc *exp.Config, log logrus.FieldLogger) error {
Expand Down

0 comments on commit 348d823

Please sign in to comment.