-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJustfile
More file actions
183 lines (148 loc) · 5.54 KB
/
Justfile
File metadata and controls
183 lines (148 loc) · 5.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Test and build all
all: deps check test build
# Check all
[group('check')]
check: check-python-pulumi
# Format all
[group('format')]
format: format-python-pulumi
alias fmt := format
# Build all
[group('build')]
build: cli
# Test all
[group('test')]
test: test-python-pulumi test-lib test-cmd
# Run the ptd CLI
ptd *ARGS:
cd {{ justfile_directory() }}/cmd && go run . {{ARGS}}
write-kubeconfig cluster_dir=invocation_directory() kubeconfig='./kubeconfig':
#!/usr/bin/env bash
set -o errexit
set -o pipefail
CLUSTER_RELEASE="$(basename '{{ cluster_dir }}')"
CLUSTER_RELEASE="${CLUSTER_RELEASE##cluster_}"
WORKLOAD="$(basename "$(dirname '{{ cluster_dir }}')")"
cd {{ invocation_directory() }}
aws eks update-kubeconfig \
--name="default_${WORKLOAD}-${CLUSTER_RELEASE}-control-plane" \
--kubeconfig='{{ kubeconfig }}' \
--alias="${WORKLOAD}-${CLUSTER_RELEASE}"
# ----------------------------------------------------------------------------
# ensure git is set up to use ssh
git-ssh:
#!/bin/bash
set -xe
if [ ! -e "$HOME/.gitconfig" ] || [ ! "$(grep $HOME/.gitconfig -e 'url "ssh://git@github.com"')" ]; then
echo -e '[url "ssh://git@github.com"]\n\tinsteadOf = https://github.com' >> $HOME/.gitconfig
fi;
# unset all aws variables
aws-unset:
unset AWS_DEFAULT_PROFILE
unset AWS_DEFAULT_REGION
unset AWS_SESSION_TOKEN
unset AWS_SECRET_ACCESS_KEY
unset AWS_ACCESS_KEY_ID
############################################################################
# Setup and dependencies
############################################################################
alias link-bins := symlink-binaries
deps: python-deps check-session-manager-plugin symlink-binaries install-thumbprint install-git-hooks
# install python dependencies (uv handles this automatically, but here if you need it)
python-deps:
uv --directory python-pulumi sync
symlink-binaries:
#!/usr/bin/env bash
binlocal="{{ justfile_directory() }}/.local/bin"
mkdir -p $binlocal
# Create symlinks only if they don't already exist
for binary in aws az pulumi; do
if [ ! -e "$binlocal/$binary" ]; then
ln -sf "$(which $binary)" "$binlocal/$binary"
fi
done
install-thumbprint:
#!/usr/bin/env bash
binlocal="{{ justfile_directory() }}/.local/bin"
mkdir -p $binlocal
CGO_ENABLED=0 GOBIN=$binlocal go install github.com/rstudio/goex/cmd/thumbprint@latest
check-session-manager-plugin:
#!/bin/bash
if ! session-manager-plugin --version &>/dev/null; then
printf '\n# ---> ERROR: missing "session-manager-plugin"\n' >&2
printf '# Please install the AWS Session Manager Plugin:\n#\n' >&2
printf '# https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html\n' >&2
exit 1
fi
# install git hooks via pre-commit (fails silently in CI)
install-git-hooks:
-uvx pre-commit install
############################################################################
# Test targets
############################################################################
[group('test')]
test-python-pulumi *ARGS:
cd {{ justfile_directory() }}/python-pulumi && just test {{ARGS}}
[group('test')]
test-cmd *ARGS:
cd {{ justfile_directory() }}/cmd && go test ./... {{ARGS}}
[group('test')]
test-cmd-cover:
cd {{ justfile_directory() }}/cmd && go test ./... -cover -coverprofile={{ justfile_directory() }}/cmd/coverage.out
[group('test')]
test-lib *ARGS="./...":
cd {{ justfile_directory() }}/lib && go test {{ARGS}}
[group('test')]
test-lib-cover:
cd {{ justfile_directory() }}/lib && go test ./... -cover -coverprofile={{ justfile_directory() }}/lib/coverage.out
[group('test')]
test-e2e URL="":
#!/usr/bin/env bash
set -e
# If URL is provided as argument, use it
if [[ -n "{{ URL }}" ]]; then
# Add https:// if no protocol is specified
TEST_URL="{{ URL }}"
if [[ ! "$TEST_URL" =~ ^https?:// ]]; then
TEST_URL="https://${TEST_URL}"
fi
echo "Running e2e tests against external URL: $TEST_URL"
cd {{ justfile_directory() }}
uv run --project e2e pytest -m "e2e" --base-url="$TEST_URL" ./e2e
exit 0
fi
# If PLAYWRIGHT_TEST_BASE_URL is set, run tests against that URL
if [[ -n "${PLAYWRIGHT_TEST_BASE_URL:-}" ]]; then
echo "Running e2e tests against external URL: $PLAYWRIGHT_TEST_BASE_URL"
cd {{ justfile_directory() }}
uv run --project e2e pytest -m "e2e" --base-url="$PLAYWRIGHT_TEST_BASE_URL" ./e2e
exit 0
fi
# No URL provided - show usage
echo "Error: No URL provided for e2e tests."
echo ""
echo "Usage:"
echo " just test-e2e <url> # Test against a specific URL"
echo " just test-e2e ganso01-staging.posit.team # Example"
echo ""
echo "Or set PLAYWRIGHT_TEST_BASE_URL environment variable."
exit 1
############################################################################
# Build targets
############################################################################
[group('build')]
cli:
mkdir -p .local/bin
goreleaser build --single-target --snapshot --clean -o .local/bin/ptd
#############################################################################
# Check targets
#############################################################################
[group('check')]
check-python-pulumi:
cd {{ justfile_directory() }}/python-pulumi && just check
#############################################################################
# Format targets
#############################################################################
[group('format')]
format-python-pulumi:
cd {{ justfile_directory() }}/python-pulumi && just format