Skip to content

Commit

Permalink
Add Windows packaging and release job, split build into standalone job
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Mirić committed Sep 28, 2020
1 parent 8187dea commit 6ce1157
Show file tree
Hide file tree
Showing 2 changed files with 224 additions and 128 deletions.
352 changes: 224 additions & 128 deletions .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,135 +19,110 @@ env:
GODEBUG: netdns=go+1

jobs:
# deps:
# runs-on: ubuntu-latest
# defaults:
# run:
# shell: bash
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: 1.14.x
# - name: Check dependencies
# run: |
# go version
# test -z "$(go mod vendor && git status --porcelain)"
# go mod verify
deps:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Check dependencies
run: |
go version
test -z "$(go mod vendor && git status --porcelain)"
go mod verify
# lint:
# runs-on: ubuntu-latest
# defaults:
# run:
# shell: bash
# env:
# GOLANGCI_VERSION: v1.31
# GO111MODULE: 'on'
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# fetch-depth: 0
# - name: Lint
# # Why is `go mod vendor` needed here!? If it's not run then
# # golangci-lint fails because of inconsistent vendoring...
# run: |
# go get github.com/golangci/golangci-lint/cmd/golangci-lint@$GOLANGCI_VERSION
# BASEREV=$(git merge-base HEAD origin/master)
# echo "Base revision: $BASEREV"
# export PATH="$HOME/go/bin:$PATH"
# go mod vendor
# golangci-lint run --out-format=tab --new-from-rev "$BASEREV" ./...
lint:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
GOLANGCI_VERSION: v1.31
GO111MODULE: 'on'
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Lint
# Why is `go mod vendor` needed here!? If it's not run then
# golangci-lint fails because of inconsistent vendoring...
run: |
go get github.com/golangci/golangci-lint/cmd/golangci-lint@$GOLANGCI_VERSION
BASEREV=$(git merge-base HEAD origin/master)
echo "Base revision: $BASEREV"
export PATH="$HOME/go/bin:$PATH"
go mod vendor
golangci-lint run --out-format=tab --new-from-rev "$BASEREV" ./...
# test:
# strategy:
# matrix:
# go-version: [1.14.x, 1.15.x]
# platform: [ubuntu-latest, windows-latest]
# runs-on: ${{ matrix.platform }}
# defaults:
# run:
# shell: bash
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Install Go
# uses: actions/setup-go@v2
# with:
# go-version: ${{ matrix.go-version }}
# - name: Run tests with code coverage
# run: |
# go version
# export GOMAXPROCS=2
# export PATH=$GOPATH/bin:$PATH
# echo "mode: set" > coverage.txt
# for pkg in $(go list ./... | grep -v vendor); do
# list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep github.com/loadimpact/k6 | grep -v vendor || true)
# if [ -n "$list" ]; then
# list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd, -)
# fi
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
platform: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.platform }}
defaults:
run:
shell: bash
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Run tests with code coverage
run: |
go version
export GOMAXPROCS=2
export PATH=$GOPATH/bin:$PATH
echo "mode: set" > coverage.txt
for pkg in $(go list ./... | grep -v vendor); do
list=$(go list -test -f '{{ join .Deps "\n"}}' $pkg | grep github.com/loadimpact/k6 | grep -v vendor || true)
if [ -n "$list" ]; then
list=$(echo "$list" | cut -f1 -d ' ' | sort -u | paste -sd, -)
fi
# go test -v -race -timeout 800s --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
# done
# grep -h -v "^mode:" *.coverage >> coverage.txt
# rm -f *.coverage
# bash <(curl --fail -s https://codecov.io/bash)
# go tool cover -html=coverage.txt -o coverage.html
# - name: Upload coverage report
# uses: actions/upload-artifact@v2
# with:
# name: test-coverage-report
# path: coverage.html
go test -v -race -timeout 800s --coverpkg="$list" -coverprofile=$(echo $pkg | tr / -).coverage $pkg
done
grep -h -v "^mode:" *.coverage >> coverage.txt
rm -f *.coverage
bash <(curl --fail -s https://codecov.io/bash)
go tool cover -html=coverage.txt -o coverage.html
- name: Upload coverage report
uses: actions/upload-artifact@v2
with:
name: test-coverage-report
path: coverage.html

# docker:
# runs-on: ubuntu-latest
# needs: [lint, test]
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Build
# run: docker build -t $DOCKER_IMAGE_ID .
# - name: Check
# run: |
# docker run $DOCKER_IMAGE_ID version
# docker run $DOCKER_IMAGE_ID --help
# docker run $DOCKER_IMAGE_ID help
# docker run $DOCKER_IMAGE_ID run --help
# docker run $DOCKER_IMAGE_ID inspect --help
# docker run $DOCKER_IMAGE_ID status --help
# docker run $DOCKER_IMAGE_ID stats --help
# docker run $DOCKER_IMAGE_ID scale --help
# docker run $DOCKER_IMAGE_ID pause --help
# docker run $DOCKER_IMAGE_ID resume --help
# - name: Publish
# if: github.event_name != 'pull_request'
# run: |
# echo "REF=${{ github.ref }}"
# echo "DOCKER_IMAGE_ID=$DOCKER_IMAGE_ID"
# #
# # Log into registry
# echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
# # Strip git ref prefix from version
# VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# # Strip "v" prefix from tag name
# [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo "$VERSION" | sed -e 's/^v//')
# echo "VERSION=$VERSION"
# docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:$VERSION"
# docker push "$DOCKER_IMAGE_ID:$VERSION"
# # We also want to tag the latest stable version as latest
# if [[ "$VERSION" != "master" ]] && [[ ! "$VERSION" =~ (RC|rc) ]]; then
# docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:latest"
# docker push "$DOCKER_IMAGE_ID:latest"
# fi
configure:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
defaults:
run:
shell: bash
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version
id: get_version
run: |
VERSION="${GITHUB_REF##*/}"
echo "VERSION=${VERSION}"
echo "::set-output name=version::${VERSION}"
release:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
# needs: [lint, test]
needs: [deps, lint, test]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Checkout code
Expand All @@ -157,10 +132,8 @@ jobs:
with:
go-version: 1.14.x
- name: Install package builders
# Needed so that `go get` doesn't try to install glide as as a k6
# dependency, which would fail if run from the k6 directory because of
# Go modules.
working-directory: /tmp
env:
GO111MODULE: 'off'
run: |
gopath="$(go env GOPATH)"
go get github.com/Masterminds/glide
Expand All @@ -178,14 +151,137 @@ jobs:
run: |
go version
./build-release.sh
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: binaries
path: dist/

publish-docker:
runs-on: ubuntu-latest
needs: [deps, lint, test, configure]
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build
run: docker build -t $DOCKER_IMAGE_ID .
- name: Check
run: |
docker run $DOCKER_IMAGE_ID version
docker run $DOCKER_IMAGE_ID --help
docker run $DOCKER_IMAGE_ID help
docker run $DOCKER_IMAGE_ID run --help
docker run $DOCKER_IMAGE_ID inspect --help
docker run $DOCKER_IMAGE_ID status --help
docker run $DOCKER_IMAGE_ID stats --help
docker run $DOCKER_IMAGE_ID scale --help
docker run $DOCKER_IMAGE_ID pause --help
docker run $DOCKER_IMAGE_ID resume --help
- name: Publish
if: github.event_name != 'pull_request'
run: |
echo "REF=${{ github.ref }}"
echo "DOCKER_IMAGE_ID=$DOCKER_IMAGE_ID"
# Log into registry
echo "${{ secrets.DOCKER_PASS }}" | docker login -u "${{ secrets.DOCKER_USER }}" --password-stdin
VERSION="${VERSION#v}"
echo "VERSION=$VERSION"
docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:$VERSION"
docker push "$DOCKER_IMAGE_ID:$VERSION"
# We also want to tag the latest stable version as latest
if [[ "$VERSION" != "master" ]] && [[ ! "$VERSION" =~ (RC|rc) ]]; then
docker tag "$DOCKER_IMAGE_ID" "$DOCKER_IMAGE_ID:latest"
docker push "$DOCKER_IMAGE_ID:latest"
fi
publish-github:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
needs: [deps, lint, test, configure, build]
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: dist
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
assets=()
for asset in ./dist/*; do
assets+=("-a" "$asset")
done
tag_name="${GITHUB_REF##*/}"
hub release create "${assets[@]}" -m "$tag_name" -m "$(cat ./release\ notes/${tag_name}.md)" "$tag_name"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
hub release create "${assets[@]}" -m "$VERSION" -m "$(cat ./release\ notes/${VERSION}.md)" "$VERSION"
# - name: Upload packages to Bintray
# run: |
# # Publishing deb
# curl --fail -H "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -T "dist/k6-$VERSION-amd64.deb" \
# "https://${{ secrets.BINTRAY_USER }}:${{ secrets.BINTRAY_KEY }}@api.bintray.com/content/loadimpact/deb/k6/${VERSION#v}/k6-${VERSION}-amd64.deb;deb_distribution=stable;deb_component=main;deb_architecture=amd64;publish=1;override=1"
# # Publishing rpm
# curl --fail -H "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -T "dist/k6-$VERSION-amd64.rpm" \
# "https://${{ secrets.BINTRAY_USER }}:${{ secrets.BINTRAY_KEY }}@api.bintray.com/content/loadimpact/rpm/k6/${VERSION#v}/k6-${VERSION}-amd64.rpm?publish=1&override=1"

publish-windows:
runs-on: windows-latest
defaults:
run:
shell: powershell
needs: [deps, lint, test, configure, build]
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION: ${{ needs.configure.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install pandoc
uses: crazy-max/ghaction-chocolatey@v1
with:
args: install -y pandoc
- name: Install wix tools
run: |
curl -O wix311-binaries.zip https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
Expand-Archive -Path .\wix311-binaries.zip -DestinationPath .\wix311\
echo "::add-path::$($pwd.path)\wix311"
- name: Download binaries
uses: actions/download-artifact@v2
with:
name: binaries
path: dist
- name: Unzip Windows binary
run: |
Expand-Archive -Path ".\dist\k6-$env:VERSION-win64.zip" -DestinationPath .\packaging\
move .\packaging\k6-$env:VERSION-win64\k6.exe .\packaging\
rmdir .\packaging\k6-$env:VERSION-win64\
- name: Create MSI package
run: |
$env:VERSION = $env:VERSION -replace 'v(\d{1,}\.\d{1,}\.\d{1,}).*','$1'
pandoc -s -f markdown -t rtf -o packaging\LICENSE.rtf LICENSE.md
cd .\packaging
candle.exe -arch x64 "-dVERSION=$env:VERSION" k6.wxs
light.exe -ext WixUIExtension k6.wixobj
- name: Prepare Chocolatey package
run: |
$env:VERSION = $env:VERSION.TrimStart("v", " ")
cd .\packaging
(Get-Content '.\k6.portable.nuspec' -Raw).Replace("<version>__REPLACE__</version>", "<version>$env:VERSION</version>") | Out-File '.\k6.portable.nuspec'
- name: Create Chocolatey package
uses: crazy-max/ghaction-chocolatey@v1
with:
args: pack --verbose --outputdirectory .\packaging .\packaging\k6.portable.nuspec
# - name: Upload packages to Bintray
# run: |
# cd .\packaging
# $env:VERSION = $env:VERSION.TrimStart("v", " ")
# curl --fail -H "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -T .\k6.msi "https://${{ secrets.BINTRAY_USER }}:${{ secrets.BINTRAY_KEY }}@api.bintray.com/content/loadimpact/windows/k6/$env:VERSION/k6-v$env:VERSION-amd64.msi?publish=1&override=1"
# curl --fail -H "X-GPG-PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}" -T .\k6.portable.$env:VERSION.nupkg "https://${{ secrets.BINTRAY_USER }}:${{ secrets.BINTRAY_KEY }}@api.bintray.com/content/loadimpact/choco/k6.portable/$env:VERSION/k6.portable.$env:VERSION.nupkg?publish=1&override=1"'
File renamed without changes.

0 comments on commit 6ce1157

Please sign in to comment.