Skip to content

Commit ea9ea2d

Browse files
committed
Feat: Add metadata validation workflow and scripts
Signed-off-by: alyssacgoins <[email protected]>
1 parent 00758af commit ea9ea2d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1301
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: validate-metadata-schema
2+
env:
3+
PYTHON_VERSION: 3.11
4+
on:
5+
pull_request:
6+
paths:
7+
- 'component/pipelines/**'
8+
- 'scripts/**'
9+
10+
jobs:
11+
validate-component-metadata-schema:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v6
20+
with:
21+
python-version: ${{ env.PYTHON_VERSION }}
22+
23+
- name: Install Test dependencies
24+
run: |
25+
pip install -r scripts/validate_metadata/requirements.txt
26+
27+
- name: Retrieve new components
28+
id: get-new-components
29+
run: |
30+
BASE_COMMIT="${{ github.event.pull_request.base.sha }}"
31+
HEAD_COMMIT="${{ github.event.pull_request.head.sha }}"
32+
33+
COMMIT_RANGE="HEAD~1..HEAD"
34+
SCRIPT_DIR="scripts/validate_metadata"
35+
36+
echo "Using BASE_COMMIT: $BASE_COMMIT"
37+
echo "Using HEAD_COMMIT: $HEAD_COMMIT"
38+
echo "Run COMMIT_RANGE=$COMMIT_RANGE"
39+
40+
# If diff is detected in scripts/validate_metadata, validate all components.
41+
SCRIPT_DIFF=$(git diff --name-only --diff-filter=A $COMMIT_RANGE -- $SCRIPT_DIR)
42+
if [[ "$SCRIPT_DIFF" == "" ]]; then
43+
echo "Changes detected in critical script directory: $SCRIPT_DIR"
44+
ALL_COMPONENT_FILES=$(find components -mindepth 2 -maxdepth 2 -type d | \
45+
sort -u | \
46+
tr '\n' ',' | \
47+
sed 's/,$//')
48+
49+
echo "Changes detected in scripts/validate_metadata. All existing components will be validated: $ALL_COMPONENT_FILES"
50+
echo "new_components_list=$ALL_COMPONENT_FILES" >> "$GITHUB_OUTPUT"
51+
52+
else
53+
# If no script diff is detected, check for new components.
54+
GIT_DIFF=$(git diff --name-only --diff-filter=A $COMMIT_RANGE -- "components")
55+
NEW_COMPONENTS=()
56+
57+
# Retrieve list of component categories.
58+
COMPONENT_TYPES=$(find components -mindepth 2 -maxdepth 2 -type d | \
59+
sed 's/^components\///' | \
60+
sort -u)
61+
62+
# Identify all new components in each category.
63+
for dir in $COMPONENT_TYPES; do
64+
echo "DIR: components/$dir"
65+
if [[ " $GIT_DIFF " =~ components/"$dir" ]]; then
66+
NEW_COMPONENTS+=(components/"$dir")
67+
fi
68+
done
69+
70+
# Format the list of new components for output.
71+
FORMATTED_COMPONENTS+=$(printf '%s\n' "${NEW_COMPONENTS[@]}" | \
72+
sort -u | \
73+
tr '\n' ',' | \
74+
sed 's/,$//')
75+
76+
if [[ "$SCRIPT_DIFF" == "" ]]; then
77+
echo "The following new components were found and will be validated: $FORMATTED_COMPONENTS"
78+
else
79+
echo "No new components detected."
80+
fi
81+
82+
echo "new_components_list=$FORMATTED_COMPONENTS" >> "$GITHUB_OUTPUT"
83+
84+
fi
85+
86+
- name: Validate new components
87+
if: ${{ steps.get-new-components.outputs.new_components_list != '' }}
88+
run: |
89+
SCRIPT_PATH="$GITHUB_WORKSPACE/scripts/validate_metadata/validate_metadata.py"
90+
NEW_COMPONENTS_ARRAY="${{ steps.get-new-components.outputs.new_components_list }}"
91+
92+
# 2. Set IFS to a comma, so that the shell will split the string by commas.
93+
IFS=','
94+
95+
for component in $NEW_COMPONENTS_ARRAY; do
96+
COMPONENT_PATH="$GITHUB_WORKSPACE/$component"
97+
echo "Processing component: $component"
98+
python $SCRIPT_PATH --component $COMPONENT_PATH
99+
done
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Entry point for running validate_metadata as a module.
2+
"""
3+
4+
from .validate_metadata import main
5+
6+
if __name__ == "__main__":
7+
main()
8+
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PyYAML==6.0.3
2+
semver==3.0.4
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
approvers:
2+
- sample-approver
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
tier: third_party
2+
name: happy-path-component
3+
stability: alpha | beta | stable
4+
dependencies:
5+
kubeflow:
6+
- name: Pipelines
7+
version: '>=2.5'
8+
- name: Trainer
9+
version: '>=2.0'
10+
external_services:
11+
- name: Argo Workflows
12+
version: "3.6"
13+
tags:
14+
- training
15+
- evaluation
16+
lastVerified: 2025-03-15T00:00:00Z
17+
ci:
18+
skip_dependency_probe: false
19+
pytest: optional
20+
links:
21+
documentation: https://kubeflow.org/components/happy-path-component
22+
issue_tracker: https://github.com/kubeflow/kfp-components/issues
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
approvers:
2+
- sample-approver
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: component_valid
2+
tier: third-party
3+
stability: alpha
4+
dependencies:
5+
kubeflow:
6+
- name: Pipelines
7+
version: '2.5.0'
8+
- name: Trainer
9+
version: '2.0.0'
10+
external_services:
11+
- name: Argo Workflows
12+
version: "3.6.0"
13+
tags:
14+
- training
15+
- evaluation
16+
lastVerified: 2025-03-15T00:00:00Z
17+
ci:
18+
skip_dependency_probe: false
19+
links:
20+
documentation: https://kubeflow.org/components/happy-path-component
21+
issue_tracker: https://github.com/kubeflow/kfp-components/issues

scripts/validate_metadata/test_data/component_directories_metadata/not_a_dir.txt

Whitespace-only changes.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: invalid-ci
2+
tier: core
3+
stability: alpha
4+
dependencies:
5+
kubeflow:
6+
- name: Pipelines
7+
version: '>=2.5.0'
8+
- name: Trainer
9+
version: '>=2.0.0'
10+
external_services:
11+
- name: Argo Workflows
12+
version: "3.6.0"
13+
tags:
14+
- training
15+
- evaluation
16+
lastVerified: 2025-03-15T00:00:00Z
17+
ci: invalid-ci-value
18+
links:
19+
documentation: https://kubeflow.org/components/happy-path-component
20+
issue_tracker: https://github.com/kubeflow/kfp-components/issues
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: invalid-ci-category
2+
tier: core
3+
stability: stable
4+
dependencies:
5+
kubeflow:
6+
- name: Pipelines
7+
version: '>=2.5.0'
8+
- name: Trainer
9+
version: '>=2.0.0'
10+
external_services:
11+
- name: Argo Workflows
12+
version: "3.6.0"
13+
tags:
14+
- training
15+
- evaluation
16+
lastVerified: 2025-03-15T00:00:00Z
17+
ci:
18+
skip_dependency_probe: false
19+
invalid_ci_category: invalid_value
20+
links:
21+
documentation: https://kubeflow.org/components/happy-path-component
22+
issue_tracker: https://github.com/kubeflow/kfp-components/issues

0 commit comments

Comments
 (0)