Skip to content

Commit c171861

Browse files
committed
Address PR commments.
Signed-off-by: alyssacgoins <agoins@redhat.com>
1 parent 2dc5b12 commit c171861

File tree

10 files changed

+84
-150
lines changed

10 files changed

+84
-150
lines changed

.github/resources/scripts/get_components_for_validation.sh

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: scripts-unit-tests
2+
env:
3+
PYTHON_VERSION: 3.11
4+
on:
5+
pull_request:
6+
paths:
7+
- 'scripts/validate_metadata/**'
8+
jobs:
9+
execute-scripts-unit-tests:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v6
18+
with:
19+
python-version: ${{ env.PYTHON_VERSION }}
20+
21+
- name: Install test dependencies
22+
run: |
23+
pip install -r scripts/validate_metadata/requirements.txt
24+
25+
- name: Install Test dependencies
26+
run: |
27+
pip install -r scripts/validate_metadata/requirements.txt
28+
29+
- name: Run tests
30+
run: pytest scripts/validate_metadata

.github/workflows/validate-component-metadata-schema.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: validate-metadata-schema
2+
env:
3+
PYTHON_VERSION: 3.11
4+
RETRIEVAL_SCRIPT_PATH: $GITHUB_WORKSPACE/.github/resources/scripts/get_items_for_validation.sh
5+
VALIDATION_SCRIPT_PATH: $GITHUB_WORKSPACE/scripts/validate_metadata/validate_metadata.py
6+
on:
7+
pull_request:
8+
paths:
9+
- 'components/**'
10+
- 'pipelines/**'
11+
- 'scripts/**'
12+
- 'third_party/components/**'
13+
- 'third_party/pipelines/**'
14+
15+
jobs:
16+
validate-metadata-schema:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v5
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Set up Python
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: ${{ env.PYTHON_VERSION }}
27+
28+
- name: Install Test dependencies
29+
run: |
30+
pip install -r scripts/validate_metadata/requirements.txt
31+
32+
- name: Retrieve new components and/or pipelines
33+
id: get-new-items
34+
run: ${{ env.RETRIEVAL_SCRIPT_PATH }} "${{ github.event.pull_request.base.sha }}" "${{ github.event.pull_request.head.sha }}" validate_metadata
35+
36+
#ToDo: Utilize .github/scripts/find-changed-components-and-pipelines.sh script once merged in from https://github.com/kubeflow/pipelines-components/pull/7
37+
- name: Validate new core/third-party components and/or pipelines
38+
if: ${{ steps.get-new-items.outputs.new_items_list != '' }}
39+
run: |
40+
NEW_ITEMS_ARRAY="${{ steps.get-new-items.outputs.new_items_list }}"
41+
42+
# Set IFS to a comma, so that the shell will split the string by commas.
43+
IFS=','
44+
45+
for item in $NEW_ITEMS_ARRAY; do
46+
FILE_PATH="$GITHUB_WORKSPACE/$item"
47+
echo "Processing item: $item"
48+
python "${{ env.VALIDATION_SCRIPT_PATH }}" --item $FILE_PATH
49+
done

scripts/__init__.py

Whitespace-only changes.

scripts/validate_metadata/__init__.py

Whitespace-only changes.

scripts/validate_metadata/__main__.py

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
PyYAML==6.0.3
22
semver==3.0.4
3+
pytest==7.1.2

scripts/validate_metadata/test_data/component_directories_metadata/component_valid/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: component_valid
2-
tier: third-party
2+
tier: third_party
33
stability: alpha
44
dependencies:
55
kubeflow:

scripts/validate_metadata/validate_metadata.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def parse_args() -> argparse.Namespace:
5757
parser.add_argument(
5858
'--component',
5959
type=validate_component_directory,
60+
required=True,
6061
help='Path to the component directory (must contain component.py and metadata.yaml)'
6162
)
6263

@@ -290,25 +291,22 @@ def get_invalid_versions(dependencies: list[dict]) -> list[dict]:
290291
def main():
291292
"""Main entry point for the CLI."""
292293
args = parse_args()
293-
if not args.component:
294-
raise ValidationError("Error: --component must be specified.")
295-
296294
component_dir = args.component
297295

298296
# Validate OWNERS
299297
try:
300298
owners_file_path = component_dir / OWNERS
301299
validate_owners_file(owners_file_path)
302300
except ValidationError as e:
303-
logging.error("Validation Error: {}", e)
301+
logging.error("Validation Error: %s", e)
304302
sys.exit(1)
305303

306304
# Validate metadata.yaml
307305
try:
308306
metadata_file_path = component_dir / METADATA
309307
validate_metadata_yaml(metadata_file_path)
310308
except ValidationError as e:
311-
logging.error("Validation Error: {}", e)
309+
logging.error("Validation Error: %s", e)
312310
sys.exit(1)
313311

314312
# Validation successful.

0 commit comments

Comments
 (0)