fix: pipeline validation and delete collaborator-agent sample because it already a template #1113
This file contains hidden or 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
| name: Sample Validation | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| branches: | |
| - dev | |
| - main | |
| push: | |
| branches: | |
| - dev | |
| - main | |
| jobs: | |
| sample-validation: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| steps: | |
| - name: Checkout Pull Request | |
| if: ${{ github.event_name == 'pull_request' }} | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.head_ref }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| - name: Checkout Branch | |
| if: ${{ github.event_name != 'pull_request' }} | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| ref: ${{ github.ref_name }} | |
| repository: ${{ github.repository }} | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| - name: Validate Sample Config | |
| run: | | |
| node validation-tool/validate-config.js .config/samples-config-v3.json | |
| exit $? | |
| - 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. | |
| exceptions=("incoming-webhook-notification" "hello-world-office-addin") | |
| samples=`jq -r ".samples | .[] | select(has(\"downloadUrlInfo\") | not) | .id" .config/samples-config-v3.json` | |
| validationFailed="validation failed" | |
| validationWarning="warning" | |
| 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 "\n❌ Sample '$line' validation failed.\n" | |
| echo "$result" | |
| validationResult=false | |
| elif grep -q "$validationWarning" <<< "$result"; then | |
| printf "\n⚠️ Sample '$line' validation passed with warnings.\n" | |
| echo "$result" | |
| else | |
| printf "\n✅ Sample '$line' validation passed.\n" | |
| fi | |
| fi | |
| done <<< "$samples" | |
| 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. | |
| # Deleted folders are skipped (they no longer exist). | |
| exceptions=(".config" ".devcontainer" "assets" "templates" "validation-tool" "basic-blazor-tab-app" "incoming-webhook-notification" "stocks-update-notification-bot-dotnet" "whos-next-meeting-app") | |
| samples=`jq -r ".[]" <<< '${{ steps.get_changed_folders.outputs.changed }}'` | |
| validationFailed="validation failed" | |
| validationResult=true | |
| while IFS= read -r line; do | |
| if [[ ! ${exceptions[@]} =~ $line ]] | |
| then | |
| # Skip deleted folders - they no longer exist so cannot be validated | |
| if [ ! -d "$line" ]; then | |
| printf "\nSkipping deleted folder: '$line'\n" | |
| continue | |
| fi | |
| 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 |