From eb2190eb0d7e751b1ef61fe110bade1ab8f44aad Mon Sep 17 00:00:00 2001 From: Jonathan Cope Date: Thu, 26 Jul 2018 17:20:41 -0500 Subject: [PATCH] Add release note generator; tweak test coverage reporting, fixup docs (#276) Tweak script, add make target refactored makefile removed redundanty vendor exclusion Updated dev readme and release doc eval when non-docker review comment changes spelling --- .gitignore | 1 + .travis.yml | 3 +- Makefile | 54 +++++++----------- doc/releases.md | 38 ++++++++----- hack/README.md | 15 +++++ hack/build/config.sh | 2 +- hack/build/release-description.sh | 91 +++++++++++++++++++++++++++++++ 7 files changed, 153 insertions(+), 51 deletions(-) create mode 100755 hack/build/release-description.sh diff --git a/.gitignore b/.gitignore index 9443493ad..416fbe95f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ _out/* bin/* manifests/generated/* .coverprofile +release-announcement diff --git a/.travis.yml b/.travis.yml index 5d2893aff..83c28e57e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,10 +47,9 @@ script: - "sed \"s#cdi.kubevirt.io/storage.import.endpoint:.*#cdi.kubevirt.io/storage.import.endpoint: \"$SRC#\"\" manifests/example/golden-pvc.yaml | kubectl apply -f -" - k_wait_all_running pods - kubectl get pods --all-namespaces -- if [[ ${TRAVIS_PULL_REQUEST} == 'false' ]]; then make goveralls && make test-functional; else make test; fi +- make goveralls && make test-functional before_deploy: -- git remote set-url origin https://"${GH_USER}":"${GH_TOKEN}"@github.com/kubevirt/containerized-data-importer.git - docker login -u="$DOCKER_USER" -p="$DOCKER_PASS" deploy: diff --git a/Makefile b/Makefile index 4917fe297..902c7e1b6 100644 --- a/Makefile +++ b/Makefile @@ -12,8 +12,6 @@ #See the License for the specific language governing permissions and #limitations under the License. -DOCKER=1 - .PHONY: build build-controller build-importer \ docker docker-controller docker-cloner docker-importer \ test test-functional test-unit \ @@ -21,23 +19,24 @@ DOCKER=1 vet \ format \ manifests \ - goveralls + goveralls \ + release-description + +DOCKER=1 +ifeq (${DOCKER}, 1) +DO=./hack/build/in-docker +else +DO=eval +endif all: docker clean: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "./hack/build/build-go.sh clean; rm -rf bin/* _out/* manifests/generated/* .coverprofile" -else - ./hack/build/build-go.sh clean; rm -rf bin/* _out/* manifests/generated/* .coverprofile -endif + ${DO} "./hack/build/build-go.sh clean; rm -rf bin/* _out/* manifests/generated/* .coverprofile release-announcement" build: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "./hack/build/build-go.sh clean && ./hack/build/build-go.sh build ${WHAT} && DOCKER_REPO=${DOCKER_REPO} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} ./hack/build/build-manifests.sh ${WHAT} && ./hack/build/build-copy-artifacts.sh ${WHAT}" -else - ./hack/build/build-go.sh clean && ./hack/build/build-go.sh build ${WHAT} && ./hack/build/build-manifests.sh && ./hack/build/build-copy-artifacts.sh ${WHAT} -endif + ${DO} "./hack/build/build-go.sh clean && ./hack/build/build-go.sh build ${WHAT} && DOCKER_REPO=${DOCKER_REPO} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} ./hack/build/build-manifests.sh ${WHAT} && ./hack/build/build-copy-artifacts.sh ${WHAT}" + build-controller: WHAT = cmd/cdi-controller build-controller: build @@ -46,11 +45,7 @@ build-importer: build # Note, the cloner is a bash script and has nothing to build test: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "./hack/build/build-go.sh test ${WHAT}" -else - ./hack/build/build-go.sh test ${WHAT} -endif + ${DO} "./hack/build/build-go.sh test ${WHAT}" test-unit: WHAT = pkg/ test-unit: test @@ -81,25 +76,16 @@ publish: docker ./hack/build/build-docker.sh publish ${WHAT} vet: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "./hack/build/build-go.sh vet ${WHAT}" -else - ./hack/build/build-go.sh vet ${WHAT} -endif + ${DO} "./hack/build/build-go.sh vet ${WHAT}" format: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "./hack/build/format.sh" -else - ./hack/build/format.sh -endif + ${DO} "./hack/build/format.sh" manifests: -ifeq (${DOCKER}, 1) - ./hack/build/in-docker "DOCKER_REPO=${DOCKER_REPO} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} ./hack/build/build-manifests.sh" -else - ./hack/build/build-manifests.sh -endif + ${DO} "DOCKER_REPO=${DOCKER_REPO} DOCKER_TAG=${DOCKER_TAG} VERBOSITY=${VERBOSITY} PULL_POLICY=${PULL_POLICY} ./hack/build/build-manifests.sh" goveralls: - ./hack/build/in-docker "TRAVIS_JOB_ID=${TRAVIS_JOB_ID} TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} TRAVIS_BRANCH=${TRAVIS_BRANCH} ./hack/build/goveralls.sh" + ${DO} "TRAVIS_JOB_ID=${TRAVIS_JOB_ID} TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} TRAVIS_BRANCH=${TRAVIS_BRANCH} ./hack/build/goveralls.sh" + +release-description: + ./hack/build/release-description.sh ${RELREF} ${PREREF} diff --git a/doc/releases.md b/doc/releases.md index 735436d5e..67ebf0de1 100644 --- a/doc/releases.md +++ b/doc/releases.md @@ -1,5 +1,10 @@ # Version and Release +* [Overview](#overview) +* [Version Scheme](#version-scheme) +* [Releasing a New Version](#releasing-a-new-version) + * [Verifying the Release](#verifying-the-release) + * [Travis CI](#travis-ci) ### Overview ### Version Scheme @@ -14,41 +19,46 @@ CDI adheres to the [semantic version definitions](https://semver.org/) format of ### Releasing a New Version - The version number is tracked in several files in CDI as well as through a git tag. To reduce the chance of human error, a help script is used to change the version in all known locations. +Release branches are used to isolate a stable version of CDI. Git tags are used within these release branches to track incrementing of Minor and Patch versions. When a Major version is incremented, a new stable branch should be created corresponding to the release. - DO NOT EDIT ANY VERSION STRINGS IN CDI!! +- Release branches should adhere to the `release-v#.#.#` pattern. -1. Set the new release version +- Tags should adhere to the `v#.#.#(-alpha.#)` pattern. - A recipe has been provided in `Makefile` to handle version setting. Use ONLY this command to set versions. Do NOT edit the values manually. +When creating a new release branch, follow the below process. This assumes that `origin` references a fork of `kubevirt/containerized-data-importer` and you have added the main repository as the remote alias ``. If you have cloned `kubevirt/containerized-data-importer` directly, omit the `` alias. - $ make set-version VERSION=v#.#.# +1. Make sure you have the latest upstream code - The `set-version` recipe will locate files in CDI containing the current version value, substitute in the new version, then commit and tag the changes. The user will be shown a list of files to be changed and prompted to continue before the substitutions are made. + `$ git pull master` -1. Verify the changes +1. Create a new branch from `/master` - Before publishing the changes, make one last check to verify the correct version value has been substituted in. + `$ git checkout /master -b release-v#.#.#` - $ git diff HEAD~1 +1. Create a tag corresponding to the version -1. Push the changes to Github + `$ git tag -a -m "Release of version v#.#.#" v#.#.#` - $ git push upstream master && git push upstream --tags +1. Push the new branch and tag to the main kubevirt repo. (If you have cloned the main repo directly, use `origin` for <`upstream`>) - Travis CI will detect the new tag and execute the deploy script. This will publish the newly updated controller manifest and CDI binaries to git releases. + `$ git push -u release-v#.#.# && git push --tags` +CI will be triggered when a tag matching `v#.#.#(-alpha.#)` is pushed. The automation will handle release artifact testing, building, and publishing. + +Following the release, `make release-description` should be executed to generate a github release description template. The `Notable Changes` section should be filled in manually, briefly listing major changes that the new release includes. Copy/Paste this template into the corresponding github release. #### Verifying the Release ##### Images -- Check hub.docker.com/r/kubevirt repository for the newly tagged images. If you do not see the tags corresponding to the version, something has gone wrong. +- Check hub.docker.com/r/kubevirt repository for the newly tagged images. If you do not see the tags corresponding to the version, check the travis build log for errors. [CDI-Controller](https://hub.docker.com/r/kubevirt/cdi-controller/tags/) [CDI-Importer](https://hub.docker.com/r/kubevirt/cdi-importer/) -##### Travis CI Jobs + [CDI-Cloner](https://hub.docker.com/r/kubevirt/cdi-cloner/) + +##### Travis CI Track the CI job for the pushed tag. Navigate to the [CDI Travis dashboard](https://travis-ci.org/kubevirt/containerized-data-importer/branches) and select the left most colored box (either Green, Yellow, or Red) for the branch corresponding to the version diff --git a/hack/README.md b/hack/README.md index 79f734678..2ac46d1b0 100644 --- a/hack/README.md +++ b/hack/README.md @@ -1,5 +1,16 @@ ## Getting Started For Developers +* [Download CDI](#download-cdi) + * [Lint, Test, Build](#lint-test-build) + * [Make Targets](#make-targets) + * [Make Variables](#make-variables) + * [Submit PRs](#submit-prs) + * [Releases](#releases) + * [Vendoring Dependencies](#vendoring-dependencies) + * [S3 Compatible Client Setup](#s3-compatible-client-setup) + * [AWS S3 CLI](#aws-s3-cli) + * [Minio CLI](#minio-cli) + ### Download CDI To download the source directly, simply @@ -59,6 +70,10 @@ These may be passed to a target as `$ make VARIABLE=value target` All PRs should originate from forks of kubevirt.io/containerized-data-importer. Work should not be done directly in the upstream repository. Open new working branches from master/HEAD of your forked repository and push them to your remote repo. Then submit PRs of the working branch against the upstream master branch. +### Releases + +Release practices are described in the [release doc](/doc/releases.md). + ### Vendoring Dependencies This project uses `glide` as it's dependency manager. At present, all project dependencies are vendored; using `glide` is unnecessary in the normal work flow. diff --git a/hack/build/config.sh b/hack/build/config.sh index f863bd402..7a8a41c70 100755 --- a/hack/build/config.sh +++ b/hack/build/config.sh @@ -30,6 +30,6 @@ VERBOSITY=${VERBOSITY:-1} PULL_POLICY=${PULL_POLICY:-IfNotPresent} function allPkgs { - ret=$(sed "s,kubevirt.io/containerized-data-importer,${CDI_DIR},g" <(go list ./... | grep -v -E "vendor|pkg/client" | sort -u )) + ret=$(sed "s,kubevirt.io/containerized-data-importer,${CDI_DIR},g" <(go list ./... | grep -v "pkg/client" | sort -u )) echo "$ret" } diff --git a/hack/build/release-description.sh b/hack/build/release-description.sh new file mode 100755 index 000000000..d3afe613e --- /dev/null +++ b/hack/build/release-description.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash + +set -eou pipefail + +underline() { + echo "$2" + printf "%0.s$1" $(seq ${#2}) +} + +log() { echo "$@" >&2; } +title() { underline "=" "$@"; } +section() { underline "-" "$@"; } + +# +# All sorts of content +# +release_notes() { + log "Fetching release notes" + cat manual-release-notes || echo "FIXME manual notes needed" +} + +summary() { + log "Building summary" + echo "This release follows $PREREF and consists of $(git log --oneline $RELSPANREF | wc -l) changes, contributed by" + echo -n "$(git shortlog -sne $RELSPANREF | wc -l) people, leading to" + echo "$(git diff --shortstat $RELSPANREF)." +} + +downloads() { + log "Adding download urls" + local GHRELURL="https://github.com/kubevirt/containerized-data-importer/releases/tag/" + local RELURL="$GHRELURL$RELREF" + cat <. + +Pre-built CDI containers are published on Docker Hub and can be viewed at: + + +. +EOF +} + +shortlog() { + git shortlog -sne $RELSPANREF | sed "s/^/ /" +} + +usage() { + echo "Usage: $0 [RELEASE_REF] [PREV_RELEASE_REF]" +} + +main() { + log "Span: $RELSPANREF" + cat < +- [How to contribute][contributing] + +[contributing]: https://github.com/kubevirt/containerized-data-importer/blob/master/hack/README.md +EOF +} + +# +# Let's get the party started +# +RELREF="$1" +PREREF="$2" +RELREF=${RELREF:-$(git describe --abbrev=0 --tags)} +PREREF=${PREREF:-$(git describe --abbrev=0 --tags $RELREF^)} +RELSPANREF=$PREREF..$RELREF + +main + +# vim: sw=2 et