Skip to content

Commit

Permalink
Update release vscode (#109)
Browse files Browse the repository at this point in the history
* increment go-utils

* restore vscode download feature

* restore vsce to cloudbuild

* fix makefile, gen docs

* fix pre-release err with changelog validation?

* use strings in cloudbuild

* try old cloudbuild config

* partial cloudbuild

* partial cloudbuild - missing id

* partial cloudbuild - rest of cloudbuild

* partial cloudbuild - without publish

* partial cloudbuild - fix invalid yaml

* guard extension publish behind release flag

* fix dirs in cloudbuild

* generate version info in goscript

* specify directory for cloudbuild make

* fix mis-named script

* remove v from toml versions, hyphenate make targets, extend cloudbuild timeout

* consolidate make files

* use go-vsce cloudbuild

* extend timeout

* include go-vsce tag

* json comma fix

* guard package by release, use png for vscode

* update BinariesSha type for tsc

* update hash check in vscode

* update vscode readme

* update image

* tweak readme, clean cloudbuild
  • Loading branch information
mitchdraft authored Mar 5, 2019
1 parent 132afbf commit e77c988
Show file tree
Hide file tree
Showing 15 changed files with 304 additions and 313 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
name = "github.com/solo-io/solo-kit"
version = "0.2.29"

[[constraint]]
name = "github.com/solo-io/go-utils"
version = "0.2.12"

[[override]]
name = "gopkg.in/fsnotify.v1"
source = "https://github.com/fsnotify/fsnotify.git"
63 changes: 18 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,32 +140,34 @@ $(OUTPUT_DIR)/plank-gdb-container: $(OUTPUT_DIR)/plank/plank $(OUTPUT_DIR)/plank
docker build -f $(OUTPUT_DIR)/plank/Dockerfile.gdb -t $(DOCKER_REPO)/plank-gdb:$(VERSION) $(OUTPUT_DIR)/plank/
touch $@


#----------------------------------------------------------------------------------
# Extension
# VS-Code extension
#----------------------------------------------------------------------------------

.PHONY: publish-extension
publish-extension: bump-extension-version ## (vscode) Publishes extension
publish-extension: package-extension ## (vscode) Publishes extension
ifeq ($(RELEASE),"true")
./hack/publish-extension.sh
endif

.PHONY: package-extension
package-extension: bump-extension-version ## (vscode) Packages extension
ifeq ($(RELEASE),"true")
cd editor/vscode && vsce package
endif

.PHONY: bump-extension-version
bump-extension-version: ## (vscode) Bumps extension version
cd editor/vscode && \
jq '.version="$(VERSION)" | .version=.version[1:]' package.json > package.json.tmp && \
mv package.json.tmp package.json && \
jq '.version="$(VERSION)" | .binaries.linux="$(shell sha256sum $(OUTPUT_DIR)/squashctl-linux|cut -f1 -d" ")" | .binaries.darwin="$(shell sha256sum $(OUTPUT_DIR)/squashctl-darwin|cut -f1 -d" ")"' src/squash.json > src/squash.json.tmp && \
mv src/squash.json.tmp src/squash.json
go run ci/bump_extension_version.go $(VERSION)


#----------------------------------------------------------------------------------
# Build All
#----------------------------------------------------------------------------------
.PHONY: build
build: squashctl squash plank


#----------------------------------------------------------------------------------
# Docker
#----------------------------------------------------------------------------------
Expand Down Expand Up @@ -194,48 +196,19 @@ upload-github-release-assets: squashctl
go run ci/upload_github_release_assets.go


#------------------------
# .PHONY: binaries
# binaries: $(OUTPUT_DIR)/plank/plank $(OUTPUT_DIR)/squashctl $(OUTPUT_DIR)/squash # Builds squashctl binaries in and places them in $(OUTPUT_DIR)/ folder


# RELEASE_BINARIES := $(OUTPUT_DIR)/squashctl-linux $(OUTPUT_DIR)/squashctl-darwin $(OUTPUT_DIR)/squashctl-windows $(OUTPUT_DIR)/plank/plank $(OUTPUT_DIR)/squash

# .PHONY: release-binaries
# release-binaries: $(RELEASE_BINARIES)

# .PHONY: containers
# containers: $(OUTPUT_DIR)/plank-dlv-container $(OUTPUT_DIR)/plank-gdb-container ## Builds debug containers

# .PHONY: push-containers
# push-containers: all $(OUTPUT_DIR)/plank-dlv-pushed $(OUTPUT_DIR)/plank-gdb-pushed $(OUTPUT_DIR)/squash-pushed squashctl-pushed ## Pushes debug containers to $(DOCKER_REPO)

# .PHONY: release
# release: push-containers release-binaries ## Pushes containers to $(DOCKER_REPO) and releases binaries to GitHub

# .PHONY: upload-release
# upload-release: ## Uploads artifacts to GitHub releases
# ./hack/github-release.sh owner=solo-io repo=squash tag=$(VERSION)
# @$(foreach BINARY,$(RELEASE_BINARIES),./hack/upload-github-release-asset.sh owner=solo-io repo=squash tag=$(VERSION) filename=$(BINARY);)


# dist: $(OUTPUT_DIR)/plank-gdb-pushed $(OUTPUT_DIR)/plank-dlv-pushed ## Pushes all containers to $(DOCKER_REPO)



#----------------------------------------------------------------------------------
# Development utils
#----------------------------------------------------------------------------------
# Helpers for development: build and push (locally) only the things you changed
# first run `eval $(minikube docker-env)` then any of these commands
.PHONY: dev_squashctl
dev_squashctl: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/squashctl
.PHONY: dev-squashctl-darwin
dev-squashctl-darwin: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/squashctl-darwin

.PHONY: dev_win_squashctl
dev_win_squashct: $(OUTPUT_DIR)/squashctl-windows
.PHONY: dev-squashctl-win
dev-squashct-win: $(OUTPUT_DIR)/squashctl-windows

.PHONY: dev_planks
dev_planks: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/plank-dlv-container $(OUTPUT_DIR)/plank-gdb-container
.PHONY: dev-planks
dev-planks: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/plank-dlv-container $(OUTPUT_DIR)/plank-gdb-container

.PHONY: dev_squash
dev_planks: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/squash-container
.PHONY: dev-squash
dev-planks: $(OUTPUT_DIR) $(SRCS) $(OUTPUT_DIR)/squash-container
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h1 align="center">
<img src="img/squash.svg" alt="squash" width="200" height="248">
<img src="https://s3.amazonaws.com/artifacts.solo.io/squash.png" alt="squash" width="230" height="275">
<br>
Debugger for microservices
</h1>
Expand All @@ -8,6 +8,12 @@
<h4 align="center">Debug your microservice applications from your terminal or IDE <i>while</i> they run in Kubernetes.</h4>
<BR>

[**Installation**](https://squash.solo.io/overview/quick_start/) &nbsp; |
&nbsp; [**Documentation**](https://squash.solo.io) &nbsp; |
&nbsp; [**Blog**](https://medium.com/solo-io/squash-microservices-debugger-5023e27533de) &nbsp; |
&nbsp; [**Slack**](https://slack.solo.io) &nbsp; |
&nbsp; [**Twitter**](https://twitter.com/soloio_inc)


Debugging microservices applications is a difficult task. The state of an application is spread across multiple processes, often on different nodes. It is hard to get the holistic view of an application's state. Certain tools exist for troubleshooting microservice issues. OpenTracing can be used to produce transaction or workflow logs for post-mortem analysis. Service meshes like Istio can be used to monitor the network to identify latency problems. Unfortunately, these tools are passive, the feedback loop is slow, and they do not allow you to monitor and alter the application during run time.

Expand Down
3 changes: 3 additions & 0 deletions changelog/v0.4.1/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
changelog:
- type: NON_USER_FACING
description: "include vscode extension publish in cloudbuild"
147 changes: 147 additions & 0 deletions ci/bump_extension_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
package main

import (
"bufio"
"context"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"regexp"

"github.com/solo-io/go-utils/contextutils"
)

// This program does three things:
const (
// 1. reads and hashes these files
outputWin32 = "_output/squashctl-windows.exe"
outputLinux = "_output/squashctl-linux"
outputDarwin = "_output/squashctl-darwin"

// 2. modifies the version field of this file
jsPackage = "editor/vscode/package.json"

// 3. produces this file
squashConfig = "editor/vscode/src/squash.json"
)

// (End summary of functionality)

const (
extensionBaseName = "squashctl"
)

var (
jsPackageVersionLineMatch *regexp.Regexp
)

func init() {
jsPackageVersionLineMatch = regexp.MustCompile("THIS_VALUE_WILL_BE_REPLACED_BY_BUILD_SCRIPT")
}

type SquashSpec struct {
Version string `json:"version"`
BaseName string `json:"baseName"`
Binaries Binaries `json:"binaries"`
}

type Binaries struct {
Win32 string `json:"win32"`
Linux string `json:"linux"`
Darwin string `json:"darwin"`
}

func main() {

ctx := context.TODO()
if len(os.Args) != 2 {
contextutils.LoggerFrom(ctx).Fatal("Must pass a single argument ( version )")
}
version := os.Args[1]

mustPrepareJsPackage(ctx, version)
mustPrepareConfigFile(ctx, version)

}

func mustPrepareJsPackage(ctx context.Context, version string) {
lo := contextutils.LoggerFrom(ctx)
file, err := os.Open(jsPackage)
if err != nil {
lo.Fatal(err)
}
scanner := bufio.NewScanner(file)
out := ""
for scanner.Scan() {
if jsPackageVersionLineMatch.MatchString(scanner.Text()) {
out += fmt.Sprintf(` "version": "%v",%v`, version, "\n")
} else {
out += scanner.Text() + "\n"
}
}
file.Close()
writeOut, err := os.Create(jsPackage)
if err != nil {
lo.Fatal(err)
}
defer writeOut.Close()
// must be explicit with the format string to prevent accidental substitutions
if _, err := fmt.Fprintf(writeOut, "%v", out); err != nil {
lo.Fatal(err)
}
}

func mustPrepareConfigFile(ctx context.Context, version string) {
bins := Binaries{
Linux: MustGetSha(ctx, outputLinux),
Darwin: MustGetSha(ctx, outputDarwin),
Win32: MustGetSha(ctx, outputWin32),
}

squashSpec := SquashSpec{
Version: version,
BaseName: extensionBaseName,
Binaries: bins,
}
json, err := json.MarshalIndent(squashSpec, "", " ")
lo := contextutils.LoggerFrom(ctx)
if err != nil {
lo.Fatal(err)
}
configOut, err := os.Create(squashConfig)
if err != nil {
lo.Fatal(err)
}
defer configOut.Close()
if _, err := fmt.Fprintf(configOut, string(json)); err != nil {
lo.Fatal(err)
}
}

func MustGetSha(ctx context.Context, path string) string {
file, err := os.Open(path)
defer file.Close()
if err != nil {
contextutils.LoggerFrom(ctx).Fatal(err)
}
sha, err := GenerateSoloSha256(file)
if err != nil {
contextutils.LoggerFrom(ctx).Fatal(err)
}
return sha
}

// TODO(mitchdraft) get this from go-utils
// GenerateSoloSha256 produces a sha256 hash of the given file in a standard way
// for use in Solo.io's build artifact management.
func GenerateSoloSha256(file *os.File) (string, error) {
h := sha256.New()
if _, err := io.Copy(h, file); err != nil {
return "", err
}
return fmt.Sprintf("%v %v\n", hex.EncodeToString(h.Sum(nil)), filepath.Base(file.Name())), nil
}
58 changes: 8 additions & 50 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ steps:
- 'PROJECT_ROOT=github.com/solo-io/squash'
- 'GOPATH=/workspace/gopath'
dir: './gopath/src/github.com/solo-io/squash'
entrypoint: make
entrypoint: 'make'
args: ['check-format']
waitFor: ['dep']
id: 'check-format'
Expand All @@ -53,8 +53,6 @@ steps:
waitFor: ['get-creds']
id: 'check-code-and-docs-gen'



- name: 'gcr.io/cloud-builders/docker'
entrypoint: 'bash'
args: ['-c', 'docker login quay.io --username "solo-io+solobot" --password $$QUAY_IO_PASSWORD']
Expand All @@ -70,66 +68,26 @@ steps:
- 'BUILD_ID=$BUILD_ID'
- 'GCLOUD_PROJECT_ID=$PROJECT_ID'
dir: './gopath/src/github.com/solo-io/squash'
waitFor: ['check-code-and-docs-gen']
waitFor: ['docker-login', 'check-code-and-docs-gen']
id: 'compile'

- name: 'gcr.io/$PROJECT_ID/go-make'
args: ['docker-push', 'upload-github-release-assets', 'push-docs']
- name: 'gcr.io/$PROJECT_ID/go-vsce:0.1.3'
entrypoint: make
args: ['docker-push', 'upload-github-release-assets', 'push-docs', 'publish-extension']
env:
- 'TAGGED_VERSION=$TAG_NAME'
- 'PROJECT_ROOT=github.com/solo-io/squash'
- 'GOPATH=/workspace/gopath'
dir: './gopath/src/github.com/solo-io/squash'
secretEnv: ['GITHUB_TOKEN']
secretEnv: ['GITHUB_TOKEN', 'VSCODE_TOKEN']
id: 'release'
waitFor: ['compile']

# - name: 'gcr.io/cloud-builders/docker'
# env:
# # - VERSION=$TAG_NAME
# entrypoint: make
# args: ['containers']

# - name: 'gcr.io/$PROJECT_ID/vsce'
# env:
# - VERSION=$TAG_NAME
# entrypoint: make
# args: ['bump-extension-version']

# - name: node:10.10.0
# entrypoint: npm
# args: ['install']
# dir: ./extension/vscode

# - name: 'gcr.io/$PROJECT_ID/vsce'
# args: ['package']
# dir: ./extension/vscode

# # publish
# - name: 'gcr.io/cloud-builders/docker'
# env:
# - VERSION=$TAG_NAME
# entrypoint: make
# args: ['push-containers']

# - name: 'gcr.io/$PROJECT_ID/go-make'
# env:
# - VERSION=$TAG_NAME
# entrypoint: make
# args: ['upload-release']
# secretEnv: ['GITHUB_TOKEN']

# TODO(mitchdraft) enable vscode publish
#- name: 'gcr.io/$PROJECT_ID/vsce'
# entrypoint: ./hack/publish-extension.sh
# secretEnv: ['VSCODE_TOKEN']

secrets:
- kmsKeyName: projects/solo-public/locations/global/keyRings/build/cryptoKeys/build-key
secretEnv:
GITHUB_TOKEN: CiQABlzmSYYiveU0gTxGH2139eaBUedjV3vNCxQmJU+nRPlfQ/YSUQCCPGSGzbGp49fwDYuefAx9V94b8mivdp9AqB7zQAa07VtGJmrGdg9ZuhKGFrrgqxwABE0LLVNHyngCSHYSYMH8Vn/mRtT7wQuEHBlKVGtqPw==
QUAY_IO_PASSWORD: CiQABlzmSRx5TcOqbldXa/d/+bkmAfpNAWa3PTS06WvuloZL+vASaQCCPGSGCogonVZVEUNx4G3YJtWi18gSuNx4PvLe08q8xAflTMFkjsyQirAOK3Y2oCvgYwiw/ITcuydjkpMjxDygFyENXS9FKFJoAXHlPQE5qidKr8xxmxF5ezhmjGB0gjyjXIIkbSEnBg==
## uncomment when extension is ready
# VSCODE_TOKEN: CiQABlzmSepRzBG6r2UapqKVaJfx5X3PQgWpuKtIinDWI4IpZsASXQCCPGSGtYjgB1ARs6VcRy3J23Mlbo7zeqPamti48qk71axnOBu4pSomCTKj+4iB81E/dgJEmo9aXOIfPoSv7jEs1ijN7J326jA+AOS1M4eUQwfAWovUtmjecP0p+Q==
VSCODE_TOKEN: CiQABlzmSepRzBG6r2UapqKVaJfx5X3PQgWpuKtIinDWI4IpZsASXQCCPGSGtYjgB1ARs6VcRy3J23Mlbo7zeqPamti48qk71axnOBu4pSomCTKj+4iB81E/dgJEmo9aXOIfPoSv7jEs1ijN7J326jA+AOS1M4eUQwfAWovUtmjecP0p+Q==

timeout: 1800s
timeout: 3000s
Loading

0 comments on commit e77c988

Please sign in to comment.