From f6ac2d82fd3795299fb52c0151309b1f0f5c7a8f Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 19 Nov 2021 15:22:46 +0800 Subject: [PATCH 1/2] feat #11: release hrp cli binaries automatically with github actions feat #20: add Makefile for running unittest and building hrp cli binary --- .github/workflows/release.yml | 31 ++++++++++++++++++++ .github/workflows/{main.yml => unittest.yml} | 4 +-- Makefile | 20 +++++++++++++ docs/CHANGELOG.md | 4 ++- docs/cmd/hrp.md | 2 +- docs/cmd/hrp_boom.md | 2 +- docs/cmd/hrp_har2case.md | 2 +- docs/cmd/hrp_run.md | 2 +- hrp/scripts/build.sh | 23 +++++++++++++++ 9 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release.yml rename .github/workflows/{main.yml => unittest.yml} (95%) create mode 100644 Makefile create mode 100644 hrp/scripts/build.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..89be10d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,31 @@ +name: Release hrp cli binaries + +on: + release: + types: [created] + +jobs: + releases-matrix: + name: Release hrp cli binaries + runs-on: ubuntu-latest + strategy: + matrix: + # build and publish in parallel: linux/amd64/windows + goos: [linux, windows, darwin] + goarch: [amd64, arm64] + exclude: + - goarch: arm64 + goos: windows + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Release hrp cli binaries + uses: wangyoucao577/go-release-action@v1.21 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + goos: ${{ matrix.goos }} + goarch: ${{ matrix.goarch }} + project_path: "./hrp" # go build ./hrp/main.go + binary_name: "hrp" + ldflags: "-s -w" + extra_files: LICENSE docs/README.md docs/CHANGELOG.md diff --git a/.github/workflows/main.yml b/.github/workflows/unittest.yml similarity index 95% rename from .github/workflows/main.yml rename to .github/workflows/unittest.yml index 5f4fdd3..053881a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/unittest.yml @@ -1,4 +1,4 @@ -name: Build and Test +name: Run unittest with coverage on: push: @@ -10,7 +10,7 @@ on: jobs: test: strategy: - fail-fast: false + fail-fast: true matrix: go-version: - 1.13.x diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f9133fb --- /dev/null +++ b/Makefile @@ -0,0 +1,20 @@ +SHELL=/usr/bin/env bash + +.DEFAULT_GOAL=help + +.PHONY: test +test: ## run unit tests + @echo "[info] run unit tests" + @echo "go test -race -v ./..." + @go test -race -v ./... + +.PHONY: build +build: ## build hrp cli tool + @echo "[info] build hrp cli tool" + @. hrp/scripts/build.sh + +.PHONY: help +help: ## print make commands + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \ + cut -d ":" -f1- | \ + awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0723d67..fce1a6c 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,8 +1,10 @@ # Release History -## v0.2.0 (2021-11-18) +## v0.2.0 (2021-11-19) - feat: deploy mkdocs to github pages when PR merged +- feat: release hrp cli binaries automatically with github actions +- feat: add Makefile for running unittest and building hrp cli binary ## v0.1.0 (2021-11-18) diff --git a/docs/cmd/hrp.md b/docs/cmd/hrp.md index c7313a1..d844cb5 100644 --- a/docs/cmd/hrp.md +++ b/docs/cmd/hrp.md @@ -22,4 +22,4 @@ Copyright 2021 debugtalk * [hrp har2case](hrp_har2case.md) - Convert HAR to json/yaml testcase files * [hrp run](hrp_run.md) - run API test -###### Auto generated by spf13/cobra on 18-Nov-2021 +###### Auto generated by spf13/cobra on 19-Nov-2021 diff --git a/docs/cmd/hrp_boom.md b/docs/cmd/hrp_boom.md index a96132a..c02e15d 100644 --- a/docs/cmd/hrp_boom.md +++ b/docs/cmd/hrp_boom.md @@ -37,4 +37,4 @@ hrp boom [flags] * [hrp](hrp.md) - One-stop solution for HTTP(S) testing. -###### Auto generated by spf13/cobra on 18-Nov-2021 +###### Auto generated by spf13/cobra on 19-Nov-2021 diff --git a/docs/cmd/hrp_har2case.md b/docs/cmd/hrp_har2case.md index a76d26c..d8de39c 100644 --- a/docs/cmd/hrp_har2case.md +++ b/docs/cmd/hrp_har2case.md @@ -23,4 +23,4 @@ hrp har2case harPath... [flags] * [hrp](hrp.md) - One-stop solution for HTTP(S) testing. -###### Auto generated by spf13/cobra on 18-Nov-2021 +###### Auto generated by spf13/cobra on 19-Nov-2021 diff --git a/docs/cmd/hrp_run.md b/docs/cmd/hrp_run.md index 8a64c60..dee9f37 100644 --- a/docs/cmd/hrp_run.md +++ b/docs/cmd/hrp_run.md @@ -30,4 +30,4 @@ hrp run path... [flags] * [hrp](hrp.md) - One-stop solution for HTTP(S) testing. -###### Auto generated by spf13/cobra on 18-Nov-2021 +###### Auto generated by spf13/cobra on 19-Nov-2021 diff --git a/hrp/scripts/build.sh b/hrp/scripts/build.sh new file mode 100644 index 0000000..60f0f41 --- /dev/null +++ b/hrp/scripts/build.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# build hrp cli binary for testing +# release will be triggered on github actions, see .github/workflows/release.yml + +# Usage: +# $ make build +# or +# $ bash hrp/scripts/build.sh + +set -e +set -x + +# prepare path +mkdir -p "output" +bin_path="output/hrp" + +# build +go build -ldflags '-s -w' -o "$bin_path" hrp/main.go + +# check output and version +ls -lh "$bin_path" +chmod +x "$bin_path" +./"$bin_path" -v From b21232ed293303b663841ea9d9a188e8c990810d Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 19 Nov 2021 17:39:25 +0800 Subject: [PATCH 2/2] bump version to v0.2.0 --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index de4e949..f0c8ef2 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,3 @@ package hrp -const VERSION = "v0.1.0" +const VERSION = "v0.2.0"