declapract-typescript-ehmpathy 0.47.25 → 0.47.27
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.
|
@@ -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"
|
|
@@ -63,12 +63,12 @@ export const check: FileCheckFunction = async (contents, context) => {
|
|
|
63
63
|
apikeys: apikeysConfig?.apikeys?.required ?? [],
|
|
64
64
|
});
|
|
65
65
|
|
|
66
|
-
// if contents match expected,
|
|
67
|
-
if (contents
|
|
68
|
-
throw new Error('file
|
|
66
|
+
// if contents don't match expected, best practice is violated
|
|
67
|
+
if (contents !== expected) {
|
|
68
|
+
throw new Error('file does not match expected content with apikey secrets');
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
// return = file
|
|
71
|
+
// return = file matches expected (best practice followed)
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
/**
|
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.27",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.js",
|
|
8
8
|
"repository": "ehmpathy/declapract-typescript-ehmpathy",
|