-
Notifications
You must be signed in to change notification settings - Fork 55
85 lines (71 loc) · 3.91 KB
/
validate-integration-files.yml
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
name: Validate integration files
on:
pull_request:
paths:
- "integrations/**"
jobs:
validate-files:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup
run: |
pip install toml-cli yq packaging
- name: Check Ocean version 🌊
run: |
git remote add ocean-origin https://github.com/port-labs/ocean.git
git fetch ocean-origin
changed_dirs=$(git diff --name-only ocean-origin/main HEAD | grep 'integrations/' | cut -d'/' -f 1,2 | sort -u)
package_version=$(curl -s https://pypi.org/pypi/port-ocean/json | jq -r '.info.version')
for dir in $changed_dirs; do
pyproject_file=$(find $dir -name 'pyproject.toml' -not -path "**/.venv/*")
if [ -n "$pyproject_file" ]; then
installed_version=$(toml get tool.poetry.dependencies.port_ocean.version --toml-path $pyproject_file)
is_version_updated=$(python -c "from packaging import version;print(version.parse('$installed_version'.lstrip('^')) >= version.parse('$package_version'))")
if [ "$is_version_updated" = "False" ]; then
echo "ERROR: Ocean version in $pyproject_file is not updated to latest version -> $package_version"
exit 1
else
echo "Ocean version is valid in $pyproject_file"
fi
fi
done
- name: Validate integration not duplicated
run: |
for integration in $(find integrations -name 'pyproject.yaml' -not -path "**/.venv/*"); do
type=$(grep -E '^name = ".*"' "$integration" | cut -d'"' -f2)
if [ $(find integrations -name 'spec.yaml' -not -path "**/.venv/*" | xargs -I {} yq -r '.type' {} | grep -c ^$integration_type$) -gt 1 ]; then
echo "ERROR: $integration_type integration type is duplicated please check your spec.yaml file"
exit 1
fi
done
- name: Validate icons
run: |
S3_BUCKET="port-graphical-assets"
S3_APP_ICONS_URL="https://${S3_BUCKET}.s3.amazonaws.com?prefix=icons/apps/"
APP_RESULTS=($(curl -s "${S3_APP_ICONS_URL}" | grep -o '<Key>[^<]*</Key>' | sed 's/<Key>\([^<]*\)<\/Key>/\1/' | tr '[:upper:]' '[:lower:]'))
S3_GENERAL_ICONS_URL="https://${S3_BUCKET}.s3.amazonaws.com?prefix=icons/general/"
GENERAL_RESULTS=$(curl -s "${S3_GENERAL_ICONS_URL}" | grep -o '<Key>[^<]*</Key>' | sed 's/<Key>\([^<]*\)<\/Key>/\1/' | tr '[:upper:]' '[:lower:]')
S3_SYSTEM_ICONS_URL="https://${S3_BUCKET}.s3.amazonaws.com?prefix=icons/system/"
SYSTEM_RESULTS=$(curl -s "${S3_SYSTEM_ICONS_URL}" | grep -o '<Key>[^<]*</Key>' | sed 's/<Key>\([^<]*\)<\/Key>/\1/' | tr '[:upper:]' '[:lower:]')
APP_AND_SYSTEM_RESULTS=($(printf "%s\n" "${APP_RESULTS[@]}" "${SYSTEM_RESULTS[@]}" | sort -u))
RESULTS=($(printf "%s\n" "${APP_AND_SYSTEM_RESULTS[@]}" "${GENERAL_RESULTS[@]}" | sort -u))
echo "Got Port Icons ${RESULTS[@]}"
# All integration icons
ICONS=($(find integrations -name 'spec.yaml' -not -path "**/.venv/*" | xargs -I {} yq -r '.icon' {} | tr '[:upper:]' '[:lower:]'))
BP_ICONS=($(find integrations/** -name 'blueprints.json' -not -path "**/.venv/*" | xargs -I {} jq -r '.[] | .. | .icon?' {} | grep -v '^null$' | sort -u | tr '[:upper:]' '[:lower:]'))
MERGED_SET=($(printf "%s\n" "${ICONS[@]}" "${BP_ICONS[@]}" | sort -u))
echo "Required Icons: ${MERGED_SET[@]}"
for ICON in "${MERGED_SET[@]}"; do
if [ $(echo "${RESULTS[@]}" | grep -c "$ICON") -eq 0 ]; then
echo "ERROR: $ICON icon is missing in icons pool"
exit 1
fi
done