Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

significant code refactoring #211

Merged
merged 40 commits into from
Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
ff04514
fix errorlint errors
alexei-led Nov 11, 2021
3555699
fix style
alexei-led Nov 11, 2021
d801a2a
fix goctitic errors
alexei-led Nov 11, 2021
17fdf80
update dependency
alexei-led Nov 11, 2021
8549c3b
fix Docker API mockgen, tests
alexei-led Nov 13, 2021
86beb89
remove obsolete nolint comment; use config
alexei-led Nov 13, 2021
fce3bcc
skip couple gosec warnings
alexei-led Nov 13, 2021
aa032f3
fix gosimple violations
alexei-led Nov 13, 2021
77eec42
fix prealloc linter
alexei-led Nov 13, 2021
b844dce
fix whitespace linter
alexei-led Nov 13, 2021
1bd0000
fix multiple wrapcheck linter errors
alexei-led Nov 13, 2021
f63b3c5
refactor code to less duplicate
alexei-led Nov 14, 2021
dd3e447
refactor code to less duplicate
alexei-led Nov 17, 2021
192935d
embed base netemCommand
alexei-led Nov 17, 2021
fd3a7af
fix wrapcheck linter
alexei-led Nov 18, 2021
9cfb8af
replace duration string flag with time.Duration
alexei-led Nov 18, 2021
0d4078f
remove from public
alexei-led Nov 18, 2021
8b8dd4f
fix wrapcheck linter all
alexei-led Nov 18, 2021
06bf719
fix remaining linter errors
alexei-led Nov 18, 2021
aedbf79
skip dupl false-positive
alexei-led Nov 18, 2021
2579ece
increase dupl threshold to 150
alexei-led Nov 18, 2021
4792a77
fix integration test
alexei-led Nov 18, 2021
c29e135
add restart integration test; fix restart implementation
alexei-led Nov 18, 2021
6a64b4e
add stress integration test; use duration CLI flag
alexei-led Nov 18, 2021
e649935
add stress integration test
alexei-led Nov 18, 2021
690e0e8
update stop integration
alexei-led Nov 18, 2021
6ab4416
fix alpine package name for bats-core
alexei-led Nov 18, 2021
fb4dc12
update stress integration
alexei-led Nov 18, 2021
56c9d18
update stress integration
alexei-led Nov 18, 2021
cf1599a
remove unsupported bats flag on alpine
alexei-led Nov 18, 2021
dfc8c5c
test build
alexei-led Nov 18, 2021
d439f3c
update gh actions
alexei-led Nov 18, 2021
ecf6891
load test images to docker engine for run
alexei-led Nov 18, 2021
8b7c443
fix docker image tag for local test
alexei-led Nov 18, 2021
a34fd0e
use latest bats
alexei-led Nov 18, 2021
91034a0
do not install bats and bash
alexei-led Nov 18, 2021
2b3e44c
bats command
alexei-led Nov 18, 2021
51ceb8a
debug bats failure
alexei-led Nov 18, 2021
a2da48c
debug stress test; pring log
alexei-led Nov 18, 2021
9a13db7
skip stress test for CI; cannot change cgroup and fail test
alexei-led Nov 18, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 107 additions & 98 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,110 +3,119 @@ name: Pumba CI
on:
push:
branches:
- '*'
- '*'
tags:
- '*'
- '*'
paths-ignore:
- 'docs/**'
- 'deploy/**'
- '*.md'
- 'docs/**'
- 'deploy/**'
- '*.md'
pull_request:
branches:
- '*'
- '*'

jobs:

full:
build:

runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[skip ci]')"


steps:
- uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: list available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: decide on tag
id: tagger
run: |
tag=$(echo "${{ github.ref }}" | sed -e 's/^refs\/heads\///g' -e 's/^refs\/tags\///g' -e 's/^refs\/pull\///g' -e 's/\/merge$//g' | sed -e 's/master/latest/g')
echo "::set-output name=tag::${tag}"
echo "::debug::docker image tag ${tag}"

- name: prepare build arguments
id: prepare
run: |
args=$(echo "--progress=plain --build-arg=CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} --build-arg=VCS_COMMIT_ID=${{ github.sha }} --build-arg=VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }} --build-arg=VCS_SLUG=${{ github.repository }} --file=docker/Dockerfile .")
echo "::debug::prepare build args ${args}"
echo "::set-output name=args::${args}"

- name: cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: build test images
run: |
echo "==> compile and test Go code"
DOCKER_BUILDKIT=1 docker build --tag=pumba/build-and-test \
--target=build-and-test \
${{ steps.prepare.outputs.args }}
echo "==> prepare integration tests image"
DOCKER_BUILDKIT=1 docker build --tag pumba/integration-tests \
--target=integration-tests \
${{ steps.prepare.outputs.args }}

- name: run integration tests
run: |
docker buildx ls
docker run -i --rm --name integration-tests -v /var/run/docker.sock:/var/run/docker.sock pumba/integration-tests

- name: upload coverage report
run: |
CI_BUILD_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks
docker run -i --rm --name upload-coverage -e CI_BUILD_URL=${CI_BUILD_URL} -e CI_BUILD_ID=${RUNNER_TRACKING_ID} pumba/build-and-test

- name: login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_ACCOUNT }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: prepare release image
if: github.event_name != 'pull_request'
env:
DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
run: |
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \
--cache-from "type=local,src=/tmp/.buildx-cache" \
--cache-to "type=local,dest=/tmp/.buildx-cache" \
--output "type=image,push=true" \
--tag=${DOCKER_ORG}/pumba:${{ steps.tagger.outputs.tag }} \
${{ steps.prepare.outputs.args }}

- name: release to GitHub
if: github.event_name != 'pull_request'
run: |
if [[ "${{ steps.tagger.outputs.tag }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then \
DOCKER_BUILDKIT=1 docker build \
--tag pumba/github-release \
--target=github-release \
--build-arg=RELEASE=true \
--build-arg=RELEASE_TAG=${{ steps.tagger.outputs.tag }} \
--build-arg=TAG_MESSAGE="Draft Release" \
--build-arg=GITHUB_TOKEN=${{ secrets.RELEASE_TOKEN }} \
${{ steps.prepare.outputs.args }}; \
fi
- name: Checkout code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: List available platforms
run: echo ${{ steps.buildx.outputs.platforms }}

- name: Decide on tag
id: tagger
run: |
tag=$(echo "${{ github.ref }}" | sed -e 's/^refs\/heads\///g' -e 's/^refs\/tags\///g' -e 's/^refs\/pull\///g' -e 's/\/merge$//g' | sed -e 's/master/latest/g')
echo "::set-output name=tag::${tag}"
echo "::debug::docker image tag ${tag}"

- name: Cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Build test image
env:
DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile
context: .
build-args: |
CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
VCS_COMMIT_ID=${{ github.sha }}
VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }}
VCS_SLUG=${{ github.repository }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
load: true
tags: pumba/build-and-test
target: build-and-test

- name: Build integration test image
env:
DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile
context: .
build-args: |
CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
VCS_COMMIT_ID=${{ github.sha }}
VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }}
VCS_SLUG=${{ github.repository }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
load: true
tags: pumba/integration-tests
target: integration-tests

- name: Run integration tests
run: |
docker run -i --rm --name integration-tests -v /var/run/docker.sock:/var/run/docker.sock pumba/integration-tests

- name: Upload coverage report
run: |
CI_BUILD_URL=https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks
docker run -i --rm --name upload-coverage -e CI_BUILD_URL=${CI_BUILD_URL} -e CI_BUILD_ID=${RUNNER_TRACKING_ID} pumba/build-and-test

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_ACCOUNT }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push release image
if: github.event_name != 'pull_request'
env:
DOCKER_ORG: ${{ secrets.DOCKER_ORG }}
uses: docker/build-push-action@v2
with:
file: docker/Dockerfile
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
build-args: |
CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
VCS_COMMIT_ID=${{ github.sha }}
VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }}
VCS_SLUG=${{ github.repository }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
push: true
tags: ${DOCKER_ORG}/pumba:${{ steps.tagger.outputs.tag }}
64 changes: 64 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: release

on:
workflow_dispatch:
push:
branches:
- 'master'
tags:
- '[0-9]+.[0-9]+.[0-9]+'
paths-ignore:
- 'docs/**'
- 'deploy/**'
- '*.md'

jobs:

release:

runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Decide on tag
id: tagger
run: |
tag=$(echo "${{ github.ref }}" | sed -e 's/^refs\/heads\///g' -e 's/^refs\/tags\///g' -e 's/^refs\/pull\///g' -e 's/\/merge$//g' | sed -e 's/master/latest/g')
echo "::set-output name=tag::${tag}"
echo "::debug::docker image tag ${tag}"

- name: Cache Docker layers
uses: actions/cache@v2
id: cache
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Release to GitHub
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v2
with:
build-args: |
RELEASE=true
RELEASE_TAG=${{ steps.tagger.outputs.tag }}
RELEASE_TOKEN=${{ secrets.RELEASE_TOKEN }}
TAG_MESSAGE="Draft Release"
GITHUB_TOKEN=${{ secrets.RELEASE_TOKEN }}
CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }}
VCS_COMMIT_ID=${{ github.sha }}
VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }}
VCS_SLUG=${{ github.repository }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
target: github-release
63 changes: 46 additions & 17 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
gocyclo:
min-complexity: 15
maligned:
suggest-new: true
dupl:
threshold: 100
threshold: 150
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -32,36 +30,58 @@ linters-settings:
- whyNoLint
- wrapperFunc
funlen:
lines: 100
lines: 105
statements: 50

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- rowserrcheck
- asciicheck
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exhaustive
- exportloopref
- funlen
- gci
# - gochecknoglobals TODO: remove globals from code
# - gochecknoinits TODO: remove main.init
- gocognit
- goconst
- gocritic
- gocyclo
# - godox
- goerr113
- gofmt
- goimports
- golint
- gomnd
- gomoddirectives
- gosec
- gosimple
- govet
- goprintffuncname
- ifshort
- importas
- ineffassign
- interfacer
- makezero
- misspell
- nakedret
- scopelint
# - nestif
- nilerr
- nolintlint
- prealloc
- predeclared
- promlinter
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
Expand All @@ -70,15 +90,24 @@ linters:
- unparam
- unused
- varcheck
- wastedassign
- whitespace

# don't enable:
# - gochecknoglobals
# - gocognit
# - godox
# - maligned
# - prealloc
- wrapcheck
# - wsl

issues:
exclude:
- Using the variable on range scope `tt` in function literal
exclude-rules:
- path: _test\.go
linters:
- funlen
- bodyclose
- gosec
- dupl
- gocognit
- goconst
- goerr113
- path: mocks\*\.go
linters:
- wrapcheck
exclude:
- Using the variable on range scope `tt` in function literal
Loading