Skip to content

Commit 07adfdc

Browse files
authored
chore: unify plugin check and allow updating multiple in one PR (langgenius#2466)
* chore: unify plugin check * chore: allow uploading multiple plugins at once * chore: detect file changes by GitHub CLI
1 parent e722dcd commit 07adfdc

File tree

3 files changed

+147
-232
lines changed

3 files changed

+147
-232
lines changed

.github/workflows/pre-check-plugin.yaml

Lines changed: 0 additions & 161 deletions
This file was deleted.

.github/workflows/plugin-e2e-test.yaml renamed to .github/workflows/pre-pr-check-per-plugin.yaml

Lines changed: 74 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,10 @@
1-
name: Plugin E2E Test
1+
name: Pre PR Check Per Plugin
22

33
on:
4-
push:
5-
branches: [ main ]
6-
paths:
7-
- '**/manifest.yaml'
8-
- '**/provider/**'
9-
- '**/models/**'
10-
- '**/tools/**'
11-
- '**/endpoints/**'
12-
- '**/tests/**'
134
pull_request:
14-
branches: [ main ]
15-
paths:
16-
- '**/manifest.yaml'
17-
- '**/provider/**'
18-
- '**/models/**'
19-
- '**/tools/**'
20-
- '**/endpoints/**'
21-
- '**/tests/**'
5+
types: [opened, synchronize, ready_for_review, review_requested, edited]
6+
branches:
7+
- main
228

239
jobs:
2410
detect-changes:
@@ -84,13 +70,25 @@ jobs:
8470
steps:
8571
- uses: actions/checkout@v4
8672

73+
- name: Clone Marketplace Toolkit
74+
env:
75+
GH_TOKEN: ${{ github.token }}
76+
run: |
77+
gh repo clone langgenius/dify-marketplace-toolkit -- .scripts/
78+
8779
- name: Setup Python
8880
uses: actions/setup-python@v5
8981
with:
9082
python-version: '3.12'
9183

92-
- name: Install uv
93-
run: curl -LsSf https://astral.sh/uv/install.sh | sh
84+
- name: Setup uv
85+
uses: astral-sh/setup-uv@v6
86+
with:
87+
version: "latest"
88+
activate-environment: false
89+
90+
- name: yq - portable yaml processor
91+
uses: mikefarah/yq@v4.44.5
9492

9593
- name: Install Homebrew and Dify CLI
9694
run: |
@@ -106,6 +104,61 @@ jobs:
106104
secrets: ${{ toJSON(secrets) }}
107105
exclude: GITHUB_TOKEN
108106

107+
- name: Check Plugin Manifest Author
108+
run: |
109+
if ! yq '.author' "${{ matrix.plugin_path }}/manifest.yaml" | grep -q "langgenius"; then
110+
echo "!!! Plugin manifest.yaml author must be langgenius"
111+
exit 1
112+
fi
113+
114+
- name: Check If Version Exists
115+
run: |
116+
VERSION=$(yq '.version' "${{ matrix.plugin_path }}/manifest.yaml")
117+
AUTHOR=$(yq '.author' "${{ matrix.plugin_path }}/manifest.yaml")
118+
NAME=$(yq '.name' "${{ matrix.plugin_path }}/manifest.yaml")
119+
echo "Checking plugin version: $VERSION"
120+
121+
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
122+
123+
if [ "$RESPONSE_CODE" = "200" ]; then
124+
RESPONSE=$(curl -s "${{ secrets.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
125+
if [ "$(echo "$RESPONSE" | jq -r '.code')" = "0" ]; then
126+
echo "!!! Plugin version $VERSION already exists, please update the version number in manifest.yaml"
127+
exit 1
128+
fi
129+
fi
130+
131+
- name: Check for Disallowed Virtualenv Directories
132+
run: |
133+
if find "${{ matrix.plugin_path }}" -maxdepth 1 -type d \( -name ".venv*" -o -name "venv*" \) | grep -q .; then
134+
echo "!!! Please remove .venv or venv* directory in plugin path before submitting the PR"
135+
exit 1
136+
fi
137+
138+
- name: Check Plugin pyproject.toml
139+
run: |
140+
cd "${{ matrix.plugin_path }}"
141+
if [ ! -f "pyproject.toml" ]; then
142+
echo "!!! pyproject.toml is required for all plugins"
143+
exit 1
144+
fi
145+
146+
- name: Validate Dependencies with uv
147+
run: |
148+
cd "${{ matrix.plugin_path }}"
149+
uv sync --all-groups --python 3.12
150+
151+
- name: Check Plugin Install
152+
run: |
153+
export INSTALL_METHOD=serverless
154+
export SERVERLESS_PORT=8080
155+
export SERVERLESS_HOST=0.0.0.0
156+
uv run --project "${{ matrix.plugin_path }}" --with requests python .scripts/validator/test-plugin-install.py -d "${{ matrix.plugin_path }}"
157+
158+
- name: Check Packaging
159+
run: |
160+
uv run --with requests --with dify_plugin python .scripts/uploader/upload-package.py -d "${{ matrix.plugin_path }}" -t "${{ secrets.MARKETPLACE_TOKEN }}" --plugin-daemon-path /home/linuxbrew/.linuxbrew/bin/dify -u "${{ secrets.MARKETPLACE_BASE_URL }}" -f --test
161+
109162
- name: Package plugin
110163
run: |
111164
SAFE_NAME=$(echo "${{ matrix.plugin_path }}" | tr '/' '-')
@@ -136,15 +189,7 @@ jobs:
136189
if: steps.check_tests.outputs.has_tests == 'true'
137190
working-directory: ${{ env.EXTRACT_DIR }}
138191
run: |
139-
if [ -f "pyproject.toml" ]; then
140-
uv sync --all-groups --python 3.12
141-
elif [ -f "requirements.txt" ]; then
142-
uv venv --python 3.12
143-
uv pip install -r requirements.txt
144-
else
145-
echo "Error: No pyproject.toml or requirements.txt found"
146-
exit 1
147-
fi
192+
uv sync --all-groups --python 3.12
148193
149194
- name: Run tests
150195
if: steps.check_tests.outputs.has_tests == 'true'

0 commit comments

Comments
 (0)