Skip to content

Commit

Permalink
ci: run validation against sample onboarding pull request (OfficeDev#…
Browse files Browse the repository at this point in the history
…1042)

* add folder change action

* update yaml

* fix bug

* remove echo step
  • Loading branch information
tecton authored Sep 21, 2023
1 parent 9eac976 commit a4f5a5a
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/ci-sample-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ on:
pull_request:
branches:
- dev
- v3
push:
branches:
- dev
- v3

jobs:
sample-validation:
Expand Down Expand Up @@ -38,7 +40,7 @@ jobs:
node validation-tool/validate-config.js .config/samples-config-v3.json
exit $?
- name: Sample Validation Tool
- name: Run Sample Validation Tool Based on Sample Config
run: |
# This script runs the validation tool against all samples in the samples-config-v3.json file.
# External samples are excluded from the validation.
Expand All @@ -60,3 +62,37 @@ jobs:
if [ "$validationResult" = false ]; then
exit 1
fi
- name: Get Changed Folders
id: get_changed_folders
if: ${{ github.event_name == 'pull_request' }}
uses: Stockopedia/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
ignore: "**/+(.github)"
foldersOnly: true
format: json

- name: Run Sample Validation Tool on New Sample
if: ${{ github.event_name == 'pull_request' }}
run: |
# This script runs the validation tool against changed samples in the pull request.
# External samples are excluded from the validation.
exceptions=("incoming-webhook-notification")
samples=`jq -r ".[]" <<< '${{ steps.get_changed_folders.outputs.changed }}'`
validationFailed="validation failed"
validationResult=true
while IFS= read -r line; do
if [[ ! ${exceptions[@]} =~ $line ]]
then
result=`node ./validation-tool/validator.cjs -p $line`
if grep -q "$validationFailed" <<< "$result"; then
printf "\nSample '$line' validation failed.\n"
echo "$result"
validationResult=false
fi
fi
done <<< "$samples"
if [ "$validationResult" = false ]; then
exit 1
fi

0 comments on commit a4f5a5a

Please sign in to comment.