declapract-typescript-ehmpathy 0.47.26 → 0.47.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/practices/cicd-common/best-practice/.agent/repo=.this/role=any/skills/use.apikeys.sh
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
#!/
|
|
1
|
+
#!/bin/sh
|
|
2
2
|
######################################################################
|
|
3
3
|
# .what = export api keys for integration tests
|
|
4
|
-
# .why = enables
|
|
4
|
+
# .why = enables tests that require api keys to run
|
|
5
5
|
#
|
|
6
6
|
# usage:
|
|
7
|
-
#
|
|
7
|
+
# . .agent/repo=.this/role=any/skills/use.apikeys.sh
|
|
8
8
|
#
|
|
9
9
|
# note:
|
|
10
|
-
# - must be called with `source` to export vars to current shell
|
|
10
|
+
# - must be called with `.` or `source` to export vars to current shell
|
|
11
11
|
# - loads from ~/.config/rhachet/apikeys.env if available
|
|
12
12
|
# - falls back to .env.local (gitignored) in repo root
|
|
13
13
|
######################################################################
|
|
14
14
|
|
|
15
|
-
# fail if not sourced
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
# fail if not sourced (check if $0 matches this file)
|
|
16
|
+
case "$0" in
|
|
17
|
+
*use.apikeys.sh)
|
|
18
|
+
echo "error: this file must be sourced, not executed"
|
|
19
|
+
echo "usage: source $0"
|
|
20
|
+
exit 1
|
|
21
|
+
;;
|
|
22
|
+
esac
|
|
23
|
+
|
|
24
|
+
# alias source to `.` for posix compat
|
|
25
|
+
source() { . "$@"; }
|
|
21
26
|
|
|
22
|
-
# try
|
|
23
|
-
if [
|
|
27
|
+
# try to load from user config first
|
|
28
|
+
if [ -f ~/.config/rhachet/apikeys.env ]; then
|
|
24
29
|
source ~/.config/rhachet/apikeys.env
|
|
25
30
|
echo "✓ loaded api keys from ~/.config/rhachet/apikeys.env"
|
|
26
31
|
|
|
27
32
|
# fallback to local gitignored file
|
|
28
|
-
elif [
|
|
33
|
+
elif [ -f .env.local ]; then
|
|
29
34
|
source .env.local
|
|
30
35
|
echo "✓ loaded api keys from .env.local"
|
|
31
36
|
|
|
@@ -39,20 +44,21 @@ else
|
|
|
39
44
|
echo "with contents like:"
|
|
40
45
|
echo " export OPENAI_API_KEY=sk-..."
|
|
41
46
|
echo " export ANTHROPIC_API_KEY=sk-..."
|
|
42
|
-
return 1
|
|
47
|
+
return 1 2>/dev/null || exit 1
|
|
43
48
|
fi
|
|
44
49
|
|
|
45
50
|
# read required keys from json config if present
|
|
46
51
|
APIKEYS_CONFIG=".agent/repo=.this/role=any/skills/use.apikeys.json"
|
|
47
|
-
if [
|
|
48
|
-
# extract required keys
|
|
52
|
+
if [ -f "$APIKEYS_CONFIG" ]; then
|
|
53
|
+
# extract required keys via jq
|
|
49
54
|
REQUIRED_KEYS=$(jq -r '.apikeys.required[]?' "$APIKEYS_CONFIG" 2>/dev/null)
|
|
50
55
|
|
|
51
56
|
# verify each required key is set
|
|
52
57
|
for KEY in $REQUIRED_KEYS; do
|
|
53
|
-
|
|
58
|
+
VALUE=$(eval "echo \"\$$KEY\"")
|
|
59
|
+
if [ -z "$VALUE" ]; then
|
|
54
60
|
echo "⚠ $KEY not set (required by $APIKEYS_CONFIG)"
|
|
55
|
-
return 1
|
|
61
|
+
return 1 2>/dev/null || exit 1
|
|
56
62
|
fi
|
|
57
63
|
echo "✓ $KEY set"
|
|
58
64
|
done
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: test-shards-setup
|
|
2
|
+
description: generate shard matrix from jest.*.shards.jsonc config
|
|
3
|
+
|
|
4
|
+
inputs:
|
|
5
|
+
config-file:
|
|
6
|
+
description: path to the shards config file (e.g., jest.integration.shards.jsonc)
|
|
7
|
+
required: true
|
|
8
|
+
test-type:
|
|
9
|
+
description: label for notices (e.g., integration, acceptance)
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
outputs:
|
|
13
|
+
matrix:
|
|
14
|
+
description: "JSON array of shard configs for matrix strategy"
|
|
15
|
+
value: ${{ steps.generate.outputs.matrix }}
|
|
16
|
+
patterns:
|
|
17
|
+
description: "pipe-delimited patterns for --testPathIgnorePatterns"
|
|
18
|
+
value: ${{ steps.generate.outputs.patterns }}
|
|
19
|
+
|
|
20
|
+
runs:
|
|
21
|
+
using: composite
|
|
22
|
+
steps:
|
|
23
|
+
- name: generate matrix from ${{ inputs.config-file }}
|
|
24
|
+
id: generate
|
|
25
|
+
shell: bash
|
|
26
|
+
run: |
|
|
27
|
+
config_file="${{ inputs.config-file }}"
|
|
28
|
+
test_type="${{ inputs.test-type }}"
|
|
29
|
+
|
|
30
|
+
# no config = single dynamic shard (backwards compat)
|
|
31
|
+
if [[ ! -f "$config_file" ]]; then
|
|
32
|
+
echo "$test_type: no config, default to single shard"
|
|
33
|
+
echo 'matrix=[{"type":"dynamic","shard":1,"total":1}]' >> $GITHUB_OUTPUT
|
|
34
|
+
echo 'patterns=' >> $GITHUB_OUTPUT
|
|
35
|
+
exit 0
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
# read config (strip comments for jq)
|
|
39
|
+
config=$(grep -v '^\s*//' "$config_file" | jq -c '.')
|
|
40
|
+
|
|
41
|
+
# extract explicit shards
|
|
42
|
+
explicit=$(echo "$config" | jq -c '.explicit // []')
|
|
43
|
+
explicit_count=$(echo "$explicit" | jq 'length')
|
|
44
|
+
|
|
45
|
+
# extract dynamic shard count
|
|
46
|
+
dynamic_count=$(echo "$config" | jq '.dynamic.shards // 0')
|
|
47
|
+
|
|
48
|
+
# build matrix
|
|
49
|
+
matrix="[]"
|
|
50
|
+
|
|
51
|
+
# add explicit shards
|
|
52
|
+
for i in $(seq 0 $((explicit_count - 1))); do
|
|
53
|
+
patterns=$(echo "$explicit" | jq -c ".[$i].patterns")
|
|
54
|
+
matrix=$(echo "$matrix" | jq -c ". + [{\"type\": \"explicit\", \"index\": $i, \"patterns\": $patterns}]")
|
|
55
|
+
done
|
|
56
|
+
|
|
57
|
+
# add dynamic shards
|
|
58
|
+
for i in $(seq 1 $dynamic_count); do
|
|
59
|
+
matrix=$(echo "$matrix" | jq -c ". + [{\"type\": \"dynamic\", \"shard\": $i, \"total\": $dynamic_count}]")
|
|
60
|
+
done
|
|
61
|
+
|
|
62
|
+
# collect all explicit patterns for exclusion
|
|
63
|
+
explicit_patterns=$(echo "$explicit" | jq -r '.[].patterns[]' 2>/dev/null | paste -sd '|' || echo '')
|
|
64
|
+
|
|
65
|
+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
|
|
66
|
+
echo "patterns=$explicit_patterns" >> $GITHUB_OUTPUT
|
|
67
|
+
|
|
68
|
+
echo "$test_type: $(echo "$matrix" | jq 'length') shards"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"@swc/jest": "@declapract{check.minVersion('0.2.39')}"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test:auth": "[ \"$ECHO\" = 'true' ] && echo '
|
|
12
|
+
"test:auth": "[ \"$ECHO\" = 'true' ] && echo '. .agent/repo=.this/role=any/skills/use.apikeys.sh' || . .agent/repo=.this/role=any/skills/use.apikeys.sh",
|
|
13
13
|
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
14
14
|
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
15
15
|
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "declapract-typescript-ehmpathy",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "declapract best practices declarations for typescript",
|
|
5
|
-
"version": "0.47.
|
|
5
|
+
"version": "0.47.28",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|