forked from OfficeDev/teams-toolkit-samples
-
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.
ci: run validation against sample onboarding pull request (OfficeDev#…
…1042) * add folder change action * update yaml * fix bug * remove echo step
- Loading branch information
Showing
1 changed file
with
37 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -5,9 +5,11 @@ on: | |
pull_request: | ||
branches: | ||
- dev | ||
- v3 | ||
push: | ||
branches: | ||
- dev | ||
- v3 | ||
|
||
jobs: | ||
sample-validation: | ||
|
@@ -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. | ||
|
@@ -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 |