Skip to content

Commit 37bae7c

Browse files
daily only runs
1 parent 70201cd commit 37bae7c

File tree

7 files changed

+250
-67
lines changed

7 files changed

+250
-67
lines changed

opt/bin/install_snowsql.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
VERSION="1.4.3"
4+
os="$(uname -s)"; arch="$(uname -m)"
5+
case "$os" in
6+
Darwin) platform="darwin"; ext="pkg" ;;
7+
Linux) platform="linux"; ext="bash" ;;
8+
*) echo "Unsupported OS: $os" >&2; exit 1 ;;
9+
esac
10+
case "$arch" in
11+
x86_64|amd64) arch="x86_64" ;;
12+
arm64|aarch64) arch="arm64" ;;
13+
*) echo "Unsupported arch: $arch" >&2; exit 1 ;;
14+
esac
15+
16+
PLATFORM="${platform}_${arch}"
17+
BASE="https://sfc-repo.snowflakecomputing.com/snowsql/bootstrap/${VERSION}/${PLATFORM}"
18+
SIG_FILE="snowsql-${VERSION}-${PLATFORM}.${ext}.sig"
19+
BASH_FILE="snowsql-${VERSION}-${PLATFORM}.${ext}"
20+
21+
22+
curl -fSLo "$SIG_FILE" "${BASE}/${SIG_FILE}"
23+
curl -fSLo "$BASH_FILE" "${BASE}/${BASH_FILE}"
24+
25+
chmod +x "$SIG_FILE"
26+
chmod +x "$BASH_FILE"
27+
28+
gpg --verify "$SIG_FILE" "$BASH_FILE" || exit 1
29+
SNOWSQL_DEST=~/opt/bin SNOWSQL_LOGIN_SHELL=~/.profile bash "$BASH_FILE"
30+
31+
32+
33+
34+

opt/profiles/.bash_aliases

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ if [ -f ~/.custom_alias ] ; then
158158
fi
159159

160160
if [ -f ~/opt/bin/tmuxinator.zsh ] ; then
161-
source opt/bin/tmuxinator.zsh
161+
source ~/opt/bin/tmuxinator.zsh
162162
fi
163163

164164
alias ecr-login='eval $(aws ecr get-login --no-include-email)'
@@ -216,10 +216,8 @@ fi
216216
if [ -f /Applications/SnowSQL.app/Contents/MacOS/snowsql ]; then
217217
alias snowsql=/Applications/SnowSQL.app/Contents/MacOS/snowsql
218218
fi
219-
220-
# install snow cli (skip version check in editor terminals to avoid slowdown)
221-
if [[ "$EDITOR_TERMINAL" != "true" ]]; then
222-
snow --version || ( pip3 install --upgrade pip && python -m pip install snowflake-cli-labs )
219+
if [ -f ~/opt/bin/snowsql ]; then
220+
alias snowsql=~/opt/bin/snowsql
223221
fi
224222
export GOPRIVATE=github.com/snowflakedb/*
225223
alias cursor='/Applications/Cursor.app/Contents/MacOS/Cursor'
@@ -247,39 +245,54 @@ EOF
247245

248246
function sfcode() {
249247
local NAME="gco2"
250-
local DIR=~/github/snowflakedb/release-orchestration-service
251-
local NO_CUSTOMIZATION=
252-
local ROCKY9=--os rocky9
248+
local DIR="~/github/snowflakedb/release-orchestration-service"
249+
local IDE="cursor"
253250

254251
while [[ $# -gt 0 ]]; do
255252
case "$1" in
253+
-h)
254+
sfhelp
255+
return 0
256+
;;
256257
-d)
257258
DIR="$2"
258259
shift 2
259260
;;
261+
-i)
262+
IDE="$2"
263+
shift 2
264+
;;
260265
*)
261266
NAME="$1"
262267
shift
263268
;;
264269
esac
265270
done
266271

267-
sf ws code ${NAME} --dir ${DIR} --ide cursor
272+
echo "sf ws code ${NAME} --dir ${DIR} --ide ${IDE}"
273+
eval sf ws code ${NAME} --dir ${DIR} --ide ${IDE}
268274
}
269275

270276
function sfcreate() {
277+
if [[ "${DEBUG}" = "true" ]]; then
278+
set -x -v;
279+
fi
271280
local NAME="gco2"
272281
local NO_CUSTOMIZATION=
273-
local ROCKY9=--os rocky9
274-
282+
local ROCKY9="--os rocky9"
283+
275284
while [[ $# -gt 0 ]]; do
276285
case "$1" in
286+
-h)
287+
sfhelp
288+
return 0
289+
;;
277290
-nr)
278-
ROCKY9=
291+
ROCKY9=""
279292
shift
280293
;;
281294
-nc)
282-
NO_CUSTOMIZATION=--customization off
295+
NO_CUSTOMIZATION="--customization off"
283296
shift
284297
;;
285298
*)
@@ -288,9 +301,25 @@ function sfcreate() {
288301
;;
289302
esac
290303
done
291-
292-
sf ws create ${ROCKY9} --name ${NAME} ${NO_CUSTOMIZATION}
304+
echo "using name = ${NAME}"
305+
306+
echo "sf ws create --name ${NAME} ${NO_CUSTOMIZATION} ${ROCKY9}"
307+
eval sf ws create --name ${NAME} ${NO_CUSTOMIZATION} ${ROCKY9}
308+
eval sf ws ssh ${NAME}
293309
}
294310

295311
alias sfssh='sf ws ssh'
296312
alias sfls='sf ws ls'
313+
314+
function tmux4() {
315+
tmux new-session -s dev \; \
316+
split-window -h \; \
317+
split-window -v \; \
318+
select-pane -t 0 \; \
319+
split-window -v \; \
320+
select-layout tiled \; \
321+
attach
322+
}
323+
alias tdev='tmux attach -t dev'
324+
gorun() { local f=$(mktemp -t gorun-XXXX).go; cat >"$f"; go run "$f"; rm "$f"; }
325+
alias avalanche_up='GODEBUG="x509ignoreCN=0" go run ./cmd/avaServer -yes-i-really-want-to-disable-authentication -mig-bypass-sha256 -overridedb 127.0.0.1'

opt/profiles/.bashrc

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,52 @@ else
77
export EDITOR_TERMINAL=false
88
fi
99

10+
# Daily maintenance (bash) - align with zsh once-per-day behavior
11+
DOTFILES_DAILY_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/dotfiles"
12+
DOTFILES_DAILY_STAMP_FILE="${DOTFILES_DAILY_CACHE_DIR}/daily_maintenance.stamp"
13+
dotfiles_should_run_daily() {
14+
[ -d "${DOTFILES_DAILY_CACHE_DIR}" ] || mkdir -p "${DOTFILES_DAILY_CACHE_DIR}"
15+
[ -f "${DOTFILES_DAILY_STAMP_FILE}" ] || return 0
16+
local now mtime
17+
now=$(date +%s)
18+
if mtime=$(stat -f %m "${DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null); then
19+
:
20+
else
21+
mtime=$(stat -c %Y "${DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null || echo 0)
22+
fi
23+
[ $(( now - mtime )) -ge 86400 ]
24+
}
25+
dotfiles_touch_daily() {
26+
: > "${DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null || touch "${DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null
27+
}
28+
dotfiles_run_daily_maintenance() {
29+
# Pull the latest repos
30+
if [ -f "${HOME}/.gitrepos" ] ; then
31+
(
32+
cd "${HOME}" || exit 0
33+
[ -d "${HOME}/.git" ] && \
34+
git pull origin "$(git branch | grep '*' | awk '{print $2}')" 2>/dev/null
35+
"${HOME}/.gitrepos"
36+
)
37+
fi
38+
# Load SF aliases (can be slow)
39+
if command -v sf >/dev/null 2>&1 ; then
40+
eval "$(sf aliases)"
41+
fi
42+
}
43+
if [[ "$EDITOR_TERMINAL" == "false" ]]; then
44+
if dotfiles_should_run_daily; then
45+
dotfiles_touch_daily
46+
dotfiles_run_daily_maintenance &
47+
fi
48+
fi
49+
1050
# Skip debug output in editor terminals
1151
if [[ "$EDITOR_TERMINAL" == "false" ]]; then
1252
echo executing bashrc
1353
fi
1454

15-
# Pull the latest repos (skip in editor terminals for faster startup)
16-
if [[ "$EDITOR_TERMINAL" == "false" ]] && [ -f "${HOME}/.gitrepos" ] ; then
17-
cd "${HOME}"
18-
[ -d "${HOME}/.git" ] && \
19-
git pull origin $(git branch | grep '*'|awk '{print $2}')
20-
"${HOME}/.gitrepos"
21-
fi
55+
# Expensive repo update moved to daily maintenance above
2256

2357
if [ -f ~/.bash_aliases ]; then
2458
. ~/.bash_aliases
@@ -200,10 +234,5 @@ if [ -f /home/linuxbrew/.linuxbrew/bin/brew ] ; then
200234
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
201235
fi
202236

203-
# Load SF aliases conditionally
204-
if command -v sf &> /dev/null; then
205-
if [[ "$EDITOR_TERMINAL" == "false" ]]; then
206-
eval "$(sf aliases)"
207-
fi
208-
fi
237+
# SF aliases load moved to daily maintenance above
209238

opt/profiles/.goenv.sh

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,26 @@ else
77
export EDITOR_TERMINAL=false
88
fi
99

10+
# Daily maintenance cache for expensive goenv/go tool operations
11+
__DOTFILES_DAILY_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/dotfiles"
12+
__DOTFILES_DAILY_STAMP_FILE="${__DOTFILES_DAILY_CACHE_DIR}/daily_maintenance.stamp"
13+
__dotfiles_should_run_daily() {
14+
[ -d "${__DOTFILES_DAILY_CACHE_DIR}" ] || mkdir -p "${__DOTFILES_DAILY_CACHE_DIR}"
15+
[ -f "${__DOTFILES_DAILY_STAMP_FILE}" ] || return 0
16+
local now mtime
17+
now=$(date +%s)
18+
# macOS uses stat -f, Linux uses stat -c
19+
if mtime=$(stat -f %m "${__DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null); then
20+
:
21+
else
22+
mtime=$(stat -c %Y "${__DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null || echo 0)
23+
fi
24+
[ $(( now - mtime )) -ge 86400 ]
25+
}
26+
__dotfiles_touch_daily() {
27+
: > "${__DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null || touch "${__DOTFILES_DAILY_STAMP_FILE}" 2>/dev/null
28+
}
29+
1030
if [[ -d $HOME/.goenv ]]; then
1131
export PATH=$HOME/.goenv/bin:$PATH
1232
fi
@@ -18,8 +38,12 @@ if [[ "$(uname -r | awk -F'-' '{print $3}')" = "Microsoft" ]] ; then
1838
fi
1939

2040
# requires brew install goenv
21-
if [[ "$EDITOR_TERMINAL" == "false" ]] || ! command -v goenv >/dev/null 2>&1; then
22-
goenv install latest --skip-existing
41+
# Install/ensure latest Go version at most once per day in non-editor terminals
42+
if [[ "$EDITOR_TERMINAL" == "false" ]]; then
43+
if __dotfiles_should_run_daily; then
44+
__dotfiles_touch_daily
45+
command -v goenv >/dev/null 2>&1 && goenv install latest --skip-existing
46+
fi
2347
fi
2448
eval "$(goenv init -)"
2549

@@ -35,33 +59,41 @@ if [[ "$EDITOR_TERMINAL" == "true" ]]; then
3559
return
3660
fi
3761

38-
echo "GOENV_VERSION => ${GOENV_VERSION}"
39-
echo "GO_BINARY => ${GO_BINARY}"
40-
echo "GO_BINPATH => ${GO_BINPATH}"
41-
42-
# install some go command line tools
43-
go install github.com/bazelbuild/buildtools/buildifier@latest
44-
go install golang.org/x/tools/gopls@latest
45-
go install github.com/go-delve/delve/cmd/dlv@latest
46-
47-
# verify we have the tools
48-
# Check if tools are installed and working
49-
if command -v buildifier >/dev/null 2>&1; then
50-
echo "✓ buildifier $(buildifier --version) is installed"
51-
else
52-
echo "✗ buildifier is not installed properly"
53-
fi
62+
export GOTOOLCHAIN="go${GOENV_VERSION}"
5463

55-
if command -v gopls >/dev/null 2>&1; then
56-
echo "✓ gopls $(gopls version) is installed"
57-
else
58-
echo "✗ gopls is not installed properly"
64+
echo "GOENV_VERSION => ${GOENV_VERSION}"
65+
echo "GOTOOLCHAIN => ${GOTOOLCHAIN}"
66+
echo "GO_BINARY => ${GO_BINARY}"
67+
echo "GO_BINPATH => ${GO_BINPATH}"
68+
echo "GOPATH => ${GOPATH}"
69+
70+
71+
# install some go command line tools (once per day)
72+
if __dotfiles_should_run_daily; then
73+
__dotfiles_touch_daily
74+
go install github.com/bazelbuild/buildtools/buildifier@latest
75+
go install golang.org/x/tools/gopls@latest
76+
go install github.com/go-delve/delve/cmd/dlv@latest
5977
fi
6078

61-
if command -v dlv >/dev/null 2>&1; then
62-
echo "✓ delve $(dlv version) is installed"
63-
else
64-
echo "✗ delve debugger is not installed properly"
79+
# verify we have the tools (quiet outside of daily run)
80+
if __dotfiles_should_run_daily; then
81+
# Check if tools are installed and working
82+
if command -v buildifier >/dev/null 2>&1; then
83+
echo "✓ buildifier $(buildifier --version) is installed"
84+
else
85+
echo "✗ buildifier is not installed properly"
86+
fi
87+
if command -v gopls >/dev/null 2>&1; then
88+
echo "✓ gopls $(gopls version) is installed"
89+
else
90+
echo "✗ gopls is not installed properly"
91+
fi
92+
if command -v dlv >/dev/null 2>&1; then
93+
echo "✓ delve $(dlv version) is installed"
94+
else
95+
echo "✗ delve debugger is not installed properly"
96+
fi
6597
fi
6698

6799
if command -v go >/dev/null 2>&1; then

opt/profiles/.profile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ fi
135135

136136
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
137137
alias bazel='bazelisk'
138+
139+
# added by Snowflake SnowSQL installer
140+
export PATH=/Users/eraigosa/opt/bin:$PATH

0 commit comments

Comments
 (0)