diff --git a/.circleci/config.yml b/.circleci/config.yml index b58ed371bbe..7f52dff6132 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2 jobs: - build: + lint: docker: - image: circleci/golang:latest environment: @@ -8,14 +8,13 @@ jobs: working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6 steps: - checkout - - setup_remote_docker: - version: 17.07.0-ce - run: - name: setup repo and docker + name: Check dependencies command: | - git submodule update --init - docker info - echo "{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_AUTH\",\"email\":\"$DOCKER_EMAIL\"}}" >~/.dockercfg + export PATH=$GOPATH/bin:$PATH + go get -u github.com/golang/dep/cmd/dep + dep status + dep ensure -update -dry-run - run: name: Run linter command: | @@ -24,13 +23,15 @@ jobs: go get -u github.com/alecthomas/gometalinter gometalinter --install gometalinter --deadline 10m --config gometalinter.json --vendor ./... - - run: - name: Check dependencies - command: | - export PATH=$GOPATH/bin:$PATH - go get -u github.com/golang/dep/cmd/dep - dep status - dep ensure -update -dry-run + + test: + docker: + - image: circleci/golang:latest + environment: + GOPATH: /home/circleci/.go_workspace + working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6 + steps: + - checkout - run: name: Run tests and code coverage command: | @@ -42,6 +43,23 @@ jobs: grep -h -v "^mode:" *.coverage >> coverage.txt rm -f *.coverage bash <(curl -s https://codecov.io/bash) + + build-docker-images: + docker: + - image: circleci/golang:latest + environment: + GOPATH: /home/circleci/.go_workspace + working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6 + steps: + - checkout + - setup_remote_docker: + version: 17.11.0-ce + - run: + name: Setup repo and docker + command: | + git submodule update --init + docker info + echo "{\"https://index.docker.io/v1/\":{\"auth\":\"$DOCKER_AUTH\",\"email\":\"$DOCKER_EMAIL\"}}" >~/.dockercfg - run: name: Build application Docker image command: | @@ -70,3 +88,71 @@ jobs: docker tag loadimpact/k6 loadimpact/k6:${CIRCLE_TAG:1} docker push loadimpact/k6:${CIRCLE_TAG:1} fi + + build-linux-packages: + docker: + - image: circleci/golang:latest + environment: + GOPATH: /home/circleci/.go_workspace + working_directory: /home/circleci/.go_workspace/src/github.com/loadimpact/k6 + steps: + - checkout + - run: + name: Build linux packages + command: | + export PATH=$GOPATH/bin:$PATH + + go get github.com/Masterminds/glide + go get github.com/mh-cbon/go-bin-deb \ + && cd $GOPATH/src/github.com/mh-cbon/go-bin-deb \ + && glide install \ + && go install + + go get github.com/mh-cbon/go-bin-rpm \ + && cd $GOPATHsrc/github.com/mh-cbon/go-bin-rpm \ + && glide install \ + && go install + + sudo apt-get update -y + sudo apt-get install -y fakeroot rpm + + cd $GOPATH/src/github.com/loadimpact/k6 + + echo "Building k6..." + CGO_ENABLED=0 GOARCH=$ARCH go build -a -ldflags '-s -w' -o /tmp/k6 + echo "Done!" + + VERSION=${CIRCLE_TAG:1} ./packaging/gen-packages.sh + + - deploy: + name: Publish packages in Bintray + command: | + # Publishing deb + curl -H "X-GPG-PASSPHRASE: $GPG_PASSPHRASE" -T dist/k6-v$VERSION-amd64.deb "https://$BINTRAY_USER:$BINTRAY_KEY@api.bintray.com/content/loadimpact/deb/k6/$VERSION/k6-v$VERSION-amd64.deb;deb_distribution=stable;deb_component=main;deb_architecture=amd64;publish=1;override=1" + # Publishing rpm + curl -H "X-GPG-PASSPHRASE: $GPG_PASSPHRASE" -T dist/k6-v$VERSION-amd64.rpm "https://$BINTRAY_USER:$BINTRAY_KEY@api.bintray.com/content/loadimpact/rpm/k6/$VERSION/k6-v$VERSION-amd64.rpm?publish=1&override=1" +workflows: + version: 2 + test_and_build: + jobs: + - lint: + filters: + tags: + only: /.*/ + - test: + filters: + tags: + only: /.*/ + - build-docker-images: + requires: + - lint + - test + - build-linux-packages: + requires: + - lint + - test + filters: + branches: + ignore: /.*/ + tags: + only: /^v.*/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 006e4c5e471..b23515118d0 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /dist /js/node_modules /docs +/pkg-build /debug test.debug diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..91e0c51c3e8 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,52 @@ +image: Visual Studio 2017 +clone_folder: 'c:\gopath\src\github.com\%APPVEYOR_REPO_NAME%' + +branches: + only: + - /^v\d+\.\d+\.\d+$/ + +environment: + # improve readability + VCS_URL: 'https://github.com/%APPVEYOR_REPO_NAME%' + # specific to go + VERSION: "%APPVEYOR_REPO_TAG_NAME:v=%" + GOPATH: c:\gopath + CGO_ENABLED: '0' + GOARCH: amd64 + BINTRAY_KEY: + secure: /0S6SdBwfiuWEdY4SKJcZpxEV+QpsfJfqx3QqYbnK8vwmB2KMGqerGzQRnIrkbGD + GPG_PASSPHRASE: + secure: CMQ+U+qVVdhIr1Eip5nGPbaGFggVvSjg/BpSY0EpLbQ= + +# prepare system and project +install: + - choco install wixtoolset pandoc -y + - refreshenv + # ensure wix is available in PATH + - set PATH=%WIX%\bin;%PATH% + # specific to go + - set PATH=%GOPATH%\bin;%PATH% + +# build msi artifacts +build_script: + - pandoc -s -f markdown -t rtf -o packaging\LICENSE.rtf LICENSE.md + - go build -a -ldflags "-s -w" -o packaging\k6.exe + - cd packaging + - candle.exe -arch x64 -dVERSION=%VERSION% k6.wxs + - light.exe -ext WixUIExtension k6.wixobj + +deploy_script: + # Publishing the msi + - 'curl -H "X-GPG-PASSPHRASE: %GPG_PASSPHRASE%" -T k6.msi "https://%BINTRAY_USER%:%BINTRAY_KEY%@api.bintray.com/content/loadimpact/windows/k6/%VERSION%/k6-v%VERSION%-amd64.msi?publish=1&override=1"' + - ps: | + # Create Chocolately Package + mkdir .\k6.portable + + Copy-Item -Path .\k6.portable.nuspec -Destination .\k6.portable\k6.portable.nuspec + Copy-Item -Path .\k6.exe -Destination .\k6.portable\k6.exe + + Set-Location -Path .\k6.portable\ + (Get-Content '.\k6.portable.nuspec' -Raw).Replace("__REPLACE__", "$($env:VERSION)") | Out-File '.\k6.portable.nuspec' + choco pack + # Publising the chocolatey package + - 'curl -H "X-GPG-PASSPHRASE: %GPG_PASSPHRASE%" -T .\k6.portable.%VERSION%.nupkg "https://%BINTRAY_USER%:%BINTRAY_KEY%@api.bintray.com/content/loadimpact/choco/k6.portable/%VERSION%/k6.portable.%VERSION%.nupkg?publish=1&override=1"' \ No newline at end of file diff --git a/packaging/Dockerfile.linux b/packaging/Dockerfile.linux new file mode 100644 index 00000000000..fa57b78a801 --- /dev/null +++ b/packaging/Dockerfile.linux @@ -0,0 +1,17 @@ +FROM golang:1.10.2-stretch + +RUN curl https://glide.sh/get | sh + +WORKDIR /go/src/github.com/loadimpact/k6 + +RUN go get github.com/mh-cbon/go-bin-deb \ + && cd /go/src/github.com/mh-cbon/go-bin-deb \ + && glide install \ + && go install + +RUN go get github.com/mh-cbon/go-bin-rpm \ + && cd /go/src/github.com/mh-cbon/go-bin-rpm \ + && glide install \ + && go install + + RUN apt-get update -y && apt-get install -y fakeroot rpm diff --git a/packaging/deb.json b/packaging/deb.json new file mode 100644 index 00000000000..5164c9bf94f --- /dev/null +++ b/packaging/deb.json @@ -0,0 +1,23 @@ +{ + "name": "k6", + "maintainer": "Load Impact AB", + "description": "Load testing for the 21st century", + "changelog-cmd": "echo \"* $(date \"+%a %b %d %Y\") Load Impact \n - Go to the release page for more details on the changelog.\n\n https://github.com/loadimpact/k6/releases/tag/v!version!\"", + "homepage": "https://k6.io/", + "files": [ + { + "from": "/tmp/!name!", + "to": "/usr/bin/", + "base" : "/tmp", + "fperm": "0755" + } + ], + "copyrights": [ + { + "files": "*", + "copyright": "2018 Load Impact AB", + "license": "AGPL-3.0", + "file": "LICENSE" + } + ] + } \ No newline at end of file diff --git a/packaging/docker-compose.yml b/packaging/docker-compose.yml new file mode 100644 index 00000000000..800063f6e16 --- /dev/null +++ b/packaging/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3' +services: + build-linux-packages: + build: + context: . + dockerfile: Dockerfile.linux + command: | + bash -c " + CGO_ENABLED=0 GOARCH=amd64 go build -a -ldflags '-s -w' -o /tmp/k6 + /go/src/github.com/loadimpact/k6/packaging/gen-packages.sh" + volumes: + - ..:/go/src/github.com/loadimpact/k6 \ No newline at end of file diff --git a/packaging/full-white-stripe.jpg b/packaging/full-white-stripe.jpg new file mode 100644 index 00000000000..b2a7032b183 Binary files /dev/null and b/packaging/full-white-stripe.jpg differ diff --git a/packaging/gen-packages.sh b/packaging/gen-packages.sh new file mode 100755 index 00000000000..423e2c4401f --- /dev/null +++ b/packaging/gen-packages.sh @@ -0,0 +1,13 @@ +#!/bin/bash +set -e + +if [[ -z "${VERSION}" ]]; then + echo "\$VERSION enviroment variable undefined" + exit 2 +fi + +rm -rf pkg-build + +mkdir -p dist +go-bin-deb generate --file packaging/deb.json -a amd64 --version $VERSION -o dist/k6-v$VERSION-amd64.deb +go-bin-rpm generate --file packaging/rpm.json -a amd64 --version $VERSION -o dist/k6-v$VERSION-amd64.rpm \ No newline at end of file diff --git a/packaging/k6.ico b/packaging/k6.ico new file mode 100644 index 00000000000..ba6920997d3 Binary files /dev/null and b/packaging/k6.ico differ diff --git a/packaging/k6.portable.nuspec b/packaging/k6.portable.nuspec new file mode 100644 index 00000000000..c853285062c --- /dev/null +++ b/packaging/k6.portable.nuspec @@ -0,0 +1,21 @@ + + + + k6.portable + k6 (Portable) + __REPLACE__ + Load Impact + Load Impact + Load testing for the 21st century + + k6 is a developer centric open source load testing tool for testing the performance of your backend infrastructure. It’s built with Go and JavaScript to integrate well into your development workflow, so you can stay on top of performance without fuzz. + + https://k6.io + https://github.com/loadimpact/k6 + https://github.com/loadimpact/k6 + + + https://github.com/loadimpact/k6/blob/master/LICENSE.md + false + + \ No newline at end of file diff --git a/packaging/k6.wxs b/packaging/k6.wxs new file mode 100644 index 00000000000..6f9afb9a9a0 --- /dev/null +++ b/packaging/k6.wxs @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packaging/rpm.json b/packaging/rpm.json new file mode 100644 index 00000000000..22a03e609bf --- /dev/null +++ b/packaging/rpm.json @@ -0,0 +1,17 @@ +{ + "name": "k6", + "Summary": "Load testing for the 21st century", + "description": "k6 is a developer centric open source load testing tool for testing the performance of your backend infrastructure. It’s built with Go and JavaScript to integrate well into your development workflow, so you can stay on top of performance without fuzz.", + "changelog-cmd": "echo \"* $(date \"+%a %b %d %Y\") Load Impact \n - Go to the release page for more details on the changelog.\n\n https://github.com/loadimpact/k6/releases/tag/v!version!\"", + "license": "LICENSE", + "version": "!version!", + "arch": "!arch!", + "url": "https://k6.io/", + "files": [ + { + "from": "/tmp/!name!", + "to": "%{_bindir}/", + "base": "/tmp" + } + ] + } \ No newline at end of file diff --git a/packaging/thin-white-stripe.jpg b/packaging/thin-white-stripe.jpg new file mode 100644 index 00000000000..7525d9adb67 Binary files /dev/null and b/packaging/thin-white-stripe.jpg differ