mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-16 17:31:58 +00:00
👕 Fix linter and test workflows (#1241)
* Fix linter and test workflows * Fix * Fix * Fix linter
This commit is contained in:
parent
e7dec3d7a3
commit
7e6d89957a
138
.github/workflows/linter.yml
vendored
Normal file
138
.github/workflows/linter.yml
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
name: Linter
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
golint:
|
||||
name: Golint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.17'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y \
|
||||
libpcap-dev \
|
||||
llvm \
|
||||
libbpf-dev \
|
||||
linux-headers-$(uname -r)
|
||||
./devops/install-capstone.sh
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
|
||||
|
||||
- name: Generate eBPF object files and Go bindings
|
||||
run: make bpf
|
||||
|
||||
- name: Go lint - agent
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: agent
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Go lint - shared
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: shared
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Go lint - tap
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Go lint - CLI
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: cli
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Go lint - tap/api
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/api
|
||||
|
||||
- name: Go lint - tap/extensions/amqp
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/amqp
|
||||
|
||||
- name: Go lint - tap/extensions/http
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/http
|
||||
|
||||
- name: Go lint - tap/extensions/kafka
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/kafka
|
||||
|
||||
- name: Go lint - tap/extensions/redis
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/redis
|
||||
|
||||
- name: Go lint - logger
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
with:
|
||||
version: latest
|
||||
working-directory: logger
|
||||
|
||||
eslint:
|
||||
name: ESLint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: ESLint prerequisites ui
|
||||
run: |
|
||||
sudo npm install -g eslint
|
||||
cd ui
|
||||
npm run prestart
|
||||
npm i
|
||||
|
||||
- name: ESLint ui
|
||||
run: |
|
||||
cd ui
|
||||
npm run eslint
|
||||
|
||||
- name: ESLint prerequisites ui-common
|
||||
run: |
|
||||
sudo npm install -g eslint
|
||||
cd ui-common
|
||||
npm i
|
||||
|
||||
- name: ESLint ui-common
|
||||
run: |
|
||||
cd ui-common
|
||||
npm run eslint
|
190
.github/workflows/static_code_analysis.yml
vendored
190
.github/workflows/static_code_analysis.yml
vendored
@ -1,190 +0,0 @@
|
||||
on: [push, pull_request]
|
||||
|
||||
name: Static code analysis
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
go-lint:
|
||||
name: Go lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: '^1.17'
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y libpcap-dev
|
||||
./devops/install-capstone.sh
|
||||
|
||||
- name: Check Agent modified files
|
||||
id: agent_modified_files
|
||||
run: devops/check_modified_files.sh agent/
|
||||
|
||||
- name: Generate eBPF object files and go bindings
|
||||
id: generate_ebpf
|
||||
run: make bpf
|
||||
|
||||
- name: Go lint - agent
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.agent_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: agent
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Check shared modified files
|
||||
id: shared_modified_files
|
||||
run: devops/check_modified_files.sh shared/
|
||||
|
||||
- name: Go lint - shared
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.shared_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: shared
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Check tap modified files
|
||||
id: tap_modified_files
|
||||
run: devops/check_modified_files.sh tap/
|
||||
|
||||
- name: Go lint - tap
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Check cli modified files
|
||||
id: cli_modified_files
|
||||
run: devops/check_modified_files.sh cli/
|
||||
|
||||
- name: Go lint - CLI
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.cli_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: cli
|
||||
args: --timeout=10m
|
||||
|
||||
- name: Check tap/api modified files
|
||||
id: tap_api_modified_files
|
||||
run: devops/check_modified_files.sh tap/api/
|
||||
|
||||
- name: Go lint - tap/api
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_api_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/api
|
||||
|
||||
- name: Check tap/extensions/amqp modified files
|
||||
id: tap_amqp_modified_files
|
||||
run: devops/check_modified_files.sh tap/extensions/amqp/
|
||||
|
||||
- name: Go lint - tap/extensions/amqp
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_amqp_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/amqp
|
||||
|
||||
- name: Check tap/extensions/http modified files
|
||||
id: tap_http_modified_files
|
||||
run: devops/check_modified_files.sh tap/extensions/http/
|
||||
|
||||
- name: Go lint - tap/extensions/http
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_http_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/http
|
||||
|
||||
- name: Check tap/extensions/kafka modified files
|
||||
id: tap_kafka_modified_files
|
||||
run: devops/check_modified_files.sh tap/extensions/kafka/
|
||||
|
||||
- name: Go lint - tap/extensions/kafka
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_kafka_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/kafka
|
||||
|
||||
- name: Check tap/extensions/redis modified files
|
||||
id: tap_redis_modified_files
|
||||
run: devops/check_modified_files.sh tap/extensions/redis/
|
||||
|
||||
- name: Go lint - tap/extensions/redis
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.tap_redis_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: tap/extensions/redis
|
||||
|
||||
- name: Check logger modified files
|
||||
id: logger_modified_files
|
||||
run: devops/check_modified_files.sh logger/
|
||||
|
||||
- name: Go lint - logger
|
||||
uses: golangci/golangci-lint-action@v2
|
||||
if: steps.logger_modified_files.outputs.matched == 'true'
|
||||
with:
|
||||
version: latest
|
||||
working-directory: logger
|
||||
|
||||
es-lint:
|
||||
name: ES lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: 16
|
||||
|
||||
- name: Check modified UI files
|
||||
id: ui_modified_files
|
||||
run: devops/check_modified_files.sh ui/
|
||||
|
||||
- name: ESLint prerequisites ui
|
||||
if: steps.ui_modified_files.outputs.matched == 'true'
|
||||
run: |
|
||||
sudo npm install -g eslint
|
||||
cd ui
|
||||
npm run prestart
|
||||
npm i
|
||||
|
||||
- name: ESLint ui
|
||||
if: steps.ui_modified_files.outputs.matched == 'true'
|
||||
run: |
|
||||
cd ui
|
||||
npm run eslint
|
||||
|
||||
- name: Check modified ui-common files
|
||||
id: ui_common_modified_files
|
||||
run: devops/check_modified_files.sh ui-common/
|
||||
|
||||
- name: ESLint prerequisites ui-common
|
||||
if: steps.ui_common_modified_files.outputs.matched == 'true'
|
||||
run: |
|
||||
sudo npm install -g eslint
|
||||
cd ui-common
|
||||
npm i
|
||||
|
||||
- name: ESLint ui-common
|
||||
if: steps.ui_common_modified_files.outputs.matched == 'true'
|
||||
run: |
|
||||
cd ui-common
|
||||
npm run eslint
|
56
.github/workflows/test.yml
vendored
56
.github/workflows/test.yml
vendored
@ -1,11 +1,13 @@
|
||||
on: [push, pull_request]
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
name: Test
|
||||
|
||||
concurrency:
|
||||
group: kubeshark-tests-validation-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
run-unit-tests:
|
||||
name: Unit Tests
|
||||
@ -22,46 +24,22 @@ jobs:
|
||||
with:
|
||||
go-version: '^1.17'
|
||||
|
||||
- name: Install libpcap
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install libpcap-dev
|
||||
|
||||
- name: Install Capstone
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y \
|
||||
libpcap-dev \
|
||||
llvm \
|
||||
libbpf-dev \
|
||||
linux-headers-$(uname -r)
|
||||
./devops/install-capstone.sh
|
||||
|
||||
- name: Generate eBPF object files and go bindings
|
||||
id: generate_ebpf
|
||||
- name: Generate eBPF object files and Go bindings
|
||||
run: make bpf
|
||||
|
||||
- name: Check CLI modified files
|
||||
id: cli_modified_files
|
||||
run: devops/check_modified_files.sh cli/
|
||||
|
||||
- name: CLI Test
|
||||
if: github.event_name == 'push' || steps.cli_modified_files.outputs.matched == 'true'
|
||||
run: make test-cli
|
||||
|
||||
- name: Check Agent modified files
|
||||
id: agent_modified_files
|
||||
run: devops/check_modified_files.sh agent/
|
||||
|
||||
- name: Agent Test
|
||||
if: github.event_name == 'push' || steps.agent_modified_files.outputs.matched == 'true'
|
||||
run: make test-agent
|
||||
|
||||
- name: Shared Test
|
||||
run: make test-shared
|
||||
|
||||
- name: Check extensions modified files
|
||||
id: ext_modified_files
|
||||
run: devops/check_modified_files.sh tap/extensions/ tap/api/
|
||||
|
||||
- name: Extensions Test
|
||||
if: github.event_name == 'push' || steps.ext_modified_files.outputs.matched == 'true'
|
||||
run: make test-extensions
|
||||
- name: Test
|
||||
run: make test
|
||||
|
||||
- name: Upload coverage to Codecov
|
||||
uses: codecov/codecov-action@v2
|
||||
|
18
Makefile
18
Makefile
@ -22,11 +22,12 @@ BUCKET_PATH=static.up9.io/kubeshark/$(GIT_BRANCH)
|
||||
export VER?=0.0
|
||||
ARCH=$(shell uname -m)
|
||||
ifeq ($(ARCH),$(filter $(ARCH),aarch64 arm64))
|
||||
BPF_O_ARCH_LABEL=arm64
|
||||
BPF_TARGET=arm64
|
||||
BPF_ARCH_SUFFIX=arm64
|
||||
else
|
||||
BPF_O_ARCH_LABEL=x86
|
||||
BPF_TARGET=amd64
|
||||
BPF_ARCH_SUFFIX=x86
|
||||
endif
|
||||
BPF_O_FILES = tap/tlstapper/tlstapper46_bpfel_$(BPF_O_ARCH_LABEL).o tap/tlstapper/tlstapper_bpfel_$(BPF_O_ARCH_LABEL).o
|
||||
|
||||
ui: ## Build UI.
|
||||
@(cd ui; npm i ; npm run build; )
|
||||
@ -43,11 +44,8 @@ agent: bpf ## Build agent.
|
||||
@(cd agent; go build -o build/kubesharkagent main.go)
|
||||
@ls -l agent/build
|
||||
|
||||
bpf: $(BPF_O_FILES)
|
||||
|
||||
$(BPF_O_FILES): $(wildcard tap/tlstapper/bpf/**/*.[ch])
|
||||
@(echo "building tlstapper bpf")
|
||||
@(./tap/tlstapper/bpf-builder/build.sh)
|
||||
bpf:
|
||||
BPF_TARGET="$(BPF_TARGET)" BPF_CFLAGS="-O2 -g -D__TARGET_ARCH_$(BPF_ARCH_SUFFIX)" go generate tap/tlstapper/tls_tapper.go
|
||||
|
||||
agent-debug: ## Build agent for debug.
|
||||
@(echo "building kubeshark agent for debug.." )
|
||||
@ -92,7 +90,7 @@ clean-docker: ## Run clean docker
|
||||
clean-bpf:
|
||||
@(rm $(BPF_O_FILES) ; echo "bpf cleanup done" )
|
||||
|
||||
test-lint: ## Run lint on all modules
|
||||
lint: ## Run lint on all modules
|
||||
cd agent && golangci-lint run
|
||||
cd shared && golangci-lint run
|
||||
cd tap && golangci-lint run
|
||||
@ -101,6 +99,8 @@ test-lint: ## Run lint on all modules
|
||||
cd tap/dbgctl && golangci-lint run
|
||||
cd tap/extensions/ && for D in */; do cd $$D && golangci-lint run && cd ..; done
|
||||
|
||||
test: test-cli test-agent test-shared test-extensions
|
||||
|
||||
test-cli: ## Run cli tests
|
||||
@echo "running cli tests"; cd cli && $(MAKE) test
|
||||
|
||||
|
11
build-bpf.sh
Executable file
11
build-bpf.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
BPF_TARGET=amd64
|
||||
BPF_CFLAGS="-O2 -g -D__TARGET_ARCH_x86"
|
||||
ARCH=$(uname -m)
|
||||
if [[ $ARCH == "aarch64" || $ARCH == "arm64" ]]; then
|
||||
BPF_TARGET=arm64
|
||||
BPF_CFLAGS="-O2 -g -D__TARGET_ARCH_arm64"
|
||||
fi
|
||||
|
||||
BPF_TARGET=\"$BPF_TARGET\" BPF_CFLAGS=\"$BPF_CFLAGS\" go generate tap/tlstapper/tls_tapper.go
|
@ -1,45 +0,0 @@
|
||||
#!/bin/bash
|
||||
paths_arr=( "$@" )
|
||||
|
||||
printf "\n========== List modified files ==========\n"
|
||||
echo "$(git diff --name-only HEAD^ HEAD)"
|
||||
|
||||
printf "\n========== List paths to match and check existence ==========\n"
|
||||
for path in ${paths_arr[*]}
|
||||
do
|
||||
if [ -f "$path" ] || [ -d "$path" ]; then
|
||||
echo "$path - found"
|
||||
else
|
||||
echo "$path - does not found - exiting with failure"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
printf "\n========== Check paths of modified files ==========\n"
|
||||
git diff --name-only HEAD^ HEAD > files.txt
|
||||
matched=false
|
||||
while IFS= read -r file
|
||||
do
|
||||
for path in ${paths_arr[*]}
|
||||
do
|
||||
if [[ $file == $path* ]]; then
|
||||
echo "$file - match path: $path"
|
||||
matched=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [[ $matched == true ]]; then
|
||||
break
|
||||
else
|
||||
echo "$file - does not match any given path"
|
||||
fi
|
||||
done < files.txt
|
||||
|
||||
printf "\n========== Result ==========\n"
|
||||
if [[ $matched = true ]]; then
|
||||
echo "match found"
|
||||
echo "::set-output name=matched::true"
|
||||
else
|
||||
echo "no match found"
|
||||
echo "::set-output name=matched::false"
|
||||
fi
|
Loading…
Reference in New Issue
Block a user