-
Notifications
You must be signed in to change notification settings - Fork 85
149 lines (133 loc) · 4.34 KB
/
Copy pathtest-plugins.yml
File metadata and controls
149 lines (133 loc) · 4.34 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
name: Test Plugins
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
jobs:
discover:
runs-on: ubuntu-latest
outputs:
python_plugins: ${{ steps.find.outputs.python_plugins }}
js_plugins: ${{ steps.find.outputs.js_plugins }}
steps:
- uses: actions/checkout@v7
- name: Discover plugins
id: find
shell: bash
run: |
PY_PLUGINS=()
for test_file in plugins/*/test/test_*.py; do
[ -f "$test_file" ] || continue
if grep -q 'if __name__ == "__main__"' "$test_file"; then
PY_PLUGINS+=("$test_file")
fi
done
JS_PLUGINS=()
for pkg in plugins/*/package.json; do
[ -f "$pkg" ] || continue
plugin=$(echo "$pkg" | cut -d'/' -f2)
JS_PLUGINS+=("$plugin")
done
if [ ${#PY_PLUGINS[@]} -eq 0 ]; then
PY_JSON="[]"
else
PY_JSON=$(printf '%s\n' "${PY_PLUGINS[@]}" | jq -R . | jq -sc .)
fi
if [ ${#JS_PLUGINS[@]} -eq 0 ]; then
JS_JSON="[]"
else
JS_JSON=$(printf '%s\n' "${JS_PLUGINS[@]}" | jq -R . | jq -sc .)
fi
echo "python_plugins=$PY_JSON" >> "$GITHUB_OUTPUT"
echo "js_plugins=$JS_JSON" >> "$GITHUB_OUTPUT"
echo "Python plugins found: $PY_JSON"
echo "JS plugins found: $JS_JSON"
test-python:
needs: discover
if: ${{ needs.discover.outputs.python_plugins != '[]' }}
runs-on: ubuntu-latest
name: "Python Plugins Tests"
env:
APPDATA: /home/runner/appdata
LOCALAPPDATA: /home/runner/localappdata
USERPROFILE: /home/runner
steps:
- uses: actions/checkout@v7
- name: Setup environment
run: |
mkdir -p $APPDATA $LOCALAPPDATA
- name: Install uv
shell: bash
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
uv --version
- name: Run Python plugin tests
shell: bash
run: |
TEST_FILES=$(echo '${{ needs.discover.outputs.python_plugins }}' | jq -r '.[]')
failed=0
for test_file in $TEST_FILES; do
if [ -f "$test_file" ]; then
plugin_dir=$(echo "$test_file" | cut -d'/' -f2)
echo "▶ Running tests for $plugin_dir ($test_file)"
if ! uv run --with pytest --with tomlkit --with pyyaml pytest "$test_file"; then
echo "❌ Plugin '$plugin_dir' test failed."
failed=1
fi
fi
done
if [ $failed -ne 0 ]; then
exit 1
fi
test-js:
needs: discover
if: ${{ needs.discover.outputs.js_plugins != '[]' }}
runs-on: ubuntu-latest
name: "JS Plugins Tests"
steps:
- uses: actions/checkout@v7
- name: Install Bun
shell: bash
run: |
curl -fsSL https://bun.sh/install | bash
echo "$HOME/.bun/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.bun/bin:$PATH"
bun --version
- name: Run JS plugin tests
shell: bash
run: |
export PATH="$HOME/.bun/bin:$PATH"
PLUGINS=$(echo '${{ needs.discover.outputs.js_plugins }}' | jq -r '.[]')
failed=0
for plugin in $PLUGINS; do
echo "▶ Running tests for $plugin"
cd "plugins/$plugin"
bun install
if cat package.json | jq -e '.scripts.test' > /dev/null 2>&1; then
if ! bun run test; then
echo "❌ Plugin '$plugin' test failed."
failed=1
fi
else
TEST_FILES=$(ls test/test_*.ts test/test_*.js 2>/dev/null)
if [ -n "$TEST_FILES" ]; then
for TEST_FILE in $TEST_FILES; do
echo "▶ Running $TEST_FILE"
if ! bun run "$TEST_FILE"; then
echo "❌ Plugin '$plugin' test failed."
failed=1
fi
done
else
echo "⚠️ No test script or test file found — skipping."
fi
fi
cd - > /dev/null
done
if [ $failed -ne 0 ]; then
exit 1
fi