mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2024-11-24 08:22:25 +02:00
Script to verify example after new release. (#579)
* verify example. * fix review comments. * fix tools/go.* * remove leftover exit.
This commit is contained in:
parent
5d346a4190
commit
f474c349ae
4
Makefile
4
Makefile
@ -53,6 +53,10 @@ $(TOOLS_DIR)/stringer: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_M
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/stringer golang.org/x/tools/cmd/stringer
|
||||
|
||||
$(TOOLS_DIR)/gojq: $(TOOLS_MOD_DIR)/go.mod $(TOOLS_MOD_DIR)/go.sum $(TOOLS_MOD_DIR)/tools.go
|
||||
cd $(TOOLS_MOD_DIR) && \
|
||||
go build -o $(TOOLS_DIR)/gojq github.com/itchyny/gojq/cmd/gojq
|
||||
|
||||
precommit: generate build lint examples test
|
||||
|
||||
.PHONY: test-with-coverage
|
||||
|
@ -34,3 +34,12 @@ Use the same tag as used in the pre-release step.
|
||||
## Release
|
||||
Now create a release for the new tag on github. tag.sh script generates commit logs since
|
||||
last release. Use that to draft the new release.
|
||||
|
||||
## Verify Examples
|
||||
After releasing run following script to verify that examples build outside of the otel repo.
|
||||
The script copies examples into a different directory and builds them.
|
||||
|
||||
```
|
||||
./verify_examples.sh
|
||||
```
|
||||
|
||||
|
@ -4,6 +4,10 @@ go 1.13
|
||||
|
||||
require (
|
||||
github.com/client9/misspell v0.3.4
|
||||
github.com/fatih/color v1.9.0 // indirect
|
||||
github.com/golangci/golangci-lint v1.23.6
|
||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||
github.com/stretchr/testify v1.5.0 // indirect
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 // indirect
|
||||
golang.org/x/tools v0.0.0-20200220155224-947cbf191135
|
||||
)
|
||||
|
11
tools/go.sum
11
tools/go.sum
@ -30,6 +30,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
|
||||
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
@ -165,6 +167,9 @@ github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaa
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
@ -245,6 +250,8 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.0 h1:DMOzIV76tmoDNE9pX6RSN0aDtCYeCg5VueieJaAo1uw=
|
||||
github.com/stretchr/testify v1.5.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/timakin/bodyclose v0.0.0-20190930140734-f7f2e9bca95e h1:RumXZ56IrCj4CL+g1b9OL/oH0QnsF976bC8xQFYUD5Q=
|
||||
@ -310,6 +317,10 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69 h1:rOhMmluY6kLMhdnrivzec6lLgaVbMHMn2ISQXJeJ5EM=
|
||||
golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4 h1:sfkvUWPNGwSV+8/fNqctR5lS2AqCSqYwXdrjCxp/dXo=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
|
86
verify_examples.sh
Executable file
86
verify_examples.sh
Executable file
@ -0,0 +1,86 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright The OpenTelemetry Authors
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
cd $(dirname $0)
|
||||
TOOLS_DIR=$(pwd)/.tools
|
||||
|
||||
if [ -z "${GOPATH}" ] ; then
|
||||
printf "GOPATH is not defined.\n"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ ! -d "${GOPATH}" ] ; then
|
||||
printf "GOPATH ${GOPATH} is invalid \n"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
# Pre-requisites
|
||||
if ! git diff --quiet; then \
|
||||
git status
|
||||
printf "\n\nError: working tree is not clean\n"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
if [ "$(git tag --contains $(git log -1 --pretty=format:"%H"))" = "" ] ; then
|
||||
printf "$(git log -1)"
|
||||
printf "\n\nError: HEAD is not pointing to a tagged version"
|
||||
fi
|
||||
|
||||
make ${TOOLS_DIR}/gojq
|
||||
|
||||
DIR_TMP="${GOPATH}/src/oteltmp/"
|
||||
rm -rf $DIR_TMP
|
||||
mkdir -p $DIR_TMP
|
||||
|
||||
printf "Copy examples to ${DIR_TMP}\n"
|
||||
cp -a ./example ${DIR_TMP}
|
||||
|
||||
# Update go.mod files
|
||||
printf "Update go.mod: rename module and remove replace\n"
|
||||
|
||||
PACKAGE_DIRS=$(find . -mindepth 2 -type f -name 'go.mod' -exec dirname {} \; | egrep 'example' | sed 's/^\.\///' | sort)
|
||||
|
||||
for dir in $PACKAGE_DIRS; do
|
||||
printf " Update go.mod for $dir\n"
|
||||
(cd "${DIR_TMP}/${dir}" && \
|
||||
# replaces is ("mod1" "mod2" …)
|
||||
replaces=($(go mod edit -json | ${TOOLS_DIR}/gojq '.Replace[].Old.Path')) && \
|
||||
# strip double quotes
|
||||
replaces=("${replaces[@]%\"}") && \
|
||||
replaces=("${replaces[@]#\"}") && \
|
||||
# make an array (-dropreplace=mod1 -dropreplace=mod2 …)
|
||||
dropreplaces=("${replaces[@]/#/-dropreplace=}") && \
|
||||
go mod edit -module "oteltmp/${dir}" "${dropreplaces[@]}" && \
|
||||
go mod tidy)
|
||||
done
|
||||
printf "Update done:\n\n"
|
||||
|
||||
# Build directories that contain main package. These directories are different than
|
||||
# directories that contain go.mod files.
|
||||
#
|
||||
printf "Build examples:\n"
|
||||
EXAMPLES=$(./get_main_pkgs.sh ./example)
|
||||
for ex in $EXAMPLES; do
|
||||
printf " Build $ex in ${DIR_TMP}/${ex}\n"
|
||||
(cd "${DIR_TMP}/${ex}" && \
|
||||
go build .)
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
printf "Remove copied files.\n"
|
||||
rm -rf $DIR_TMP
|
Loading…
Reference in New Issue
Block a user