Skip to content

Commit

Permalink
Merge pull request #3797 from weaveworks/update-build-tools
Browse files Browse the repository at this point in the history
Update build tools
  • Loading branch information
bboreham authored Jan 18, 2021
2 parents 2c040c7 + 7243af7 commit 9aa9b1a
Show file tree
Hide file tree
Showing 38 changed files with 184 additions and 242 deletions.
4 changes: 4 additions & 0 deletions .lintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated files
./cri/runtime/api.pb.go
# Files from different repo
./tools/*
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ shell:
tests: $(CODECGEN_TARGETS) prog/staticui/staticui.go prog/externalui/externalui.go
./tools/test -no-go-get -tags $(GO_BUILD_TAGS)

lint:
lint: prog/staticui/staticui.go prog/externalui/externalui.go
./tools/lint

prog/staticui/staticui.go:
Expand Down Expand Up @@ -278,7 +278,7 @@ realclean: clean
$(DOCKERHUB_USER)/scope $(DOCKERHUB_USER)/cloud-agent \
$(DOCKERHUB_USER)/scope:$(IMAGE_TAG) $(DOCKERHUB_USER)/cloud-agent:$(IMAGE_TAG) \
weaveworks/weaveexec:$(WEAVENET_VERSION) \
ubuntu:yakkety alpine:3.5 node:6.9.0 2>/dev/null || true
ubuntu:bionic alpine:3.11 node:6.9.0 2>/dev/null || true

# Dependencies are intentionally build without enforcing any tags
# since they are build on the host
Expand Down
2 changes: 1 addition & 1 deletion app/api_topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ type websocketState struct {
}

func (wc *websocketState) update(ctx context.Context) error {
span := ot.StartSpan("websocket.Render", ot.Tag{"topology", wc.topologyID})
span := ot.StartSpan("websocket.Render", ot.Tag{Key: "topology", Value: wc.topologyID})
defer span.Finish()
ctx = ot.ContextWithSpan(ctx, span)
// We measure how much time has passed since the channel was opened
Expand Down
2 changes: 1 addition & 1 deletion app/multitenant/aws_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func NewAWSCollector(config AWSCollectorConfig) (AWSCollector, error) {
}

func (c *awsCollector) flushLoop() {
for _ = range c.ticker.C {
for range c.ticker.C {
c.flushPending(context.Background())
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/multitenant/consul_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type consulClient struct {

// Get and deserialise a JSON value from consul.
func (c *consulClient) Get(ctx context.Context, key string, out interface{}) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "Consul Get", opentracing.Tag{"key", key})
span, ctx := opentracing.StartSpanFromContext(ctx, "Consul Get", opentracing.Tag{Key: "key", Value: key})
defer span.Finish()
kvp, _, err := c.kv.Get(key, queryOptions)
if err != nil {
Expand All @@ -76,7 +76,7 @@ func (c *consulClient) Get(ctx context.Context, key string, out interface{}) err
// CAS atomically modify a value in a callback.
// If value doesn't exist you'll get nil as a argument to your callback.
func (c *consulClient) CAS(ctx context.Context, key string, out interface{}, f CASCallback) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "Consul CAS", opentracing.Tag{"key", key})
span, ctx := opentracing.StartSpanFromContext(ctx, "Consul CAS", opentracing.Tag{Key: "key", Value: key})
defer span.Finish()
var (
index = uint64(0)
Expand Down
7 changes: 4 additions & 3 deletions app/multitenant/consul_pipe_router.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"context"

"github.com/gorilla/mux"
"github.com/gorilla/websocket"
opentracing "github.com/opentracing/opentracing-go"
Expand Down Expand Up @@ -289,7 +290,7 @@ func (pr *consulPipeRouter) Get(ctx context.Context, id string, e app.End) (xfer
}
key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id)
log.Infof("Get %s:%s", key, e)
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Get", opentracing.Tag{"key", key})
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Get", opentracing.Tag{Key: "key", Value: key})
defer span.Finish()

// Try to ensure the given end of the given pipe
Expand Down Expand Up @@ -333,7 +334,7 @@ func (pr *consulPipeRouter) Release(ctx context.Context, id string, e app.End) e
}
key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id)
log.Infof("Release %s:%s", key, e)
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Release", opentracing.Tag{"key", key})
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Release", opentracing.Tag{Key: "key", Value: key})
defer span.Finish()

// atomically clear my end of the pipe in consul
Expand All @@ -360,7 +361,7 @@ func (pr *consulPipeRouter) Delete(ctx context.Context, id string) error {
}
key := fmt.Sprintf("%s%s-%s", pr.prefix, userID, id)
log.Infof("Delete %s", key)
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Delete", opentracing.Tag{"key", key})
span, ctx := opentracing.StartSpanFromContext(ctx, "PipeRouter Delete", opentracing.Tag{Key: "key", Value: key})
defer span.Finish()

return pr.client.CAS(ctx, key, &consulPipe{}, func(in interface{}) (interface{}, bool, error) {
Expand Down
52 changes: 26 additions & 26 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ setup() {
else
echo "Cannot determine version - multiple tags point at HEAD:" >&2
for TAG in $HEAD_TAGS; do
echo -e "\t$TAG" >&2
echo -e "\\t$TAG" >&2
done
exit 1
fi
Expand All @@ -65,8 +65,8 @@ build() {

echo "== Clone repo at $LATEST_TAG for version $VERSION"
if [ -d "$RELEASE_DIR" ]; then
echo -e "\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2
echo -e "\trm -rf $RELEASE_DIR" >&2
echo -e "\\u2757 Release directory $RELEASE_DIR already exists, you may want to" >&2
echo -e "\\trm -rf $RELEASE_DIR" >&2
exit 1
fi

Expand All @@ -78,7 +78,7 @@ build() {
## Check that the top changelog entry is this version
if ! latest_changelog=$(perl -nle'print $& if m{(?<=^## Release ).*}' ./CHANGELOG.md | head -1) \
|| ! [ "$latest_changelog" = "$VERSION" ]; then
echo -e "\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
echo -e "\\u2757 Latest changelog entry \"$latest_changelog\" does not match the release version $VERSION" >&2
exit 1
fi

Expand All @@ -93,7 +93,7 @@ build() {
if make tests SUDO="$SUDO"; then
echo -e '\u2713 Tests pass'
else
echo -e "\u2757 Tests failed, probably best not publish this one" >&2
echo -e "\\u2757 Tests failed, probably best not publish this one" >&2
exit 1
fi

Expand All @@ -119,20 +119,20 @@ draft() {

## Check that the tag exists by looking at github
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_TAG_SHA" >/dev/null 2>&1; then
echo -e "\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2
echo -e "\\u2757 Tag $LATEST_TAG is not on GitHub, or is not the same as the local tag" >&2
echo -e "\\thttps://github.com/$GITHUB_USER/scope/tags" >&2
echo "You may need to" >&2
echo -e "\tgit push [email protected]:$GITHUB_USER/scope $LATEST_TAG"
echo -e "\\tgit push [email protected]:$GITHUB_USER/scope $LATEST_TAG"
exit 1
fi

echo -e "\u2713 Tag $LATEST_TAG exists in GitHub repo $GITHUB_USER/scope"
echo -e "\\u2713 Tag $LATEST_TAG exists in GitHub repo $GITHUB_USER/scope"

## Check that the version does not already exist by looking at github
## releases
if github-release info --user "$GITHUB_USER" --repo scope --tag "$LATEST_TAG" >/dev/null 2>&1; then
echo -e "\u2757 Release $LATEST_TAG already exists on GitHub" >&2
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2
echo -e "\\u2757 Release $LATEST_TAG already exists on GitHub" >&2
echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG" >&2
exit 1
fi

Expand All @@ -144,7 +144,7 @@ draft() {
fi

echo "== Creating GitHub release $RELEASE_ARGS $RELEASE_NAME $VERSION"
github-release release $RELEASE_ARGS \
github-release release "$RELEASE_ARGS" \
--user "$GITHUB_USER" \
--repo scope \
--tag "$LATEST_TAG" \
Expand All @@ -159,7 +159,7 @@ draft() {
--file "./scope"

echo "** Draft $TYPE $RELEASE_NAME $VERSION created at"
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
}

publish() {
Expand All @@ -177,22 +177,22 @@ publish() {
--tag "$LATEST_TAG"

echo "** Pre-release $RELEASE_NAME $VERSION published at"
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
else
echo "== Sanity checks"
if ! [ "$LATEST_TAG_COMMIT_SHA" == "$LATEST_RELEASE_COMMIT_SHA" ]; then
echo -e "\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2
echo -e "\\u2757 The tag latest_release does not point to the same commit as $LATEST_TAG" >&2
echo "You may need to" >&2
echo -e "\tgit tag -af latest_release $LATEST_TAG" >&2
echo -e "\\tgit tag -af latest_release $LATEST_TAG" >&2
exit 1
fi

## Check that the 'latest_release' tag exists by looking at github
if ! curl -sSf "https://api.github.com/repos/$GITHUB_USER/scope/git/tags/$LATEST_RELEASE_SHA" >/dev/null 2>&1; then
echo -e "\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2
echo -e "\thttps://github.com/$GITHUB_USER/scope/tags" >&2
echo -e "\\u2757 Tag latest_release is not on GitHub, or is not the same as the local tag" >&2
echo -e "\\thttps://github.com/$GITHUB_USER/scope/tags" >&2
echo "You may need to" >&2
echo -e "\tgit push -f [email protected]:$GITHUB_USER/scope latest_release" >&2
echo -e "\\tgit push -f [email protected]:$GITHUB_USER/scope latest_release" >&2
exit 1
fi
echo '** Sanity checks OK for publishing tag' "$LATEST_TAG" as "$DOCKERHUB_USER/scope:$VERSION"
Expand Down Expand Up @@ -229,8 +229,8 @@ publish() {
--file "./scope"

echo "** Release $RELEASE_NAME $VERSION published at"
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
echo -e "\thttps://github.com/$GITHUB_USER/scope/releases/latest_release"
echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/$LATEST_TAG"
echo -e "\\thttps://github.com/$GITHUB_USER/scope/releases/latest_release"
fi
}

Expand All @@ -254,19 +254,19 @@ push_images() {

usage() {
echo "Usage:"
echo -e "\t./bin/release build"
echo -e "\\t./bin/release build"
echo "-- Build artefacts for the latest version tag"
echo -e "\t./bin/release draft"
echo -e "\\t./bin/release draft"
echo "-- Create draft release with artefacts in GitHub"
echo -e "\t./bin/release publish"
echo -e "\\t./bin/release publish"
echo "-- Publish the GitHub release and update DockerHub"
exit 1
}

# Ensure required tooling is installed
if ! which github-release >/dev/null; then
if ! command -v github-release >/dev/null; then
echo "Please install git-release:" >&2
echo -e "\tgo get github.com/weaveworks/github-release" >&2
echo -e "\\tgo get github.com/weaveworks/github-release" >&2
echo "and create a git token per https://github.com/weaveworks/github-release" >&2
exit 1
fi
Expand Down
Loading

0 comments on commit 9aa9b1a

Please sign in to comment.