diff --git a/.dockerignore b/.dockerignore index dcab0f5a..f9f1e639 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,7 @@ .idea .vscode .github +.test .gitignore .env diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4d2b04a1..170f1a9f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,117 +1,72 @@ -name: "Continuous Integration" +name: "Build and Test" on: - push: - branches: - - '*' - tags: - - '*' + pull_request: paths-ignore: - 'docs/**' - 'deploy/**' + - 'examples/**' - '*.md' - pull_request: - branches: - - '*' jobs: - buildx: + test: + name: "lint and test" runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 + permissions: + checks: write + pull-requests: write - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - - name: Set up Docker buildx - id: buildx - uses: docker/setup-buildx-action@v1 + steps: + - name: checkout + uses: actions/checkout@v3 - - name: Cache Docker layers - uses: actions/cache@v2 - id: cache + - name: setup Go + uses: actions/setup-go@v3 with: - path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.sha }} - restore-keys: | - ${{ runner.os }}-buildx- + go-version: 1.19 - - name: Build, lint and test - 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: lint and test + shell: sh + run: | + make lint + make test-coverage - - name: Build integration tests image - env: - DOCKER_ORG: ${{ secrets.DOCKER_ORG }} - uses: docker/build-push-action@v2 + - name: publish test results + uses: EnricoMi/publish-unit-test-result-action@v2 + if: always() 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 + junit_files: ".cover/tests.xml" - - 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 + uses: codecov/codecov-action@v3 + with: + files: ".cover/coverage.xml" - - 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 + integration: + name: "integration tests" + runs-on: ubuntu-latest - - 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}" + steps: + - name: checkout + uses: actions/checkout@v3 - - name: Login to DockerHub - uses: docker/login-action@v1 + - name: setup buildx + uses: docker/setup-buildx-action@v2 with: - username: ${{ secrets.DOCKER_ACCOUNT }} - password: ${{ secrets.DOCKER_TOKEN }} + driver-opts: network=host - - name: Build and push Docker image - if: github.event_name != 'pull_request' - env: - DOCKER_ORG: ${{ secrets.DOCKER_ORG }} - uses: docker/build-push-action@v2 + - name: build image + uses: docker/build-push-action@v3 with: + build-args: SKIP_TESTS=true file: docker/Dockerfile context: . - platforms: linux/amd64,linux/arm64 - build-args: | - CODECOV_TOKEN=${{ secrets.CODECOV_TOKEN }} - VCS_COMMIT_ID=${{ github.sha }} - VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }} - VCS_SLUG=${{ github.repository }} - SKIP_TESTS=true - cache-from: type=local,src=/tmp/.buildx-cache - cache-to: type=local,dest=/tmp/.buildx-cache - push: true - tags: ${{ secrets.DOCKER_ORG }}/pumba:${{ steps.tagger.outputs.tag }} + tags: pumba:test + target: integration-tests + outputs: type=docker,dest=/tmp/image.tar + + - name: integration tests + run: | + docker load -i /tmp/image.tar + docker run -i --rm --name integration-tests -v /var/run/docker.sock:/var/run/docker.sock pumba:test diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3a541d8c..48cb3046 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -7,25 +7,28 @@ on: # The branches below must be a subset of the branches above branches: [ master ] schedule: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + # │ │ │ │ │ + # * * * * * - cron: '0 17 * * 5' jobs: - analyze: - name: Analyze + CodeQL-Build: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - # Override automatic language detection by changing the below list - # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] - language: [ 'go' ] - # Learn more... - # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection + permissions: + # required for all workflows + security-events: write steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. @@ -38,14 +41,14 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v1 + uses: github/codeql-action/init@v2 with: - languages: ${{ matrix.language }} + languages: go # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v1 + uses: github/codeql-action/autobuild@v2 # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl @@ -59,4 +62,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 + uses: github/codeql-action/analyze@v2 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3d1bc42b..6d74243a 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,49 +1,94 @@ -name: "Release to GitHub" +name: "Release" on: - workflow_dispatch: push: branches: - - 'master' + - master tags: - '[0-9]+.[0-9]+.[0-9]+' paths-ignore: - 'docs/**' - 'deploy/**' + - 'examples/**' + - 'test/**' - '*.md' + - '*.yaml' jobs: - release: + build: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v2 + container: golang:1.19-alpine - - name: Set up Docker buildx - id: buildx - uses: docker/setup-buildx-action@v1 + steps: + - name: checkout + uses: actions/checkout@v3 - - name: Decide on tag - id: tagger + - name: build + shell: sh + env: + GOPROXY: https://proxy.golang.org + CGO_ENABLED: 0 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}" + apk --update add ca-certificates tzdata make git bash + make release + + create-release: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + name: release + needs: [ build ] + runs-on: ubuntu-latest + + steps: + - name: tag + id: get_tag + run: echo ::set-output name=git_tag::${GITHUB_REF/refs\/tags\//} + + - name: changelog + id: build_changelog + uses: mikepenz/release-changelog-builder-action@v3.6.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: release + uses: softprops/action-gh-release@v1 + with: + name: ${{ steps.get_tag.outputs.git_tag }} + tag_name: ${{ steps.get_tag.outputs.git_tag }} + body: ${{steps.build_changelog.outputs.changelog}} + files: | + .bin/* + push: + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + name: push + runs-on: ubuntu-latest + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: get tag + id: get_tag + run: echo ::set-output name=git_tag::${GITHUB_REF/refs\/tags\//} + + - name: setup QEMU + uses: docker/setup-qemu-action@v2 + + - name: setup buildx + uses: docker/setup-buildx-action@v2 + + - name: login to registry + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_ACCOUNT }} + password: ${{ secrets.DOCKER_TOKEN }} - - name: Release to GitHub - if: startsWith(github.ref, 'refs/tags/') - uses: docker/build-push-action@v2 + - name: build and push + uses: docker/build-push-action@v3 with: file: docker/Dockerfile context: . - build-args: | - RELEASE=true - RELEASE_TAG=${{ steps.tagger.outputs.tag }} - RELEASE_TOKEN=${{ secrets.RELEASE_TOKEN }} - TAG_MESSAGE="Draft Release" - GITHUB_TOKEN=${{ secrets.RELEASE_TOKEN }} - VCS_COMMIT_ID=${{ github.sha }} - VCS_BRANCH_NAME=${{ steps.tagger.outputs.tag }} - VCS_SLUG=${{ github.repository }} - target: github-release + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ secrets.DOCKER_ORG }}/pumba:${{ steps.get_tag.outputs.git_tag }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 743c5c15..5a21a995 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ .bin .env .in -/.gtm/ +.test **/.DS_Store **/debug diff --git a/.golangci.yml b/.golangci.yaml similarity index 100% rename from .golangci.yml rename to .golangci.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 1d41be35..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,653 +0,0 @@ -# Changelog - -## [Unreleased](https://github.com/alexei-led/pumba/tree/HEAD) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.9.1...HEAD) - -**Closed issues:** - -- GHSA-77vh-xpmg-72qh: Clarify `mediaType` handling [\#225](https://github.com/alexei-led/pumba/issues/225) -- GHSA-qq97-vm5h-rrhg: OCI Manifest Type Confusion Issue [\#224](https://github.com/alexei-led/pumba/issues/224) - -**Merged pull requests:** - -- Bump github.com/opencontainers/image-spec from 1.0.1 to 1.0.2 [\#229](https://github.com/alexei-led/pumba/pull/229) ([dependabot[bot]](https://github.com/apps/dependabot)) -- Bump github.com/containerd/containerd from 1.5.7 to 1.5.16 [\#228](https://github.com/alexei-led/pumba/pull/228) ([dependabot[bot]](https://github.com/apps/dependabot)) -- Bump github.com/docker/distribution from 2.7.1+incompatible to 2.8.0+incompatible [\#227](https://github.com/alexei-led/pumba/pull/227) ([dependabot[bot]](https://github.com/apps/dependabot)) - -## [0.9.1](https://github.com/alexei-led/pumba/tree/0.9.1) (2023-01-09) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.9.0...0.9.1) - -**Closed issues:** - -- Netem Functionalities not working ? [\#221](https://github.com/alexei-led/pumba/issues/221) -- IO-Stress: bind source path does not exist [\#218](https://github.com/alexei-led/pumba/issues/218) -- command 'tc' failed in /TargetContainer [\#215](https://github.com/alexei-led/pumba/issues/215) -- golangci-lint fails on 0.9.0 [\#213](https://github.com/alexei-led/pumba/issues/213) -- Binary for 0.9.0 [\#212](https://github.com/alexei-led/pumba/issues/212) -- Persistent or "daemon" mode [\#196](https://github.com/alexei-led/pumba/issues/196) - -**Merged pull requests:** - -- update/go-libs [\#226](https://github.com/alexei-led/pumba/pull/226) ([alexei-led](https://github.com/alexei-led)) -- Get the client source docker socket path dynamically [\#219](https://github.com/alexei-led/pumba/pull/219) ([Vr00mm](https://github.com/Vr00mm)) -- Replace deprecated ioutil with other functions [\#214](https://github.com/alexei-led/pumba/pull/214) ([aminvakil](https://github.com/aminvakil)) - -## [0.9.0](https://github.com/alexei-led/pumba/tree/0.9.0) (2021-11-20) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.8.0...0.9.0) - -**Implemented enhancements:** - -- significant code refactoring [\#211](https://github.com/alexei-led/pumba/pull/211) ([alexei-led](https://github.com/alexei-led)) - -**Merged pull requests:** - -- Restart with delay [\#209](https://github.com/alexei-led/pumba/pull/209) ([aodhan-domhnaill](https://github.com/aodhan-domhnaill)) - -## [0.8.0](https://github.com/alexei-led/pumba/tree/0.8.0) (2021-10-21) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.8...0.8.0) - -**Closed issues:** - -- re2 doesn't work for netem plugin [\#206](https://github.com/alexei-led/pumba/issues/206) -- always the argument --pull-image is true [\#203](https://github.com/alexei-led/pumba/issues/203) -- Release binary for darwin arm64 [\#201](https://github.com/alexei-led/pumba/issues/201) -- Missing golint dependency on make [\#198](https://github.com/alexei-led/pumba/issues/198) -- check on the latest release [\#193](https://github.com/alexei-led/pumba/issues/193) -- Unable to generate binaries on Mac [\#192](https://github.com/alexei-led/pumba/issues/192) -- "cgroup change of group failed" issue is seen while using stress-ng [\#189](https://github.com/alexei-led/pumba/issues/189) - -**Merged pull requests:** - -- Container restart [\#208](https://github.com/alexei-led/pumba/pull/208) ([aodhan-domhnaill](https://github.com/aodhan-domhnaill)) -- Container exec [\#207](https://github.com/alexei-led/pumba/pull/207) ([aodhan-domhnaill](https://github.com/aodhan-domhnaill)) -- go 1.17 bump [\#205](https://github.com/alexei-led/pumba/pull/205) ([alexei-led](https://github.com/alexei-led)) -- ci: added support darwin arm64 [\#202](https://github.com/alexei-led/pumba/pull/202) ([karl-cardenas-coding](https://github.com/karl-cardenas-coding)) -- Replace `go get` with `go install` [\#199](https://github.com/alexei-led/pumba/pull/199) ([aminvakil](https://github.com/aminvakil)) - -## [0.7.8](https://github.com/alexei-led/pumba/tree/0.7.8) (2021-04-07) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.7...0.7.8) - -**Closed issues:** - -- Issue with stress command [\#191](https://github.com/alexei-led/pumba/issues/191) -- v0.7.7 tarball sha256 change? [\#190](https://github.com/alexei-led/pumba/issues/190) - -## [0.7.7](https://github.com/alexei-led/pumba/tree/0.7.7) (2020-12-16) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.6...0.7.7) - -**Fixed bugs:** - -- How to run netem on VLAN tagged interfaces? [\#182](https://github.com/alexei-led/pumba/issues/182) - -**Closed issues:** - -- Suggestion for a kill tool [\#187](https://github.com/alexei-led/pumba/issues/187) -- list of container names not working? [\#186](https://github.com/alexei-led/pumba/issues/186) -- Setting Up Pumba on Kind Kubernetes Cluster [\#180](https://github.com/alexei-led/pumba/issues/180) - -**Merged pull requests:** - -- Fix Interface regex \(fixes issue \#182\) [\#184](https://github.com/alexei-led/pumba/pull/184) ([gpsingh-1991](https://github.com/gpsingh-1991)) - -## [0.7.6](https://github.com/alexei-led/pumba/tree/0.7.6) (2020-09-17) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.5...0.7.6) - -**Merged pull requests:** - -- Multi-architectutre Docker [\#178](https://github.com/alexei-led/pumba/pull/178) ([alexei-led](https://github.com/alexei-led)) - -## [0.7.5](https://github.com/alexei-led/pumba/tree/0.7.5) (2020-09-12) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.4...0.7.5) - -**Implemented enhancements:** - -- Pumba Commands for chaos testing [\#89](https://github.com/alexei-led/pumba/issues/89) -- Kubernetes Chaos Test [\#51](https://github.com/alexei-led/pumba/issues/51) - -**Closed issues:** - -- Build instructions are not correct for 0.7.4 [\#170](https://github.com/alexei-led/pumba/issues/170) -- TC not found or failed [\#159](https://github.com/alexei-led/pumba/issues/159) -- NetEm multiple targets ip's leads to fatal execption, unrecognized CIDR [\#158](https://github.com/alexei-led/pumba/issues/158) -- pumba wildcard not working properly [\#133](https://github.com/alexei-led/pumba/issues/133) -- Documentation doubts [\#119](https://github.com/alexei-led/pumba/issues/119) - -**Merged pull requests:** - -- Skip error [\#177](https://github.com/alexei-led/pumba/pull/177) ([alexei-led](https://github.com/alexei-led)) -- Linter fix [\#176](https://github.com/alexei-led/pumba/pull/176) ([alexei-led](https://github.com/alexei-led)) - -## [0.7.4](https://github.com/alexei-led/pumba/tree/0.7.4) (2020-07-20) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.3...0.7.4) - -**Closed issues:** - -- Netem target port filter [\#130](https://github.com/alexei-led/pumba/issues/130) - -**Merged pull requests:** - -- Adding port targeting [\#163](https://github.com/alexei-led/pumba/pull/163) ([chuckkQ](https://github.com/chuckkQ)) - -## [0.7.3](https://github.com/alexei-led/pumba/tree/0.7.3) (2020-07-19) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.2...0.7.3) - -**Implemented enhancements:** - -- Attacking a container's available cpu/ram? [\#114](https://github.com/alexei-led/pumba/issues/114) -- Restrict pumba targets by docker labels [\#86](https://github.com/alexei-led/pumba/issues/86) -- stress Docker host [\#50](https://github.com/alexei-led/pumba/issues/50) - -**Closed issues:** - -- Error running Pumba on OpenShift version 4.3 [\#169](https://github.com/alexei-led/pumba/issues/169) -- Pumba docker container is exiting as soon as container is initiated [\#165](https://github.com/alexei-led/pumba/issues/165) -- unexpected behaviour of --interval flag [\#162](https://github.com/alexei-led/pumba/issues/162) -- Unable to start Pumba docker container on MacOs [\#161](https://github.com/alexei-led/pumba/issues/161) -- Control the packet selection in loss/corruption/duplication commands [\#160](https://github.com/alexei-led/pumba/issues/160) -- Network emulation not working on armv7 containers [\#156](https://github.com/alexei-led/pumba/issues/156) -- Using Pumba with Docker desktop on Windows won't randomly kill a container [\#155](https://github.com/alexei-led/pumba/issues/155) -- How to use Pumba on AWS Fargate Containers [\#154](https://github.com/alexei-led/pumba/issues/154) -- Running stress-ng with K8s on an alpine based image causes errors [\#153](https://github.com/alexei-led/pumba/issues/153) -- Why use a DaemonSet in Kubernetes? [\#150](https://github.com/alexei-led/pumba/issues/150) -- Error when running 'pumba stress' [\#149](https://github.com/alexei-led/pumba/issues/149) -- regression: with --tc-image flag, iproute2 sidecar container is not deleted after the command execution finishes [\#135](https://github.com/alexei-led/pumba/issues/135) -- https://goo.gl/SUKo6T sunset [\#81](https://github.com/alexei-led/pumba/issues/81) -- Is there a Pumba API? [\#75](https://github.com/alexei-led/pumba/issues/75) - -**Merged pull requests:** - -- Update docker engine to allow cleanup [\#167](https://github.com/alexei-led/pumba/pull/167) ([chuckkQ](https://github.com/chuckkQ)) - -## [0.7.2](https://github.com/alexei-led/pumba/tree/0.7.2) (2020-02-26) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.1...0.7.2) - -**Merged pull requests:** - -- Refactor log errors [\#152](https://github.com/alexei-led/pumba/pull/152) ([alexei-led](https://github.com/alexei-led)) - -## [0.7.1](https://github.com/alexei-led/pumba/tree/0.7.1) (2020-02-10) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.7.0...0.7.1) - -**Implemented enhancements:** - -- Anyway to run this on a Raspberry PI [\#146](https://github.com/alexei-led/pumba/issues/146) - -## [0.7.0](https://github.com/alexei-led/pumba/tree/0.7.0) (2020-02-09) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.8...0.7.0) - -**Closed issues:** - -- pumba netem is affecting all containers in host and not responding to kill -9 when running in background [\#147](https://github.com/alexei-led/pumba/issues/147) -- docker client version too new [\#144](https://github.com/alexei-led/pumba/issues/144) - -**Merged pull requests:** - -- stress test target container [\#148](https://github.com/alexei-led/pumba/pull/148) ([alexei-led](https://github.com/alexei-led)) - -## [0.6.8](https://github.com/alexei-led/pumba/tree/0.6.8) (2019-12-21) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.7...0.6.8) - -## [0.6.7](https://github.com/alexei-led/pumba/tree/0.6.7) (2019-12-19) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.5...0.6.7) - -**Closed issues:** - -- Bug: netem command not working on minikube [\#140](https://github.com/alexei-led/pumba/issues/140) -- DaemonSet apiVersion changed with newer Kubernetes version [\#138](https://github.com/alexei-led/pumba/issues/138) - -**Merged pull requests:** - -- Use container labels as additional filter [\#143](https://github.com/alexei-led/pumba/pull/143) ([alexei-led](https://github.com/alexei-led)) -- Add minikube netem hint [\#142](https://github.com/alexei-led/pumba/pull/142) ([LaumiH](https://github.com/LaumiH)) -- Fix daemonset apiVersion and nodeSelector for k8s \>= 1.16.2 [\#139](https://github.com/alexei-led/pumba/pull/139) ([LaumiH](https://github.com/LaumiH)) - -## [0.6.5](https://github.com/alexei-led/pumba/tree/0.6.5) (2019-10-01) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.4...0.6.5) - -**Closed issues:** - -- pull-image can only be true [\#132](https://github.com/alexei-led/pumba/issues/132) -- K8s & netem question [\#128](https://github.com/alexei-led/pumba/issues/128) - -**Merged pull requests:** - -- Use GitHub Actions [\#136](https://github.com/alexei-led/pumba/pull/136) ([alexei-led](https://github.com/alexei-led)) - -## [0.6.4](https://github.com/alexei-led/pumba/tree/0.6.4) (2019-05-02) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.3...0.6.4) - -**Fixed bugs:** - -- Unable to specify target network, only single host IP [\#126](https://github.com/alexei-led/pumba/issues/126) - -**Closed issues:** - -- How to add more containers to kill [\#124](https://github.com/alexei-led/pumba/issues/124) -- Using re2 in pumba command in kubernetes template [\#123](https://github.com/alexei-led/pumba/issues/123) -- Fedora - command 'tc' not found [\#121](https://github.com/alexei-led/pumba/issues/121) -- log-level behaviour [\#120](https://github.com/alexei-led/pumba/issues/120) - -**Merged pull requests:** - -- Add support for specifying target networks \(CIDR notation\) \#126 [\#127](https://github.com/alexei-led/pumba/pull/127) ([gmpify](https://github.com/gmpify)) - -## [0.6.3](https://github.com/alexei-led/pumba/tree/0.6.3) (2019-03-12) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.2...0.6.3) - -**Fixed bugs:** - -- Regex issue with interface name [\#109](https://github.com/alexei-led/pumba/issues/109) - -**Closed issues:** - -- Slack hook certificate error [\#122](https://github.com/alexei-led/pumba/issues/122) - -**Merged pull requests:** - -- Fix spelling error [\#116](https://github.com/alexei-led/pumba/pull/116) ([CatEars](https://github.com/CatEars)) -- Update interface regexp [\#108](https://github.com/alexei-led/pumba/pull/108) ([ddliu](https://github.com/ddliu)) - -## [0.6.2](https://github.com/alexei-led/pumba/tree/0.6.2) (2018-12-12) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.1...0.6.2) - -**Implemented enhancements:** - -- Deployment failed on Kubernetes 1.7 [\#42](https://github.com/alexei-led/pumba/issues/42) - -**Fixed bugs:** - -- Multiple matching container `netem` commands executed in sequentially when triggered with `docker run` [\#112](https://github.com/alexei-led/pumba/issues/112) - -**Closed issues:** - -- Pumba daemonset pods are crashing [\#110](https://github.com/alexei-led/pumba/issues/110) - -**Merged pull requests:** - -- run netem in parallel on multiple containers. fix \#112 [\#113](https://github.com/alexei-led/pumba/pull/113) ([alexei-led](https://github.com/alexei-led)) -- Change command to args and support entrypoint [\#111](https://github.com/alexei-led/pumba/pull/111) ([yaron-idan](https://github.com/yaron-idan)) - -## [0.6.1](https://github.com/alexei-led/pumba/tree/0.6.1) (2018-11-15) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.6.0...0.6.1) - -**Implemented enhancements:** - -- Better killing and respawing options [\#46](https://github.com/alexei-led/pumba/issues/46) -- No such image: gaiadocker/iproute2 [\#40](https://github.com/alexei-led/pumba/issues/40) - -**Fixed bugs:** - -- reuse tc container [\#97](https://github.com/alexei-led/pumba/issues/97) - -**Closed issues:** - -- when using --tc-image flag the sidekick image is not deleted after the command execution finishes [\#106](https://github.com/alexei-led/pumba/issues/106) -- Cannot connect to the Docker daemon [\#105](https://github.com/alexei-led/pumba/issues/105) -- Strange latency spikes on 4.15.0-36 kernel [\#103](https://github.com/alexei-led/pumba/issues/103) - -**Merged pull requests:** - -- Fixing tc image and more [\#107](https://github.com/alexei-led/pumba/pull/107) ([alexei-led](https://github.com/alexei-led)) - -## [0.6.0](https://github.com/alexei-led/pumba/tree/0.6.0) (2018-10-08) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.5.2...0.6.0) - -**Closed issues:** - -- Any Plan about Network Partitioning Simulation? [\#96](https://github.com/alexei-led/pumba/issues/96) -- Add SVG version of Pumba logo [\#94](https://github.com/alexei-led/pumba/issues/94) - -**Merged pull requests:** - -- use SCRATCH image for base image [\#101](https://github.com/alexei-led/pumba/pull/101) ([alexei-led](https://github.com/alexei-led)) -- Better support for CI tool and Codecov [\#100](https://github.com/alexei-led/pumba/pull/100) ([alexei-led](https://github.com/alexei-led)) -- Refactor: Initialize CLI Commands in a separate func. [\#99](https://github.com/alexei-led/pumba/pull/99) ([nawazish-github](https://github.com/nawazish-github)) - -## [0.5.2](https://github.com/alexei-led/pumba/tree/0.5.2) (2018-09-03) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.5.0...0.5.2) - -**Implemented enhancements:** - -- Pumba is not an importable package [\#60](https://github.com/alexei-led/pumba/issues/60) -- Add Start command. [\#59](https://github.com/alexei-led/pumba/issues/59) - -**Fixed bugs:** - -- Got permission denied after using pumba to delay network [\#83](https://github.com/alexei-led/pumba/issues/83) -- docker\_entrypoint.sh changes ownership of parent socket [\#38](https://github.com/alexei-led/pumba/issues/38) - -**Closed issues:** - -- Pumba attack - visualize the execution steps in command terminal [\#91](https://github.com/alexei-led/pumba/issues/91) -- Pumba run time startup issues [\#88](https://github.com/alexei-led/pumba/issues/88) -- cat: can't open 'VERSION': No such file or directory [\#87](https://github.com/alexei-led/pumba/issues/87) -- netem delay loses the first 3 packets [\#72](https://github.com/alexei-led/pumba/issues/72) -- Pumba container exiting without any error [\#70](https://github.com/alexei-led/pumba/issues/70) - -**Merged pull requests:** - -- Add corrupt and duplicate netem commands [\#95](https://github.com/alexei-led/pumba/pull/95) ([philipgloyne](https://github.com/philipgloyne)) - -## [0.5.0](https://github.com/alexei-led/pumba/tree/0.5.0) (2018-05-21) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.8...0.5.0) - -**Closed issues:** - -- Slack hooks fail due to no ca [\#84](https://github.com/alexei-led/pumba/issues/84) - -**Merged pull requests:** - -- Code refactoring [\#85](https://github.com/alexei-led/pumba/pull/85) ([alexei-led](https://github.com/alexei-led)) -- implement 'contains' in a cheaper, simpler way [\#82](https://github.com/alexei-led/pumba/pull/82) ([Dieterbe](https://github.com/Dieterbe)) -- Spring cleanup [\#80](https://github.com/alexei-led/pumba/pull/80) ([alexei-led](https://github.com/alexei-led)) - -## [0.4.8](https://github.com/alexei-led/pumba/tree/0.4.8) (2018-03-12) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.7...0.4.8) - -**Implemented enhancements:** - -- Fix `netem` when destination IP filter is defined [\#52](https://github.com/alexei-led/pumba/issues/52) - -**Fixed bugs:** - -- netem command fails on images where user != root [\#43](https://github.com/alexei-led/pumba/issues/43) - -**Closed issues:** - -- use dumb-init [\#69](https://github.com/alexei-led/pumba/issues/69) -- use su-exec instead of gosu [\#68](https://github.com/alexei-led/pumba/issues/68) -- kubernetes command should be an array and not a string [\#63](https://github.com/alexei-led/pumba/issues/63) -- custom built container kills itself [\#62](https://github.com/alexei-led/pumba/issues/62) -- suggest kubernetes limits and requests [\#61](https://github.com/alexei-led/pumba/issues/61) -- allow targetting multiple specific ip's [\#57](https://github.com/alexei-led/pumba/issues/57) - -**Merged pull requests:** - -- moving git repo to alexei-led [\#78](https://github.com/alexei-led/pumba/pull/78) ([alexei-led](https://github.com/alexei-led)) -- Limit the number of container to kill \#46 [\#77](https://github.com/alexei-led/pumba/pull/77) ([ccronca](https://github.com/ccronca)) -- Add Start command. \#59 [\#76](https://github.com/alexei-led/pumba/pull/76) ([ccronca](https://github.com/ccronca)) -- very minor min corrections [\#74](https://github.com/alexei-led/pumba/pull/74) ([ghost](https://github.com/ghost)) -- use dumb-init and su-exec [\#71](https://github.com/alexei-led/pumba/pull/71) ([grosser](https://github.com/grosser)) -- add requests/limits so container does not be come too greedy [\#67](https://github.com/alexei-led/pumba/pull/67) ([grosser](https://github.com/grosser)) -- avoid self-killing on kubernetes [\#66](https://github.com/alexei-led/pumba/pull/66) ([grosser](https://github.com/grosser)) -- prefer regular nodes by default [\#65](https://github.com/alexei-led/pumba/pull/65) ([grosser](https://github.com/grosser)) -- do not spam extra shell / make killing soft by default [\#64](https://github.com/alexei-led/pumba/pull/64) ([grosser](https://github.com/grosser)) -- support specifying multiple target IP's [\#58](https://github.com/alexei-led/pumba/pull/58) ([Dieterbe](https://github.com/Dieterbe)) -- fix logging of configs [\#56](https://github.com/alexei-led/pumba/pull/56) ([Dieterbe](https://github.com/Dieterbe)) - -## [0.4.7](https://github.com/alexei-led/pumba/tree/0.4.7) (2017-11-14) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.6...0.4.7) - -**Fixed bugs:** - -- Pumba does not seem to work in my environment [\#33](https://github.com/alexei-led/pumba/issues/33) - -**Merged pull requests:** - -- Fixes [\#55](https://github.com/alexei-led/pumba/pull/55) ([Dieterbe](https://github.com/Dieterbe)) -- fix typo's [\#54](https://github.com/alexei-led/pumba/pull/54) ([Dieterbe](https://github.com/Dieterbe)) - -## [0.4.6](https://github.com/alexei-led/pumba/tree/0.4.6) (2017-10-26) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.5...0.4.6) - -**Implemented enhancements:** - -- Pumba interact with all containers inside docker [\#41](https://github.com/alexei-led/pumba/issues/41) - -**Fixed bugs:** - -- Target IP filter blocking all traffic [\#39](https://github.com/alexei-led/pumba/issues/39) - -**Closed issues:** - -- Regex not working [\#47](https://github.com/alexei-led/pumba/issues/47) -- Building Error - "golang:1.8-alpine AS builder" [\#45](https://github.com/alexei-led/pumba/issues/45) - -**Merged pull requests:** - -- Add a Gitter chat badge to README.md [\#49](https://github.com/alexei-led/pumba/pull/49) ([gitter-badger](https://github.com/gitter-badger)) -- Creates a deploy file for OpenShift [\#48](https://github.com/alexei-led/pumba/pull/48) ([lordofthejars](https://github.com/lordofthejars)) - -## [0.4.5](https://github.com/alexei-led/pumba/tree/0.4.5) (2017-09-06) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.4...0.4.5) - -**Fixed bugs:** - -- not work in k8s ver 1.3 [\#19](https://github.com/alexei-led/pumba/issues/19) - -## [0.4.4](https://github.com/alexei-led/pumba/tree/0.4.4) (2017-07-08) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.3...0.4.4) - -## [0.4.3](https://github.com/alexei-led/pumba/tree/0.4.3) (2017-07-07) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.2...0.4.3) - -**Implemented enhancements:** - -- tc command check [\#35](https://github.com/alexei-led/pumba/issues/35) - -**Fixed bugs:** - -- Cannot remove running container [\#31](https://github.com/alexei-led/pumba/issues/31) -- "pumba rm" without "--force" flag is useless [\#30](https://github.com/alexei-led/pumba/issues/30) - -**Closed issues:** - -- Replace `samalba/dockerclient` library [\#14](https://github.com/alexei-led/pumba/issues/14) - -## [0.4.2](https://github.com/alexei-led/pumba/tree/0.4.2) (2017-03-16) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.1...0.4.2) - -**Merged pull requests:** - -- Added basic e2e tests [\#37](https://github.com/alexei-led/pumba/pull/37) ([slnowak](https://github.com/slnowak)) -- Pumba is now able to remove container [\#34](https://github.com/alexei-led/pumba/pull/34) ([slnowak](https://github.com/slnowak)) - -## [0.4.1](https://github.com/alexei-led/pumba/tree/0.4.1) (2017-02-01) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.4.0-2-gdf5e4a3...0.4.1) - -## [0.4.0-2-gdf5e4a3](https://github.com/alexei-led/pumba/tree/0.4.0-2-gdf5e4a3) (2017-01-29) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.3.2...0.4.0-2-gdf5e4a3) - -**Merged pull requests:** - -- Get rid of samalba client [\#32](https://github.com/alexei-led/pumba/pull/32) ([slnowak](https://github.com/slnowak)) - -## [0.3.2](https://github.com/alexei-led/pumba/tree/0.3.2) (2017-01-17) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.3.1...0.3.2) - -## [0.3.1](https://github.com/alexei-led/pumba/tree/0.3.1) (2016-12-13) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.3.0...0.3.1) - -**Implemented enhancements:** - -- Implement `rate` bandwidth limit [\#25](https://github.com/alexei-led/pumba/issues/25) - -**Closed issues:** - -- Debug messages problem [\#28](https://github.com/alexei-led/pumba/issues/28) - -**Merged pull requests:** - -- Implement rate bandwidth limit [\#29](https://github.com/alexei-led/pumba/pull/29) ([meqif](https://github.com/meqif)) - -## [0.3.0](https://github.com/alexei-led/pumba/tree/0.3.0) (2016-11-24) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.9-4257dcf...0.3.0) - -**Closed issues:** - -- Unable to start the pumba container [\#27](https://github.com/alexei-led/pumba/issues/27) - -## [0.2.9-4257dcf](https://github.com/alexei-led/pumba/tree/0.2.9-4257dcf) (2016-10-28) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.9...0.2.9-4257dcf) - -## [0.2.9](https://github.com/alexei-led/pumba/tree/0.2.9) (2016-10-28) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.8...0.2.9) - -## [0.2.8](https://github.com/alexei-led/pumba/tree/0.2.8) (2016-10-28) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.7...0.2.8) - -## [0.2.7](https://github.com/alexei-led/pumba/tree/0.2.7) (2016-10-27) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.6-3-g705f13b...0.2.7) - -## [0.2.6-3-g705f13b](https://github.com/alexei-led/pumba/tree/0.2.6-3-g705f13b) (2016-10-25) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.6...0.2.6-3-g705f13b) - -**Implemented enhancements:** - -- One time run w/o interval [\#20](https://github.com/alexei-led/pumba/issues/20) -- Run first action before interval [\#17](https://github.com/alexei-led/pumba/issues/17) -- Can't rely on the Docker restart policy [\#11](https://github.com/alexei-led/pumba/issues/11) - -**Fixed bugs:** - -- netem: add check for `iptools2` install [\#21](https://github.com/alexei-led/pumba/issues/21) - -**Closed issues:** - -- Chaos state [\#18](https://github.com/alexei-led/pumba/issues/18) - -**Merged pull requests:** - -- Fix typo: dealy -\> delay [\#26](https://github.com/alexei-led/pumba/pull/26) ([kane-c](https://github.com/kane-c)) - -## [0.2.6](https://github.com/alexei-led/pumba/tree/0.2.6) (2016-09-25) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.5...0.2.6) - -## [0.2.5](https://github.com/alexei-led/pumba/tree/0.2.5) (2016-09-08) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.4...0.2.5) - -## [0.2.4](https://github.com/alexei-led/pumba/tree/0.2.4) (2016-08-10) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.3...0.2.4) - -## [0.2.3](https://github.com/alexei-led/pumba/tree/0.2.3) (2016-08-07) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.2...0.2.3) - -## [0.2.2](https://github.com/alexei-led/pumba/tree/0.2.2) (2016-08-06) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.1...0.2.2) - -**Implemented enhancements:** - -- Disconnect container from Docker network [\#13](https://github.com/alexei-led/pumba/issues/13) -- Pause running container [\#12](https://github.com/alexei-led/pumba/issues/12) - -**Closed issues:** - -- Support recovery "validation" scripts [\#5](https://github.com/alexei-led/pumba/issues/5) -- Support additional Docker commands [\#4](https://github.com/alexei-led/pumba/issues/4) - -## [0.2.1](https://github.com/alexei-led/pumba/tree/0.2.1) (2016-07-28) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.2.0...0.2.1) - -## [0.2.0](https://github.com/alexei-led/pumba/tree/0.2.0) (2016-07-27) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.11...0.2.0) - -**Merged pull requests:** - -- Add basic capability to disrupt container network [\#16](https://github.com/alexei-led/pumba/pull/16) ([inbarshani](https://github.com/inbarshani)) - -## [0.1.11](https://github.com/alexei-led/pumba/tree/0.1.11) (2016-07-16) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.10...0.1.11) - -**Closed issues:** - -- Replace Gox [\#10](https://github.com/alexei-led/pumba/issues/10) -- Add a pkg installer for Mac OS X [\#9](https://github.com/alexei-led/pumba/issues/9) -- Collect container "lifecycle" activities from Docker host, Pumba is running on [\#3](https://github.com/alexei-led/pumba/issues/3) - -## [0.1.10](https://github.com/alexei-led/pumba/tree/0.1.10) (2016-06-05) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.9...0.1.10) - -## [0.1.9](https://github.com/alexei-led/pumba/tree/0.1.9) (2016-05-22) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.8...0.1.9) - -## [0.1.8](https://github.com/alexei-led/pumba/tree/0.1.8) (2016-05-22) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.7...0.1.8) - -## [0.1.7](https://github.com/alexei-led/pumba/tree/0.1.7) (2016-05-21) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.6...0.1.7) - -**Closed issues:** - -- Add label to skip Pumba eyes [\#8](https://github.com/alexei-led/pumba/issues/8) -- Post to Slack does not work [\#7](https://github.com/alexei-led/pumba/issues/7) - -## [0.1.6](https://github.com/alexei-led/pumba/tree/0.1.6) (2016-04-25) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.5...0.1.6) - -**Closed issues:** - -- Are you planning to support Kubernetes or OpenSHift ? [\#6](https://github.com/alexei-led/pumba/issues/6) -- Log Pumba "kill" activities with more details about affected containers [\#2](https://github.com/alexei-led/pumba/issues/2) - -## [0.1.5](https://github.com/alexei-led/pumba/tree/0.1.5) (2016-04-13) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.4...0.1.5) - -**Merged pull requests:** - -- Add a Bitdeli Badge to README [\#1](https://github.com/alexei-led/pumba/pull/1) ([bitdeli-chef](https://github.com/bitdeli-chef)) - -## [0.1.4](https://github.com/alexei-led/pumba/tree/0.1.4) (2016-04-08) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/0.1.3...0.1.4) - -## [0.1.3](https://github.com/alexei-led/pumba/tree/0.1.3) (2016-04-04) - -[Full Changelog](https://github.com/alexei-led/pumba/compare/9e876ae5807d4c3d7a859952bd8210b737a1d097...0.1.3) - - - -\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* diff --git a/Makefile b/Makefile index 4b8c2561..60c7ffee 100644 --- a/Makefile +++ b/Makefile @@ -1,29 +1,31 @@ MODULE = $(shell $(GO) list -m) -DATE ?= $(shell date +%FT%T%z) +DATE ?= $(shell date "+%Y-%m-%d %H:%M %Z") VERSION ?= $(shell git describe --tags --always --dirty 2> /dev/null || \ cat $(CURDIR)/VERSION 2> /dev/null || echo v0) -COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null) -BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) +COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null) +BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) PKGS = $(or $(PKG),$(shell $(GO) list ./...)) TESTPKGS = $(shell $(GO) list -f \ '{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' \ $(PKGS)) -LDFLAGS_VERSION = -X main.Version=$(VERSION) -X main.GitCommit=$(COMMIT) -X main.GitBranch=$(BRANCH) -X main.BuildTime=$(DATE) +LINT_CONFIG = $(CURDIR)/.golangci.yaml +LDFLAGS_VERSION = -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.branch=$(BRANCH) -X \"main.buildTime=$(DATE)\" BIN = $(CURDIR)/.bin -GOLANGCI_LINT_CONFIG = $(CURDIR)/.golangci.yml +TARGETOS ?= $(GOOS) +TARGETARCH ?= $(GOARCH) PLATFORMS = darwin linux windows ARCHITECTURES = amd64 arm64 -TARGETOS ?= linux -TARGETARCH ?= amd64 - - -GO = go -DOCKER = docker -GOMOCK = mockery -BATS = bats -GOLANGCI_LINT = golangci-lint +GO = go +DOCKER = docker +MOCK = mockery +BATS = bats +LINT = golangci-lint +GOCOV = gocov +GOCOVXML = gocov-xml +GOUNIT = go-junit-report +GOMOCK = mockery TIMEOUT = 15 V = 0 @@ -40,7 +42,6 @@ all: setup-tools fmt lint test build dependency: ; $(info $(M) downloading dependencies...) @ ## Build program binary $Q $(GO) mod download - .PHONY: build build: dependency | ; $(info $(M) building $(TARGETOS)/$(TARGETARCH) binary...) @ ## Build program binary $Q env GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) $(GO) build \ @@ -61,27 +62,18 @@ release: clean ; $(info $(M) building binaries for multiple os/arch...) @ ## Bui # Tools -setup-tools: setup-golangci-lint setup-gocov setup-gocov-xml setup-go2xunit +setup-tools: setup-lint setup-gocov setup-gocov-xml setup-go-junit-report -setup-golangci-lint: +setup-lint: $(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1 setup-gocov: - $(GO) install github.com/axw/gocov/gocov@latest + $(GO) install github.com/axw/gocov/gocov@v1.1.0 setup-gocov-xml: $(GO) install github.com/AlekSi/gocov-xml@latest -setup-go2xunit: - $(GO) install github.com/tebeka/go2xunit@latest +setup-go-junit-report: + $(GO) install github.com/jstemmer/go-junit-report/v2@latest setup-mockery: - $(GO) get github.com/vektra/mockery/v2/ -setup-ghr: - $(GO) install github.com/tcnksm/ghr@latest - -GOLINT=golint -GOCOV=gocov -GOCOVXML=gocov-xml -GO2XUNIT=go2xunit -GOMOCK=mockery -GHR=ghr + $(GO) get github.com/vektra/mockery/v2@latest # Tests @@ -99,26 +91,23 @@ $(TEST_TARGETS): test check test tests: ; $(info $(M) running $(NAME:%=% )tests...) @ ## Run tests $Q env CGO_ENABLED=1 $(GO) test -timeout $(TIMEOUT)s $(ARGS) $(TESTPKGS) -test-xml: setup-go2xunit; $(info $(M) running xUnit tests...) @ ## Run tests with xUnit output - $Q mkdir -p test - $Q 2>&1 $(GO) test -timeout $(TIMEOUT)s -v $(TESTPKGS) | tee test/tests.output - $(GO2XUNIT) -fail -input test/tests.output -output test/tests.xml - COVERAGE_MODE = atomic +COVERAGE_DIR = $(CURDIR)/.cover COVERAGE_PROFILE = $(COVERAGE_DIR)/profile.out COVERAGE_XML = $(COVERAGE_DIR)/coverage.xml COVERAGE_HTML = $(COVERAGE_DIR)/index.html + .PHONY: test-coverage -test-coverage: COVERAGE_DIR := $(CURDIR)/.cover/coverage.$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") -test-coverage: setup-gocov setup-gocov-xml; $(info $(M) running coverage tests...) @ ## Run coverage tests +test-coverage: setup-go-junit-report setup-gocov setup-gocov-xml; $(info $(M) running coverage tests...) @ ## Run coverage tests $Q mkdir -p $(COVERAGE_DIR) - $Q $(GO) test \ + $Q $(GO) test -v -cover \ -coverpkg=$$($(GO) list -f '{{ join .Deps "\n" }}' $(TESTPKGS) | \ grep '^$(MODULE)/' | grep -v mocks | \ tr '\n' ',' | sed 's/,$$//') \ -covermode=$(COVERAGE_MODE) \ - -coverprofile="$(COVERAGE_PROFILE)" $(TESTPKGS) - $Q $(GO) tool cover -html=$(COVERAGE_PROFILE) -o $(COVERAGE_HTML) + -coverprofile="$(COVERAGE_PROFILE)" $(TESTPKGS) > $(COVERAGE_DIR)/tests.output + $(GOUNIT) -set-exit-code -in $(COVERAGE_DIR)/tests.output -out $(COVERAGE_DIR)/tests.xml + $Q $(GO) tool cover -func="$(COVERAGE_PROFILE)" $Q $(GOCOV) convert $(COVERAGE_PROFILE) | $(GOCOVXML) > $(COVERAGE_XML) # urun integration tests @@ -128,8 +117,8 @@ integration-tests: build ; $(info $(M) running integration tests with bats...) @ $Q PATH=$(BIN)/$(dir $(MODULE)):$(PATH) $(BATS) tests .PHONY: lint -lint: setup-golangci-lint; $(info $(M) running golangci-lint...) @ ## Run golangci-lint - $Q $(GOLANGCI_LINT) run -v -c $(GOLANGCI_LINT_CONFIG) ./... +lint: setup-lint; $(info $(M) running golangci-lint...) @ ## Run golangci-lint + $Q $(LINT) run -v -c $(LINT_CONFIG) ./... .PHONY: fmt fmt: ; $(info $(M) running gofmt...) @ ## Run gofmt on all source files @@ -144,33 +133,6 @@ mocks: setup-mockery; $(info $(M) generating mocks...) @ ## Run mockery $Q $(GOMOCK) --dir $(call source_of,github.com/docker/docker)/client --name ImageAPIClient $Q $(GOMOCK) --dir $(call source_of,github.com/docker/docker)/client --name APIClient -# generate CHANGELOG.md changelog file -.PHONY: changelog -changelog: $(DOCKER) ; $(info $(M) generating changelog...) @ ## Generating CAHNGELOG.md -ifndef GITHUB_TOKEN - $(error GITHUB_TOKEN is undefined) -endif - $Q $(DOCKER) run -it --rm -v $(CURDIR):/usr/local/src/pumba -w /usr/local/src/pumba ferrarimarco/github-changelog-generator --user alexei-led --project pumba --token $(GITHUB_TOKEN) - -# generate github release -.PHONY: github-release -github-release: setup-ghr | release ;$(info $(M) generating github release...) @ ## run ghr tool -ifndef GITHUB_TOKEN - $(error GITHUB_TOKEN is undefined) -endif - $Q $(GHR) \ - -t $(GITHUB_TOKEN) \ - -u alexei-led \ - -r pumba \ - -n "v$(RELEASE_TAG)" \ - -b "$(TAG_MESSAGE)" \ - -prerelease \ - -draft \ - -debug \ - -recreate \ - "$(RELEASE_TAG)" \ - "$(BIN)/$(dir $(MODULE))" - # Misc .PHONY: clean @@ -190,6 +152,7 @@ version: .PHONY: debug debug: @echo $(LDFLAGS_VERSION) + @echo $(BIN)/$(basename $(MODULE)) # helper function: find module path define source_of diff --git a/VERSION b/VERSION index f374f666..965065db 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.9.1 +0.9.3 diff --git a/cmd/main.go b/cmd/main.go index 6a0ab2b6..77917e25 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -27,20 +27,20 @@ var ( ) var ( - // Version that is passed on compile time through -ldflags - Version = "built locally" + // version that is passed on compile time through -ldflags + version = "local" - // GitCommit that is passed on compile time through -ldflags - GitCommit = "none" + // commit that is passed on compile time through -ldflags + commit = "none" - // GitBranch that is passed on compile time through -ldflags - GitBranch = "none" + // branch that is passed on compile time through -ldflags + branch = "none" - // BuildTime that is passed on compile time through -ldflags - BuildTime = "none" + // buildTime that is passed on compile time through -ldflags + buildTime = "none" - // HumanVersion is a human readable app version - HumanVersion = fmt.Sprintf("%s - %.7s (%s) %s", Version, GitCommit, GitBranch, BuildTime) + // versionSingature is a human readable app version + versionSingature = fmt.Sprintf("%s - [%s:%.7s] %s", version, branch, commit, buildTime) ) const ( @@ -67,7 +67,7 @@ func main() { app := cli.NewApp() app.Name = "Pumba" - app.Version = HumanVersion + app.Version = versionSingature app.Compiled = time.Now() app.Authors = []cli.Author{ { diff --git a/codecov.yml b/codecov.yaml similarity index 100% rename from codecov.yml rename to codecov.yaml diff --git a/docker/Dockerfile b/docker/Dockerfile index cae9253e..d304f754 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,3 @@ -# syntax = docker/dockerfile:experimental - # # ----- Go Builder Image ------ # @@ -10,6 +8,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ git \ bash \ + tzdata \ + ca-certificates \ && rm -rf /var/lib/apt/lists/* # @@ -23,7 +23,6 @@ WORKDIR /go/src/pumba # copy Makefile COPY Makefile . -RUN --mount=type=cache,target=/root/.cache/go-build make setup-tools # copy go.mod/sum COPY go.* ./ @@ -33,42 +32,24 @@ RUN --mount=type=cache,target=/root/.cache/go-build make dependency COPY mocks ./mocks COPY cmd ./cmd COPY pkg ./pkg -COPY .golangci.yml . +COPY .golangci.yaml . COPY VERSION . # run lint, test race and calculate coverage ARG SKIP_TESTS RUN --mount=type=cache,target=/root/.cache/go-build if [ -z "$SKIP_TESTS" -o "$SKIP_TESTS" = false ]; then make lint test-race test-coverage; fi -# `VCS_COMMIT_ID=$(git rev-parse --short HEAD 2>/dev/null)` -ARG VCS_COMMIT_ID -ENV VCS_COMMIT_ID ${VCS_COMMIT_ID} -# `VCS_BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)` -ARG VCS_BRANCH_NAME -ENV VCS_BRANCH_NAME ${VCS_BRANCH_NAME} -# VCS_SLUG: owner/repo slug -ARG VCS_SLUG -ENV VCS_SLUG ${VCS_SLUG} - # build pumba binary for TARGETOS/TARGETARCH (default: linux/amd64) # passed by buildkit ARG TARGETOS ARG TARGETARCH RUN --mount=type=cache,target=/root/.cache/go-build TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make build -# upload coverage reports to Codecov.io, if CODECOV_TOKEN set through build-arg -ARG CODECOV_TOKEN -ENV CODECOV_TOKEN ${CODECOV_TOKEN} -ADD https://codecov.io/bash codecov.sh -RUN chmod +x codecov.sh - -# command to upload coverage report to Codecov: need to pass CI_BUILD_ID/URL as environment variables -CMD ["./codecov.sh", "-e", "VCS_COMMIT_ID,VCS_BRANCH_NAME,VCS_SLUG,CI_BUILD_ID,CI_BUILD_URL"] # # ------ Pumba Integration Tests ------ # -FROM bats/bats:1.5.0 as integration-tests +FROM bats/bats:1.8.2 as integration-tests # install required packages RUN apk add --no-cache docker iproute2 @@ -84,45 +65,15 @@ COPY --from=build-and-test /go/src/pumba/.bin/github.com/alexei-led/pumba /usr/l ENTRYPOINT [ "bash", "-c" ] CMD [ "[ -e /var/run/docker.sock ] && bats --print-output-on-failure /tests" ] -# -# ------ Pumba GitHub Release ------ -# -FROM build-and-test as github-release - -# build argument to secify if to create a GitHub release -ARG DEBUG=false -ARG RELEASE=false - -# Release Tag: `RELEASE_TAG=$(git describe --abbrev=0)` -ARG RELEASE_TAG - -# Release Tag Message: `TAG_MESSAGE=$(git tag -l $RELEASE_TAG -n 20 | awk '{$1=""; print}')` -ARG TAG_MESSAGE - -# release to GitHub; pass GITHUB_TOKEN ras build-arg -ARG GITHUB_TOKEN - -# build pumba for all platforms -RUN --mount=type=cache,target=/root/.cache/go-build if $RELEASE; then make release; fi - -# release to GitHub -RUN --mount=type=cache,target=/root/.cache/go-build if $RELEASE; then make github-release; fi - - -# -# ------ get latest CA certificates -# -FROM alpine:3.14 as certs -RUN apk --update add ca-certificates - - # # ------ Pumba release Docker image ------ # FROM scratch -# copy CA certificates -COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt +# copy certificates +COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ +# copy timezone settings +COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo # this is the last command since it's never cached COPY --from=build-and-test /go/src/pumba/.bin/github.com/alexei-led/pumba /pumba diff --git a/hack/github_release.sh b/hack/github_release.sh deleted file mode 100755 index 2aa13135..00000000 --- a/hack/github_release.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/bash -[ -z "$DIST" ] && DIST=.bin -user=${1} -repo=${2} - -if [ -z "$GITHUB_TOKEN" ]; then - echo "Need to set GITHUB_TOKEN environment variable"; exit 1 -fi - -if [ -z "$RELEASE_TAG" ]; then - RELEASE_TAG=$(git describe --tags) - if [ $? -ne 0 ] - then - echo "Failed to setup RELEASE_TAG from 'git describe --tags'" >&2; exit 1 - fi -fi - -# get tag message (max 20 lines) -if [ -z "$TAG_MESSAGE" ]; then - TAG_MESSAGE=$(git tag -l ${RELEASE_TAG} -n 20 | awk '{$1=$2; print}') - if [ $? -ne 0 ] - then - echo "Failed to setup TAG_MESSAGE from 'git tag -l'" >&2; exit 1 - fi -fi - -if [ $DEBUG = true ]; then - echo "release --name \"v${RELEASE_TAG}\" --tag \"${RELEASE_TAG}\" --description \"${TAG_MESSAGE}\"" - exit 0 -fi - -# see https://github.com/aktau/github-release for the tool commands -# edit release details (release is automatically created for annotated tag by GitHub) -github-release release \ - --security-token ${GITHUB_TOKEN} \ - --user ${user} \ - --repo ${repo} \ - --name "v${RELEASE_TAG}" \ - --tag "${RELEASE_TAG}" \ - --description "${TAG_MESSAGE}" \ - --pre-release \ - --draft - -# upload files -( cd "${DIST}" || exit -for f in *; do - github-release upload \ - --security-token ${GITHUB_TOKEN} \ - --user ${user} \ - --repo ${repo} \ - --tag ${RELEASE_TAG} \ - --name $f \ - --file $f -done -) - -if [ $? -ne 0 ] -then - echo "Something went wrong with publishing a new release '${RELEASE_TAG}' to GitHub" >&2; exit 1 -fi