Add check for migrator filename uniqueness #3
Workflow file for this run
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: Check Migration Filename Uniqueness | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| jobs: | |
| migration-check: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Find new migration files | |
| id: find_files | |
| run: | | |
| # Compare PR branch against base, only include added files | |
| files=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }}...HEAD | grep '^recipe/migrations/' || true) | |
| echo "new_migrators=$new_migrators" >> $GITHUB_OUTPUT | |
| - name: Search for existing uses of that migrator in conda-forge | |
| if: steps.find_files.outputs.new_migrators != '' | |
| run: | | |
| failed=0 | |
| for m in ${new_migrators}; do | |
| migrator=$(basename "$m") | |
| echo "Checking for existing uses of migrator $migrator in conda-forge..." | |
| # Search in GH-org with exact path where migrators end up | |
| num_hits=$(gh search code "org:conda-forge path:.ci_support/migrations/$migrator" --json repository --jq 'map(select(.repository.isArchived == false)) | length') | |
| if [ "$num_hits" -gt 0 ]; then | |
| echo "Found $num_hits existing occurrences of migrator $migrator in conda-forge" | |
| failed=1 | |
| else | |
| echo "No existing occurrences of $migrator found" | |
| fi | |
| done | |
| if [ "$failed" -eq 1 ]; then | |
| echo "Pre-existing uses of migration filename(s) found in conda-forge." | |
| exit 1 | |
| fi |