-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
TARGET_FOLDERS=("python" "javascript" "typescript" ) | ||
PACKAGE_FILE="package.json" | ||
REPO_FOLDER="$PWD" | ||
|
||
check_json_file_syntax() { | ||
file="$1" | ||
|
||
if [ ! -f "$file" ]; then | ||
echo "Error: File $file does not exist." | ||
return 1 | ||
fi | ||
|
||
required_fields=("name" "description" "keywords" "repository") | ||
missing_fields=() | ||
|
||
for field in "${required_fields[@]}"; do | ||
if ! jq --exit-status ".$field" "$file" >/dev/null 2>&1; then | ||
missing_fields+=("$field") | ||
fi | ||
done | ||
|
||
if [ ${#missing_fields[@]} -gt 0 ]; then | ||
file=$(echo "$file" | sed 's/\/home\/runner\/work\/platform-samples\/platform-samples//') | ||
echo "Warning: File $file does not contain the required fields:" | ||
for field in "${missing_fields[@]}"; do | ||
echo "- $field" | ||
done | ||
|
||
return 1 | ||
fi | ||
|
||
return 0 | ||
} | ||
|
||
|
||
|
||
check_package_files() { | ||
local folder=$1 | ||
find "$folder" -maxdepth 2 -type f -iname "$PACKAGE_FILE" -print0 | while IFS= read -r -d '' file; do | ||
check_json_file_syntax "$file" | ||
done | ||
} | ||
|
||
|
||
check_package_files_in_folders() { | ||
for folder in "${TARGET_FOLDERS[@]}"; do | ||
folder_path="$REPO_FOLDER/$folder" | ||
if [ -d "$folder_path" ]; then | ||
check_package_files "$folder_path" | ||
else | ||
echo "Folder $folder not found in repo" | ||
fi | ||
done | ||
} | ||
|
||
|
||
check_package_files_in_folders |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Check package' | ||
description: 'Check packaeg for specific fields' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check | ||
run: bash ./.github/actions/check-package/action.sh | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
TARGET_FOLDERS=("python" "javascript" "typescript" ) | ||
README_FILE="README.md" | ||
REPO_FOLDER="$PWD" | ||
|
||
check_readme_syntax() { | ||
content=$(cat "$file") | ||
if [[ $content == *"#"* && $content != *"___"* ]]; then | ||
|
||
file=$(echo "$file" | sed 's/\/home\/runner\/work\/platform-samples\/platform-samples//') | ||
echo "Warning: syntax errorn in $file" | ||
echo "You need to add a section that starts with # and ends with ___" | ||
fi | ||
|
||
} | ||
|
||
check_readme_files() { | ||
local folder=$1 | ||
find "$folder" -maxdepth 2 -type f -iname "$README_FILE" -print0 | while IFS= read -r -d '' file; do | ||
check_readme_syntax "$file" | ||
done | ||
} | ||
|
||
|
||
check_readme_files_in_folders() { | ||
for folder in "${TARGET_FOLDERS[@]}"; do | ||
folder_path="$REPO_FOLDER/$folder" | ||
if [ -d "$folder_path" ]; then | ||
check_readme_files "$folder_path" | ||
else | ||
echo "Folder $folder not found in repo" | ||
fi | ||
done | ||
} | ||
|
||
check_readme_files_in_folders | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: 'Check readme' | ||
description: 'Check readme for # <content> ___ ' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check | ||
run: bash ./.github/actions/check-readme/action.sh | ||
shell: bash | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: "Check readme files & packages in sequences" | ||
|
||
on: | ||
push: | ||
branches: | ||
- feat/check-readme | ||
|
||
jobs: | ||
check-syntax: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check readme files | ||
uses: ./.github/actions/check-readme | ||
|
||
- name: Check packages files | ||
uses: ./.github/actions/check-package | ||
|
||
|
||
|