Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mise.devbase.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
[tools]
"aqua:fullstorydev/grpcui" = "1.3.1"
github-cli = "2.83.2"
"go:github.com/go-delve/delve/cmd/dlv" = "1.26.0"
"go:github.com/mattn/goveralls" = "0.0.11"
## Sync with templates/scripts/devbase.sh.tpl
gojq = "0.12.18"
gotestsum = "1.13.0"
mage = "1.14.0"
"github:getoutreach/ci" = "1.6.14"
# linters
buf = "1.60.0"
go-jsonnet = "0.19.1"
gofumpt = "0.9.2"
golangci-lint = "2.8.0"
kubeconform = "0.6.4"
shellcheck = "0.11.0"
shfmt = "3.7.0"
"github:getoutreach/lintroller" = "1.19.0"
Expand Down
10 changes: 2 additions & 8 deletions scripts/bash-test-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
DEVBASE_LIB_DIR="$DIR/../shell/lib"

# shellcheck source=../shell/lib/bootstrap.sh
source "$DEVBASE_LIB_DIR/bootstrap.sh"
# shellcheck source=../shell/lib/logging.sh
source "$DEVBASE_LIB_DIR/logging.sh"
# shellcheck source=../shell/lib/mise.sh
source "$DEVBASE_LIB_DIR/mise.sh"
# shellcheck source=../shell/lib/shell.sh
source "$DEVBASE_LIB_DIR/shell.sh"
# shellcheck source=../shell/lib/mise/stub.sh
source "$DEVBASE_LIB_DIR/mise/stub.sh"

# Check if the bats test helpers are installed and usable.
if [[ ! -f "$DIR/bats/test_helper/bats-assert/load.bash" ]]; then
Expand Down
17 changes: 8 additions & 9 deletions shell/ci/testing/coveralls/upload-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
# Uploads code coverage to coveralls.io
#
# Note: This is not meant to be called outside of coverage.sh
set -e
set -euo pipefail

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
SHELL_DIR="$DIR/../../.."
LIB_DIR="$SHELL_DIR/lib"
LIB_DIR="$DIR/../../../lib"

# shellcheck source=../../../lib/bootstrap.sh
source "${LIB_DIR}/bootstrap.sh"
# shellcheck source=../../../lib/mise/stub.sh
source "${LIB_DIR}/mise/stub.sh"

coverage_file="$1"
flag_name="$2"

if [[ -n $COVERALLS_TOKEN && -f $coverage_file ]]; then
if [[ -n ${COVERALLS_TOKEN:-} && -f $coverage_file ]]; then
extra_args=()
if [[ -n $flag_name ]]; then
extra_args+=("-parallel" "-flagname" "$flag_name")
fi

exec "$SHELL_DIR/gobin.sh" "github.com/mattn/goveralls@v$(get_tool_version "goveralls")" \
-coverprofile="$coverage_file" -service=circle-ci -jobid="$CIRCLE_WORKFLOW_ID" \
-repotoken="$COVERALLS_TOKEN" "${extra_args[@]}"
mise_exec_tool_with_bin "go:github.com/mattn/goveralls" goveralls \
-coverprofile="$coverage_file" -service=circle-ci -jobid="${CIRCLE_WORKFLOW_ID:-}" \
-repotoken="${COVERALLS_TOKEN:-}" "${extra_args[@]}"
fi
2 changes: 1 addition & 1 deletion shell/golangci-lint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This is a wrapper around mise to run golangci-lint.
# This is a wrapper around `mise` to run `golangci-lint`.
# Useful for using the correct version of golangci-lint
# with your editor.

Expand Down
21 changes: 10 additions & 11 deletions shell/grpcui.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
#!/usr/bin/env bash
# GRPCUI wrapper
# gRPC UI wrapper

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
GOBIN="$DIR/gobin.sh"

# shellcheck source=./lib/bootstrap.sh
source "$DIR/lib/bootstrap.sh"
# shellcheck source=./lib/mise/stub.sh
source "$DIR/lib/mise/stub.sh"

# We set -plaintext here because we don't use GRPC TLS
# We set -plaintext here because we don't use gRPC TLS
args=("-plaintext" "$@")

# check if the grpcui command failes and if so echo error message
if ! "$GOBIN" "github.com/fullstorydev/grpcui/cmd/grpcui@v$(get_application_version "grpcui")" "${args[@]}"; then
echo
echo 'this expects your service to either be running locally or have port forward running.
to port forward:
- deploy to devenv (i.e. "devenv app deploy .")
# check if the grpcui command fails and if so echo error message
if ! mise_exec_tool_with_bin "aqua:fullstorydev/grpcui" grpcui "${args[@]}"; then
echo >&2
fatal 'This expects your service to either be running locally or have port forward running.
To port forward:
- deploy to devenv (i.e. "devenv apps run")
- run "kubectl port-forward service/[SERVICE-NAME] 5000:5000 -n [NAMESPACE]"'
fi
17 changes: 17 additions & 0 deletions shell/lib/mise.sh
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ mise_exec_tool_with_bin() {
fi
}

# xargs_mise_exec_tool_with_bin is a helper function that runs `mise exec` with xargs.
# Only used when a tool doesn't need its own wrapper script.
xargs_mise_exec_tool_with_bin() {
ensure_mise_installed

local maxArgs="$1"
shift
local tool="$1"
shift
local toolVersion
toolVersion="$(devbase_tool_version_from_mise "$tool")"
local mise
mise="$(find_mise)"

xargs -n "$maxArgs" "$mise" exec "$tool@$toolVersion" -- "$@"
}

asdf_shim_dir() {
echo "${ASDF_DIR:-$HOME/.asdf}/shims"
}
Expand Down
6 changes: 2 additions & 4 deletions shell/linters/jsonnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
extensions=(jsonnet libsonnet)

jsonnetfmt() {
# Why: We're OK with this.
# shellcheck disable=SC2155
local JSONNETFMT=$("$DIR/gobin.sh" -p github.com/google/go-jsonnet/cmd/jsonnetfmt@v"$(get_application_version "jsonnetfmt")")
find_files_with_extensions "${extensions[@]}" | xargs -n40 "$JSONNETFMT" -i
find_files_with_extensions "${extensions[@]}" |
xargs_mise_exec_tool_with_bin 40 go-jsonnet jsonnetfmt -i
}

linter() {
Expand Down
20 changes: 6 additions & 14 deletions shell/linters/kubecfg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,32 @@
# Ensure that deployments, if they exist, are able to be rendered by
# kubecfg and are valid Kubernetes manifests.

# shellcheck source=../lib/bootstrap.sh
source "$DIR/lib/bootstrap.sh"

BUILDJSONNETPATH="$DIR/build-jsonnet.sh"
KUBECONFORM=("$DIR/gobin.sh" github.com/yannh/kubeconform/cmd/kubeconform@v0.6.4)

# Why: Used by the script that calls us
# shellcheck disable=SC2034
extensions=(jsonnet)

appName="${DEVENV_DEPLOY_APPNAME:-$(get_app_name)}"

kubernetesVersion=$(get_tool_version kubernetes)

kubecfg_kubeconform() {
if [[ ! -f "$(get_repo_directory)/$(deployment_source_path "$appName")/$(deployment_manifest_path "$appName")" ]]; then
echo "No jsonnet to be validated, skipping" >&2
info "No jsonnet to be validated, skipping" >&2
return 0
fi

tempFile=$(mktemp)
if ! "$BUILDJSONNETPATH" show >"$tempFile"; then
echo "Failed to render jsonnet" >&2
if ! "$DIR/build-jsonnet.sh" show >"$tempFile"; then
error "Failed to render jsonnet"
return 1
fi

if ! "${KUBECONFORM[@]}" \
if ! mise_exec_tool kubeconform \
-schema-location default \
-ignore-missing-schemas \
-strict \
-kubernetes-version "$kubernetesVersion" \
-kubernetes-version "$(get_tool_version kubernetes)" \
-schema-location 'https://raw.githubusercontent.com/datreeio/CRDs-catalog/main/{{.Group}}/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json' \
<"$tempFile"; then
echo "Failed to validate generated yaml" >&2
error "Failed to validate generated YAML"
return 1
fi
}
Expand Down
6 changes: 4 additions & 2 deletions shell/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ source "$DIR/lib/bootstrap.sh"
# shellcheck source=./lib/logging.sh
source "$DIR/lib/logging.sh"

# shellcheck source=./lib/mise.sh
source "$DIR/lib/mise.sh"

# shellcheck source=./lib/shell.sh
source "$DIR/lib/shell.sh"

Expand Down Expand Up @@ -191,10 +194,9 @@ if [[ "$(git ls-files '*_test.go' | wc -l | tr -d ' ')" -gt 0 ]]; then
else
exitCode=0

GOTESTSUMPATH=$("$DIR/gobin.sh" -p gotest.tools/gotestsum@v"$(get_application_version "gotestsum")")
(
set -x
"$GOTESTSUMPATH" --junitfile "$REPODIR/bin/unit-tests.xml" --format "$format" -- \
mise_exec_tool gotestsum --junitfile "$REPODIR/bin/unit-tests.xml" --format "$format" -- \
"${BENCH_FLAGS[@]}" "${COVER_FLAGS[@]}" "${TEST_FLAGS[@]}" \
-ldflags "-X github.com/getoutreach/go-outreach/v2/pkg/app.Version=testing -X github.com/getoutreach/gobox/pkg/app.Version=testing" \
-tags="$test_tags_string" "$@" "${TEST_PACKAGES[@]}"
Expand Down
6 changes: 1 addition & 5 deletions versions.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
grpcui: 1.3.1
jsonnetfmt: 0.19.1
gotestsum: 1.10.1
goveralls: 0.0.11
getoutreach/ci: v1.6.14
getoutreach/logfmt: v1.1.0

Expand All @@ -24,5 +20,5 @@ protoc-gen-go-grpc: cmd/protoc-gen-go-grpc/v1.3.0
getoutreach/markdowntools/visualizemd: v0.0.33
kovetskiy/mark: 8.8

# kubeconform
# For kubeconform parameter
kubernetes: 1.25.16