-
-
Notifications
You must be signed in to change notification settings - Fork 583
65 lines (54 loc) · 2.28 KB
/
migrator_uniqueness.yml
File metadata and controls
65 lines (54 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Check Migration Filename Uniqueness
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
migrator-name-uniqueness-check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch full history so we can diff properly
- name: Fetch base branch
run: |
git fetch origin ${{ github.base_ref }} --depth=1
- name: Find newly added migration files
id: find_migrators
run: |
# Diff only added files between base branch and PR HEAD
new_migrators=$(git diff --name-only --diff-filter=A origin/${{ github.base_ref }}...HEAD | grep '^recipe/migrations/' || true)
echo "Found new migrators:"
echo "$new_migrators"
echo "new_migrators=$new_migrators" >> $GITHUB_OUTPUT
- name: Search for existing uses of that migrator in conda-forge
if: steps.find_migrators.outputs.new_migrators != ''
run: |
failed=0
for m in ${{ steps.find_migrators.outputs.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
query=$(printf "org:conda-forge+path:.ci_support/migrations/$migrator" | jq -sRr @uri)
response=$(curl -s -H "Accept: application/vnd.github+json" \
-H "Authorization: token $GH_TOKEN" \
"https://api.github.com/search/code?q=$query")
echo "Sent $query"
echo "Got $response"
num_hits=$(echo "$response" | jq '[.items[] | select(.repository.archived == 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