Skip to content

Commit 95176d6

Browse files
committed
Fix: Update workflow for Fast Grants compatibility
1 parent 62b6e82 commit 95176d6

File tree

2 files changed

+82
-25
lines changed

2 files changed

+82
-25
lines changed

.github/scripts/parse-fast-grants-delivery.js:

Whitespace-only changes.

.github/workflows/check_author.yml

Lines changed: 82 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ on:
55

66
jobs:
77
get-delivery-files:
8-
runs-on: ubuntu-latest
9-
outputs:
10-
filenames: ${{ steps.files.outputs.added }}
11-
12-
steps:
13-
- name: Get filenames of any deliveries being added
14-
id: files
15-
uses: Ana06/get-changed-files@v2.3.0
16-
with:
17-
format: 'json'
18-
filter: |
19-
deliveries/*.md
20-
maintenance_deliveries/*.md
21-
8+
runs-on: ubuntu-latest
9+
outputs:
10+
filenames: ${{ steps.files.outputs.added }}
11+
12+
steps:
13+
- name: Get filenames of any deliveries being added
14+
id: files
15+
uses: Ana06/get-changed-files@v2.3.0
16+
with:
17+
format: 'json'
18+
filter: |
19+
deliveries/*.md
20+
maintenance_deliveries/*.md
21+
2222
check_author:
2323
runs-on: ubuntu-latest
2424
needs: get-delivery-files
@@ -27,34 +27,91 @@ jobs:
2727
fail-fast: false
2828
matrix:
2929
filename: ${{ fromJson(needs.get-delivery-files.outputs.filenames) }}
30-
30+
3131
steps:
3232
- uses: actions/checkout@v4
3333
with:
3434
ref: ${{ github.event.pull_request.head.sha }}
3535

36-
- name: Parse delivery file
36+
- name: Debug delivery file
37+
run: |
38+
echo "Checking file: ${{ matrix.filename }}"
39+
echo "File path: ${{ github.workspace }}/${{ matrix.filename }}"
40+
echo "File exists: $(test -f "${{ github.workspace }}/${{ matrix.filename }}" && echo 'YES' || echo 'NO')"
41+
echo ""
42+
echo "Content around 'Application Document':"
43+
grep -n -A2 -B2 -i "application document" "${{ github.workspace }}/${{ matrix.filename }}" || echo "Pattern not found"
44+
45+
- name: Extract application document (Fast Grants compatible)
3746
id: parse-delivery
38-
uses: w3f/parse-milestone-delivery-action@master
39-
with:
40-
path: "${{ github.workspace }}/${{ matrix.filename }}"
47+
run: |
48+
file_path="${{ github.workspace }}/${{ matrix.filename }}"
49+
50+
# Try multiple patterns to extract application document
51+
app_doc=""
52+
53+
# Pattern 1: After "**Application Document:**"
54+
app_doc=$(grep -oP "(?<=\*\*Application Document:\*\*\s)[^\s\n]+" "$file_path" 2>/dev/null | head -1 || echo "")
55+
56+
# Pattern 2: Simple applications/*.md pattern
57+
if [ -z "$app_doc" ]; then
58+
app_doc=$(grep -o "applications/[^[:space:]]*\.md" "$file_path" 2>/dev/null | head -1 || echo "")
59+
fi
60+
61+
# Pattern 3: More flexible regex
62+
if [ -z "$app_doc" ]; then
63+
app_doc=$(grep -E "applications/[a-zA-Z0-9_-]+\.md" "$file_path" 2>/dev/null | head -1 || echo "")
64+
fi
65+
66+
if [ -z "$app_doc" ]; then
67+
echo "Error: Could not extract application document from $file_path"
68+
echo "File content for debugging:"
69+
head -20 "$file_path"
70+
exit 1
71+
fi
72+
73+
echo "application_document=$app_doc" >> $GITHUB_OUTPUT
74+
echo "Found application document: $app_doc"
4175
4276
- name: Find PR author in application authors
43-
uses: actions/github-script@v5
77+
uses: actions/github-script@v7
4478
env:
4579
pr_author: ${{ github.event.pull_request.user.login }}
4680
with:
4781
script: |
82+
try {
83+
console.log(`Checking commits for: ${{ steps.parse-delivery.outputs.application_document }}`);
84+
console.log(`PR Author: ${process.env.pr_author}`);
85+
4886
const app_commits = await github.rest.repos.listCommits({
4987
owner: 'Polkadot-Fast-Grants',
5088
repo: 'apply',
51-
path: 'applications/${{ steps.parse-delivery.outputs.application_document }}'
89+
path: '${{ steps.parse-delivery.outputs.application_document }}'
5290
});
5391
54-
const app_authors = app_commits.data.map(c => c.author.login);
55-
console.log(app_authors);
56-
92+
if (app_commits.data.length === 0) {
93+
core.setFailed(`No commits found for application file: ${{ steps.parse-delivery.outputs.application_document }}`);
94+
return;
95+
}
96+
97+
const app_authors = app_commits.data
98+
.map(c => c.author?.login)
99+
.filter(author => author != null && author !== undefined);
100+
101+
console.log(`Application authors found: ${app_authors.join(', ')}`);
102+
103+
if (app_authors.length === 0) {
104+
core.setFailed('No valid authors found in application commits');
105+
return;
106+
}
57107
58108
if (!app_authors.includes(process.env.pr_author)) {
59-
core.setFailed('PR author does not match any application author.');
109+
core.setFailed(`PR author '${process.env.pr_author}' does not match any application author. Valid authors: ${app_authors.join(', ')}`);
110+
} else {
111+
console.log('Author check passed! PR author matches application author.');
60112
}
113+
114+
} catch (error) {
115+
console.error('Error details:', error);
116+
core.setFailed(`Error checking application authors: ${error.message}`);
117+
}

0 commit comments

Comments
 (0)