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

Builds deb, rpm, msi and chocolatey packages #675

Merged
merged 8 commits into from
Jun 21, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
114 changes: 100 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
version: 2
jobs:
build:
lint:
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.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: |
Expand All @@ -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: |
Expand All @@ -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: |
Expand Down Expand Up @@ -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.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/dist
/js/node_modules
/docs
/pkg-build

/debug
test.debug
Expand Down
50 changes: 50 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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
BINTRAY_KEY:
secure: /0S6SdBwfiuWEdY4SKJcZpxEV+QpsfJfqx3QqYbnK8vwmB2KMGqerGzQRnIrkbGD
GPG_PASSPHRASE:
secure: CMQ+U+qVVdhIr1Eip5nGPbaGFggVvSjg/BpSY0EpLbQ=

# prepare system and project
install:
- choco install wixtoolset -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:
- CGO_ENABLED=0 GOARCH=amd64 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:
- 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("<version>__REPLACE__</version>", "<version>$($env:VERSION)</version>") | Out-File '.\k6.portable.nuspec'
choco pack

# 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"'
# 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"'
17 changes: 17 additions & 0 deletions packaging/Dockerfile.linux
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions packaging/deb.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "k6",
"maintainer": "Load Impact AB",
"description": "Load testing for the 21st century",
"changelog-cmd": "cat './release notes/v0.21.0.md'",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? We'd have to change it for every release and I'm not sure how pretty the markdown file intended for github would be when you use it as a deb changelog. Also, if I remember correctly, debian changelogs included the full history of the package, not just the changes in the latest release.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw the command in the rpm.json spec, that one looks much more maintainable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missed the version variable, I'll added it

"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"
}
]
}
12 changes: 12 additions & 0 deletions packaging/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
Binary file added packaging/full-white-stripe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions packaging/gen-packages.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added packaging/k6.ico
Binary file not shown.
21 changes: 21 additions & 0 deletions packaging/k6.portable.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
<metadata>
<id>k6.portable</id>
<title>k6 (Portable)</title>
<version>__REPLACE__</version>
<authors>Load Impact</authors>
<owners>Load Impact</owners>
<summary>Load testing for the 21st century</summary>
<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.
</description>
<projectUrl>https://k6.io</projectUrl>
<packageSourceUrl>https://github.com/loadimpact/k6</packageSourceUrl>
<projectSourceUrl>https://github.com/loadimpact/k6</projectSourceUrl>
<tags></tags>
<copyright></copyright>
<licenseUrl>https://github.com/loadimpact/k6/blob/master/LICENSE.md</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
</metadata>
</package>
46 changes: 46 additions & 0 deletions packaging/k6.wxs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="8C5F9495-F697-4780-ABFD-90DCC2F681B6" Version="$(var.VERSION)" Language="1033" Name="k6" Manufacturer="Load Impact AB">
<Package InstallerVersion="300" Compressed="yes"/>
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit."/>

<Icon Id="k6Icon" SourceFile="k6.ico"/>
<Property Id="ARPPRODUCTICON" Value="k6Icon"/>

<Media Id="1" Cabinet="k6.cab" EmbedCab="yes" />

<!-- Step 1: Define the directory structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLDIR" Name="k6"/>
</Directory>
</Directory>

<!-- Step 2: Add files to your installer package -->
<DirectoryRef Id="INSTALLDIR">
<Component Id="k6.exe" Guid="*">
<File Id="k6.exe" Source="k6.exe" KeyPath="yes" />
</Component>
<Component Id="PathEnv" Guid="2DFDBB7D-292E-462c-A3E3-2FA14FFCD05D" >
<Environment Id="Path" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="yes" Separator=";" />
<CreateFolder />
</Component>
</DirectoryRef>

<!-- Step 3: Tell WiX to install the files -->
<Feature Id="MainApplication" Title="Main Application" Level="1">
<ComponentRef Id="k6.exe" />
<ComponentRef Id="PathEnv" />
</Feature>

<UI Id="k6InstallUI">
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
<Property Id="WIXUI_EXITDIALOGOPTIONALTEXT" Value="k6 has been successfully installed." />
</UI>

<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />
<WixVariable Id="WixUIBannerBmp" Value="thin-white-stripe.jpg"/>
<WixVariable Id="WixUIDialogBmp" Value="full-white-stripe.jpg"/>
</Product>
</Wix>
17 changes: 17 additions & 0 deletions packaging/rpm.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Binary file added packaging/thin-white-stripe.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.