99 sh : nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo "4"
1010 PARALLEL_COUNT :
1111 sh : echo $(({{.CPU_COUNT}} * 2))
12- TERO_ENV : ' {{.TERO_ENV | default "local"}}'
13- # Wrap commands with doppler for non-local environments.
14- ENV_PREFIX :
15- sh : |
16- if [ "{{.TERO_ENV}}" = "local" ]; then
17- echo ""
18- else
19- echo "doppler run -c {{.TERO_ENV}} --"
20- fi
2112
2213tasks :
2314 # ===========================================================================
@@ -121,6 +112,16 @@ tasks:
121112 desc : Validate build
122113 cmds :
123114 - go vet ./...
115+ - task : check:task-run-env
116+
117+ check:task-run-env :
118+ desc : Validate task run env wiring for local and prd
119+ cmds :
120+ - |
121+ RUN_CMD="$(TERO_ENV=prd task -n run 2>&1 | tail -n 1)"
122+ echo "$RUN_CMD" | rg './scripts/with-env.sh go run ./cmd/tero' >/dev/null
123+ rg 'env_name="\$\{TERO_ENV:-local\}"' ./scripts/with-env.sh >/dev/null
124+ rg 'exec doppler run -c "\$env_name" -- "\$@"' ./scripts/with-env.sh >/dev/null
124125
125126 # ===========================================================================
126127 # Testing
@@ -134,22 +135,22 @@ tasks:
134135 test:integration :
135136 desc : Run integration tests (TERO_ENV=dev|prd)
136137 cmds :
137- - ' {{.ENV_PREFIX}} gotestsum --format short-verbose -- -race -tags=integration -run "^TestIntegration_" ./...'
138+ - ' ./scripts/with-env.sh gotestsum --format short-verbose -- -race -tags=integration -run "^TestIntegration_" ./...'
138139
139140 test:correctness :
140141 desc : Run correctness tests (TERO_ENV=dev|prd)
141142 cmds :
142- - ' {{.ENV_PREFIX}} gotestsum --format short-verbose -- -v -tags=correctness -run "^TestCorrectness_" ./...'
143+ - ' ./scripts/with-env.sh gotestsum --format short-verbose -- -v -tags=correctness -run "^TestCorrectness_" ./...'
143144
144145 test:correctness:powersync-replay :
145146 desc : Run deterministic PowerSync fixture replay correctness test
146147 cmds :
147148 - |
148149 if [ -n "{{.FIXTURE}}" ]; then
149- TERO_POWERSYNC_FIXTURE_PATH="{{.FIXTURE}}" {{.ENV_PREFIX}} gotestsum --format short-verbose -- \
150+ TERO_POWERSYNC_FIXTURE_PATH="{{.FIXTURE}}" ./scripts/with-env.sh gotestsum --format short-verbose -- \
150151 -v -tags=correctness -run "^TestCorrectness_PowerSync_ControllerFixtureReplayDeterministic$" ./internal/powersync/extension
151152 else
152- {{.ENV_PREFIX}} gotestsum --format short-verbose -- \
153+ ./scripts/with-env.sh gotestsum --format short-verbose -- \
153154 -v -tags=correctness -run "^TestCorrectness_PowerSync_ControllerFixtureReplayDeterministic$" ./internal/powersync/extension
154155 fi
155156
@@ -166,7 +167,7 @@ tasks:
166167 run :
167168 desc : Run tero (TERO_ENV=local|dev|prd)
168169 cmds :
169- - " {{.ENV_PREFIX}} go run ./cmd/tero {{.CLI_ARGS}}"
170+ - " ./scripts/with-env.sh go run ./cmd/tero {{.CLI_ARGS}}"
170171
171172 dev :
172173 desc : Generate code and build
@@ -177,22 +178,22 @@ tasks:
177178 auth:login :
178179 desc : Login to Tero (TERO_ENV=local|dev|prd)
179180 cmds :
180- - " {{.ENV_PREFIX}} go run ./cmd/tero auth login"
181+ - " ./scripts/with-env.sh go run ./cmd/tero auth login"
181182
182183 auth:token :
183184 desc : Print current access token (TERO_ENV=local|dev|prd)
184185 cmds :
185- - " {{.ENV_PREFIX}} go run ./cmd/tero auth token"
186+ - " ./scripts/with-env.sh go run ./cmd/tero auth token"
186187
187188 auth:status :
188189 desc : Show auth status (TERO_ENV=local|dev|prd)
189190 cmds :
190- - " {{.ENV_PREFIX}} go run ./cmd/tero auth status"
191+ - " ./scripts/with-env.sh go run ./cmd/tero auth status"
191192
192193 auth:switch :
193194 desc : Switch organization (TERO_ENV=local|dev|prd)
194195 cmds :
195- - " {{.ENV_PREFIX}} go run ./cmd/tero auth switch {{.CLI_ARGS}}"
196+ - " ./scripts/with-env.sh go run ./cmd/tero auth switch {{.CLI_ARGS}}"
196197
197198 internal:powersync:capture :
198199 desc : Capture raw PowerSync stream to NDJSON (TERO_ENV=dev|prd)
@@ -202,7 +203,7 @@ tasks:
202203 MAX_BYTES : ' {{.MAX_BYTES | default "26214400"}}'
203204 cmds :
204205 - |
205- CMD="{{.ENV_PREFIX}} go run ./cmd/tero internal powersync capture --output {{.OUTPUT}} --duration {{.DURATION}} --max-bytes {{.MAX_BYTES}}"
206+ CMD="./scripts/with-env.sh go run ./cmd/tero internal powersync capture --output {{.OUTPUT}} --duration {{.DURATION}} --max-bytes {{.MAX_BYTES}}"
206207 if [ -n "{{.ACCOUNT_ID}}" ]; then
207208 CMD="$CMD --account-id {{.ACCOUNT_ID}}"
208209 fi
@@ -216,7 +217,7 @@ tasks:
216217 echo "INPUT and OUTPUT are required"
217218 exit 1
218219 fi
219- CMD="{{.ENV_PREFIX}} go run ./cmd/tero internal powersync sanitize-fixture --input {{.INPUT}} --output {{.OUTPUT}}"
220+ CMD="./scripts/with-env.sh go run ./cmd/tero internal powersync sanitize-fixture --input {{.INPUT}} --output {{.OUTPUT}}"
220221 if [ -n "{{.MAX_LINES}}" ]; then
221222 CMD="$CMD --max-lines {{.MAX_LINES}}"
222223 fi
@@ -229,12 +230,12 @@ tasks:
229230 admin:join-org :
230231 desc : Join a client organization (TERO_ENV=dev|prd)
231232 cmds :
232- - " {{.ENV_PREFIX}} go run ./cmd/admin join-org {{.CLI_ARGS}}"
233+ - " ./scripts/with-env.sh go run ./cmd/admin join-org {{.CLI_ARGS}}"
233234
234235 admin:leave-org :
235236 desc : Leave a client organization (TERO_ENV=dev|prd)
236237 cmds :
237- - " {{.ENV_PREFIX}} go run ./cmd/admin leave-org {{.CLI_ARGS}}"
238+ - " ./scripts/with-env.sh go run ./cmd/admin leave-org {{.CLI_ARGS}}"
238239
239240 # ===========================================================================
240241 # Dependencies
0 commit comments