forked from langgenius/dify-official-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (109 loc) · 4.71 KB
/
Copy pathpre-check-plugin.yaml
File metadata and controls
126 lines (109 loc) · 4.71 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
name: Pre Check Plugin
on:
pull_request:
types: [opened, synchronize, ready_for_review, review_requested, edited]
branches:
- main
- dev
paths-ignore:
- "migrations/**"
- ".scripts/**"
- ".github/**"
- ".gitignore"
- "README.md"
- "LICENSE"
env:
REPO_NAME: langgenius/dify-official-plugins
MARKETPLACE_BASE_URL: https://marketplace.dify.ai
MARKETPLACE_TOKEN: placeholder
GH_TOKEN: ${{ github.token }}
jobs:
pre-check-plugin:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clone Marketplace Toolkit
run: |
gh repo clone langgenius/dify-marketplace-toolkit -- .scripts/
- name: Download Plugin Daemon
run: |
gh release download -R langgenius/dify-plugin-daemon --pattern "dify-plugin-linux-amd64" --dir .scripts || gh release download -R langgenius/dify-plugin-daemon --pattern "dify-plugin-linux-amd64" --dir .scripts
chmod +x .scripts/dify-plugin-linux-amd64
mv .scripts/dify-plugin-linux-amd64 /usr/local/bin/dify
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
version: "latest"
activate-environment: false
- name: Setup Global Python
run: |
uv venv --python 3.12.7
uv pip install requests dify_plugin pytest
- name: yq - portable yaml processor
uses: mikefarah/yq@v4.44.5
- name: Get PR Path
run: |
export PR_FILES=$(gh pr view -R ${{ env.REPO_NAME }} ${{ github.event.pull_request.number }} --json files --jq '.files | map(select(.path | startswith("tests/") | not))')
if PLUGIN_PATH=$(uv run python .scripts/validator/check-prefix.py); then
echo $PLUGIN_PATH
echo "PLUGIN_PATH=$PLUGIN_PATH" >> $GITHUB_ENV
else
echo "PR files cross different plugin directories, skip upload."
exit 1
fi
- name: Check Plugin Manifest
run: |
# manifest.yaml author must be langgenius
if ! yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml | grep -q "langgenius"; then
echo "!!! Plugin manifest.yaml author must be langgenius"
exit 1
fi
- name: Check If Version Exists
run: |
# get version, author, name
VERSION=$(yq '.version' ${{ env.PLUGIN_PATH }}/manifest.yaml)
AUTHOR=$(yq '.author' ${{ env.PLUGIN_PATH }}/manifest.yaml)
NAME=$(yq '.name' ${{ env.PLUGIN_PATH }}/manifest.yaml)
echo "Checking plugin version: $VERSION"
# Check if the version already exists
RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" "${{ env.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
if [ "$RESPONSE_CODE" = "200" ]; then
RESPONSE=$(curl -s "${{ env.MARKETPLACE_BASE_URL }}/api/v1/plugins/$AUTHOR/$NAME/$VERSION")
if [ "$(echo "$RESPONSE" | jq -r '.code')" = "0" ]; then
echo "!!! Plugin version $VERSION already exists, please update the version number in manifest.yaml"
exit 1
fi
fi
- name: Test Changed Plugin
run: |
if [ -d "tests/${{ env.PLUGIN_PATH }}" ]; then
if [ -f "tests/${{ env.PLUGIN_PATH }}/requirements.txt" ]; then
uv pip install -r tests/${{ env.PLUGIN_PATH }}/requirements.txt
fi
PYTHONPATH=. uv run pytest tests/${{ env.PLUGIN_PATH }}
fi
- name: Check Plugin Install
run: |
cd ${{ env.PLUGIN_PATH }}
if [ -f requirements.txt ]; then
uv pip install packaging
uv pip install -r requirements.txt
dify_version=$(uv pip list | grep -E 'dify-plugin|dify_plugin' | awk '{print $2}')
target_version="0.0.1b64"
result=$(uv run python -c "from packaging.version import Version; print(0 if Version('$dify_version') > Version('$target_version') else 1)")
if [ $result == 0 ]; then
export INSTALL_METHOD=serverless
export SERVERLESS_PORT=8080
export SERVERLESS_HOST=0.0.0.0
else
export INSTALL_METHOD=aws_lambda
export AWS_LAMBDA_PORT=8080
export AWS_LAMBDA_HOST=0.0.0.0
fi
fi
cd -
uv run python .scripts/validator/test-plugin-install.py -d ${{ env.PLUGIN_PATH }}
- name: Check Packaging
run: |
uv run python .scripts/uploader/upload-package.py -d ${{ env.PLUGIN_PATH }} -t ${{ env.MARKETPLACE_TOKEN }} --plugin-daemon-path /usr/local/bin/dify -u ${{ env.MARKETPLACE_BASE_URL }} -f --test