Please add SlicerPySERA extension metadata #221
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: Extension Validation | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - 5.* | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| validate-extensions: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 # Fetch full history for git diff | |
| - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| cache-dependency-path: scripts/requirements.txt | |
| - name: Configure git | |
| run: | | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "GitHub Action" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| echo "Installing dependencies from requirements.txt:" | |
| cat scripts/requirements.txt | |
| pip install -r scripts/requirements.txt | |
| echo "Verifying installed packages:" | |
| pip list | grep -E "(jsonschema|requests)" | |
| - name: Run repository structure validation | |
| id: structure-validation | |
| continue-on-error: true | |
| run: | | |
| mkdir -p /tmp/validation-reports | |
| python scripts/check_repository_structure.py \ | |
| > /tmp/validation-reports/repository-structure-report.md | |
| - name: Get changed files | |
| run: | | |
| echo "Event: ${{ github.event_name }}" | |
| mkdir -p /tmp/validation-reports | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| # For pull requests, compare against the base branch | |
| BASE_REF="${{ github.event.pull_request.base.ref }}" | |
| echo "Base ref: $BASE_REF" | |
| git diff --name-only "origin/$BASE_REF"...HEAD > /tmp/validation-reports/changed_files.txt 2>/dev/null | |
| else | |
| # For pushes, compare against the previous commit or get all JSON files if it's the first commit | |
| git diff --name-only HEAD~1 HEAD > /tmp/validation-reports/changed_files.txt 2>/dev/null | |
| fi | |
| echo "Changed JSON files:" | |
| cat /tmp/validation-reports/changed_files.txt | |
| - name: Run extension validation | |
| id: extension-validation | |
| continue-on-error: true | |
| run: | | |
| mkdir -p /tmp/validation-reports | |
| python scripts/check_description_files.py \ | |
| $(cat /tmp/validation-reports/changed_files.txt | tr '\n' ' ') \ | |
| > /tmp/validation-reports/extension-validation-report.md | |
| echo 'report<<EOF' >> $GITHUB_OUTPUT | |
| cat /tmp/validation-reports/extension-validation-report.md >> $GITHUB_OUTPUT | |
| echo 'EOF' >> $GITHUB_OUTPUT | |
| - name: Combine validation reports and display summary | |
| if: always() | |
| run: | | |
| mkdir -p /tmp/validation-reports | |
| if [ -f /tmp/validation-reports/repository-structure-report.md ]; then | |
| cat /tmp/validation-reports/repository-structure-report.md >> /tmp/validation-reports/validation-report.md | |
| else | |
| echo "❌ Repository structure validation report not generated" >> /tmp/validation-reports/validation-report.md | |
| fi | |
| echo "" >> /tmp/validation-reports/validation-report.md | |
| if [ -f /tmp/validation-reports/extension-validation-report.md ]; then | |
| cat /tmp/validation-reports/extension-validation-report.md >> /tmp/validation-reports/validation-report.md | |
| else | |
| echo "❌ Extension validation report not generated" >> /tmp/validation-reports/validation-report.md | |
| fi | |
| if [ -f /tmp/validation-reports/validation-report.md ]; then | |
| cat /tmp/validation-reports/validation-report.md >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "❌ Validation report not generated" >> $GITHUB_STEP_SUMMARY | |
| fi | |
| - name: Upload validation reports | |
| if: always() | |
| uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 | |
| with: | |
| name: validation-reports | |
| path: | | |
| /tmp/validation-reports/validation-report.md | |
| /tmp/validation-reports/repository-structure-report.md | |
| /tmp/validation-reports/extension-validation-report.md | |
| /tmp/validation-reports/changed_files.txt | |
| retention-days: 30 | |
| - name: Find Comment | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always() | |
| uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0 | |
| id: fc | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| comment-author: "github-actions[bot]" | |
| body-includes: "<!-- extension-validation-report -->" | |
| - name: Comment PR with report | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && always() | |
| uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0 | |
| with: | |
| comment-id: ${{ steps.fc.outputs.comment-id }} | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| <!-- extension-validation-report --> | |
| # Extension Validation Report | |
| ${{ steps.extension-validation.outputs.report }} | |
| *** | |
| *This report was automatically generated by the Extension Validation workflow and it is updated automatically when files are modified.* | |
| edit-mode: replace | |
| - name: Check validation results | |
| if: always() | |
| run: | | |
| echo "Checking validation results..." | |
| STRUCTURE_RESULT="${{ steps.structure-validation.outcome }}" | |
| EXTENSION_RESULT="${{ steps.extension-validation.outcome }}" | |
| echo "Repository structure validation: $STRUCTURE_RESULT" | |
| echo "Extension validation: $EXTENSION_RESULT" | |
| if [ "$STRUCTURE_RESULT" != "success" ] || [ "$EXTENSION_RESULT" != "success" ]; then | |
| echo "❌ Extension description validation failed. See workflow summary for more information: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | |
| exit 1 | |
| else | |
| echo "✅ All validation steps passed. See workflow summary for more information: https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | |
| fi |