Skip to content

Commit c975792

Browse files
Merge branch 'stdlib-js:develop' into gammasgnf
2 parents 0c79f38 + bcc704d commit c975792

File tree

746 files changed

+48467
-1603
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

746 files changed

+48467
-1603
lines changed

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ LAPACK:
2727
Math:
2828
- changed-files:
2929
- any-glob-to-all-files: '**/math/**/*'
30+
31+
Statistics:
32+
- changed-files:
33+
- any-glob-to-all-files: '**/stats/**/*'

.github/workflows/cleanup_coverage.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ jobs:
5959
script: |
6060
const prNumber = context.payload.pull_request.number;
6161
const { data: comments } = await github.rest.issues.listComments({
62-
owner: context.repo.owner,
63-
repo: context.repo.repo,
64-
issue_number: prNumber,
62+
'owner': context.repo.owner,
63+
'repo': context.repo.repo,
64+
'issue_number': prNumber
6565
});
6666
const coverageComment = comments.find( comment => comment.body && comment.body.includes( '## Coverage Report' ) );
6767
if ( coverageComment ) {
6868
// Replace URLs with plain text in the coverage report comment body:
6969
const updatedBody = coverageComment.body.replace( /<a href="[^"]+">([^<]+)<\/a>/g, '$1' );
7070
await github.rest.issues.updateComment({
71-
owner: context.repo.owner,
72-
repo: context.repo.repo,
73-
comment_id: coverageComment.id,
74-
body: updatedBody,
71+
'owner': context.repo.owner,
72+
'repo': context.repo.repo,
73+
'comment_id': coverageComment.id,
74+
'body': updatedBody
7575
});
7676
} else {
7777
console.log( 'No Coverage Report comment found.' );

.github/workflows/labeler.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ on:
3131
- review_request_removed
3232
- ready_for_review
3333
- converted_to_draft
34+
- labeled
3435

3536
# Workflow jobs:
3637
jobs:
@@ -75,12 +76,12 @@ jobs:
7576
'owner': context.repo.owner,
7677
'repo': context.repo.repo,
7778
'issue_number': context.payload.pull_request.number,
78-
'labels': ['Needs Review'],
79+
'labels': [ 'Needs Review' ]
7980
})
8081
81-
# Add "Needs Review" label when PR is marked ready for review:
82-
- name: 'Add "Needs Review" label if PR is ready for review'
83-
if: ${{ github.event.action == 'ready_for_review' }}
82+
# Add "Needs Review" label when PR is marked ready for review or review is requested:
83+
- name: 'Add "Needs Review" label if PR is ready for review or review is requested'
84+
if: ${{ github.event.action == 'ready_for_review' || github.event.action == 'review_requested' }}
8485
# Pin action to full length commit SHA
8586
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
8687
with:
@@ -90,7 +91,7 @@ jobs:
9091
'owner': context.repo.owner,
9192
'repo': context.repo.repo,
9293
'issue_number': context.payload.pull_request.number,
93-
'labels': ['Needs Review'],
94+
'labels': [ 'Needs Review' ]
9495
})
9596
9697
# Remove "Needs Review" label when PR is converted to draft or closed:
@@ -106,8 +107,29 @@ jobs:
106107
'owner': context.repo.owner,
107108
'repo': context.repo.repo,
108109
'issue_number': context.payload.pull_request.number,
109-
'name': 'Needs Review',
110+
'name': 'Needs Review'
110111
})
111112
} catch ( error ) {
112113
console.log( 'Error removing label: %s', error.message );
113114
}
115+
116+
# Remove "Needs Review" and "Needs Changes" labels when "Ready To Merge" is assigned:
117+
- name: 'Remove "Needs Review" and "Needs Changes" labels when "Ready To Merge" is assigned'
118+
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'Ready To Merge' }}
119+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
120+
with:
121+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
122+
script: |
123+
const labelsToRemove = [ 'Needs Review', 'Needs Changes' ];
124+
for ( const label of labelsToRemove ) {
125+
try {
126+
await github.rest.issues.removeLabel({
127+
'owner': context.repo.owner,
128+
'repo': context.repo.repo,
129+
'issue_number': context.payload.pull_request.number,
130+
'name': label
131+
})
132+
} catch ( error ) {
133+
console.log( 'Error removing label %s: %s', label, error.message );
134+
}
135+
}

.github/workflows/lint_changed_files.yml

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -142,43 +142,7 @@ jobs:
142142
- name: 'Lint package.json files'
143143
if: success() || failure()
144144
run: |
145-
# Determine root directory:
146-
root=$(git rev-parse --show-toplevel)
147-
148-
# Define the path to a utility for linting package.json files:
149-
lint_package_json="${root}/lib/node_modules/@stdlib/_tools/lint/pkg-json/bin/cli"
150-
151-
# Define paths to utilities for updating package.json metadata fields:
152-
update_package_json_directories="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_directories"
153-
update_package_json_gypfile="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile"
154-
155-
# Lint changed package.json files:
156-
files=$(echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n' | grep 'package\.json$' | grep -v 'datapackage\.json$' | tr '\n' ' ' | sed 's/ $//')
157-
if [ -n "${files}" ]; then
158-
echo "Linting package.json files that have changed..."
159-
printf "${files}" | "${lint_package_json}" --split=" "
160-
else
161-
echo "No package.json files to lint."
162-
fi
163-
164-
# Check if metadata fields need to be updated in package.json files of affected packages:
165-
dirs=$(echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n' | xargs dirname | sort -u)
166-
needs_changes=0
167-
for dir in ${dirs}; do
168-
echo "Checking package.json in ${dir}..."
169-
"${update_package_json_directories}" "${dir}"
170-
"${update_package_json_gypfile}" "${dir}"
171-
if [[ `git status --porcelain` ]]; then
172-
echo "::error::Package.json in ${dir} needs updates to directories and/or gypfile fields"
173-
git diff
174-
needs_changes=1
175-
fi
176-
done
177-
178-
# Exit with failure if any needed changes were detected:
179-
if [ $needs_changes -eq 1 ]; then
180-
exit 1
181-
fi
145+
. "$GITHUB_WORKSPACE/.github/workflows/scripts/lint_package_json_files" "${{ steps.changed-files.outputs.files }}"
182146
183147
# Lint REPL help files...
184148
- name: 'Lint REPL help files'

.github/workflows/lint_random_files.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,30 @@ jobs:
393393
env:
394394
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
395395
run: |
396-
# Create a temporary file for storing lint error messages:
397-
ERROR_LOG=$(mktemp)
398-
grep -B 1 -A 2 "style:\|warning:\|error:" <<< "${{ steps.lint-c.outputs.stderr }}" > $ERROR_LOG
399-
400-
. "$GITHUB_WORKSPACE/.github/workflows/scripts/create_lint_sub_issue" \
401-
"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" \
402-
"C" \
403-
"3235" \ # Number of C lint error tracking issue
404-
"$ERROR_LOG"
396+
BODY_FILE="$GITHUB_WORKSPACE/lint_issue_body.md"
397+
398+
cat << EOF > "$BODY_FILE"
399+
## C Linting Failures
400+
401+
Linting failures were detected in the automated lint workflow run.
402+
403+
### Workflow Details
404+
- Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
405+
- Type: C Linting
406+
- Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
407+
408+
### Error Details
409+
\`\`\`
410+
$(grep -B 1 -A 2 "style:\|warning:\|error:" <<< "${{ steps.lint-c.outputs.stderr }}")
411+
\`\`\`
412+
EOF
413+
414+
. "$GITHUB_WORKSPACE/.github/workflows/scripts/create_sub_issue" \
415+
'Fix C lint errors' \
416+
"$BODY_FILE" \
417+
"3235" # Number of C lint error tracking issue
418+
419+
rm "$BODY_FILE"
405420
406421
# Lint TypeScript declarations files:
407422
- name: 'Lint TypeScript declarations files'

.github/workflows/run_tests_coverage.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,25 @@ jobs:
226226
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
227227
script: |
228228
const { data: comments } = await github.rest.issues.listComments({
229-
issue_number: context.issue.number,
230-
owner: context.repo.owner,
231-
repo: context.repo.repo,
229+
'issue_number': context.issue.number,
230+
'owner': context.repo.owner,
231+
'repo': context.repo.repo,
232232
});
233233
234234
const botComment = comments.find( comment => comment.user.login === 'stdlib-bot' && comment.body.includes( '## Coverage Report' ) );
235235
if ( botComment ) {
236236
await github.rest.issues.updateComment({
237-
owner: context.repo.owner,
238-
repo: context.repo.repo,
239-
comment_id: botComment.id,
240-
body: `${{ steps.create-report.outputs.report }}`,
237+
'owner': context.repo.owner,
238+
'repo': context.repo.repo,
239+
'comment_id': botComment.id,
240+
'body': `${{ steps.create-report.outputs.report }}`
241241
});
242242
} else {
243243
await github.rest.issues.createComment({
244-
issue_number: context.issue.number,
245-
owner: context.repo.owner,
246-
repo: context.repo.repo,
247-
body: `${{ steps.create-report.outputs.report }}`,
244+
'issue_number': context.issue.number,
245+
'owner': context.repo.owner,
246+
'repo': context.repo.repo,
247+
'body': `${{ steps.create-report.outputs.report }}`
248248
});
249249
}
250250
@@ -257,10 +257,10 @@ jobs:
257257
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
258258
script: |
259259
github.rest.repos.createCommitComment({
260-
commit_sha: context.sha,
261-
owner: context.repo.owner,
262-
repo: context.repo.repo,
263-
body: '${{ steps.create-report.outputs.report }}'
260+
'commit_sha': context.sha,
261+
'owner': context.repo.owner,
262+
'repo': context.repo.repo,
263+
'body': '${{ steps.create-report.outputs.report }}'
264264
})
265265
266266
# Checkout coverage repository:

.github/workflows/scripts/create_lint_sub_issue renamed to .github/workflows/scripts/create_sub_issue

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818

19-
# Script to create a sub-issue for linting failures
19+
# Script to create a sub-issue.
2020
#
21-
# Usage: ./create_lint_sub_issue.sh <workflow-url> <lint-type> <parent-issue-number>
21+
# Usage: ./create_sub_issue.sh <issue-title> <body-file> <parent-issue-number> [<labels>]
2222
#
2323
# Arguments:
2424
#
25-
# workflow-url URL of the workflow run.
26-
# lint-type Type of linting failure.
25+
# issue-title Title for the new sub-issue.
26+
# body-file Path to the file containing the issue body.
2727
# parent-issue-number Number of the parent issue.
28-
# error-log-file Path to the error log file.
29-
#
28+
# labels Optional comma-separated list of labels to apply to the new sub-issue.
3029
#
3130
# Environment variables:
3231
#
@@ -41,10 +40,10 @@ set -o pipefail
4140
# VARIABLES #
4241

4342
# Assign command line arguments to variables:
44-
workflow_url="$1"
45-
lint_type="$2"
43+
issue_title="$1"
44+
body_file="$2"
4645
parent_issue_number="$3"
47-
error_log_file="$4"
46+
labels="$4"
4847

4948
# Repository information:
5049
owner="stdlib-js"
@@ -57,28 +56,20 @@ if [ -z "$github_token" ]; then
5756
exit 1
5857
fi
5958

60-
# Read and format the error log
61-
if [ ! -f "$error_log_file" ]; then
62-
echo -e "Error log file not found: ${error_log_file}"
59+
# Read and validate the body file:
60+
if [ ! -f "$body_file" ]; then
61+
echo -e "ERROR: Body file not found: ${body_file}"
6362
exit 1
6463
fi
65-
error_log_content=$(cat "$error_log_file")
66-
67-
# Create issue body with formatted error log
68-
issue_body="## ${lint_type} Linting Failures
69-
70-
Linting failures were detected in the automated lint workflow run.
71-
72-
### Workflow Details
73-
- Run: ${workflow_url}
74-
- Type: ${lint_type} Linting
75-
- Date: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
76-
77-
### Error Details
78-
\`\`\`
79-
${error_log_content}
80-
\`\`\`
81-
"
64+
issue_body=$(cat "$body_file")
65+
66+
# Process labels into an array if provided:
67+
if [ -n "$labels" ]; then
68+
# Convert comma-separated string to JSON array...
69+
label_array="[$(echo "$labels" | sed 's/[[:space:]]*,[[:space:]]*/","/g' | sed 's/.*/"&"/')]"
70+
else
71+
label_array="[]"
72+
fi
8273

8374
# FUNCTIONS #
8475

@@ -114,7 +105,7 @@ EOF
114105
echo "$response" | jq -r '.data.repository.id'
115106
}
116107

117-
# Creates a child issue.
108+
# Creates a child issue with labels.
118109
#
119110
# $1 - repository node ID
120111
# $2 - issue body
@@ -127,11 +118,12 @@ create_child_issue() {
127118
-H "Content-Type: application/json" \
128119
--data @- << EOF
129120
{
130-
"query": "mutation CreateIssue(\$repositoryId: ID!, \$title: String!, \$body: String!) { createIssue(input: {repositoryId: \$repositoryId, title: \$title, body: \$body}) { issue { id number } } }",
121+
"query": "mutation CreateIssue(\$repositoryId: ID!, \$title: String!, \$body: String!, \$labelIds: [ID!]) { createIssue(input: {repositoryId: \$repositoryId, title: \$title, body: \$body, labelIds: \$labelIds}) { issue { id number } } }",
131122
"variables": {
132123
"repositoryId": "${repo_id}",
133-
"title": "Fix ${lint_type} lint errors",
134-
"body": $(echo "$issue_body" | jq -R -s '.')
124+
"title": "${issue_title}",
125+
"body": $(echo "$issue_body" | jq -R -s '.'),
126+
"labelIds": ${label_array}
135127
}
136128
}
137129
EOF
@@ -159,6 +151,37 @@ EOF
159151
echo "$response" | jq -r '.data.repository.issue.id'
160152
}
161153

154+
# Fetches label IDs for given label names.
155+
fetch_label_ids() {
156+
if [ -z "$labels" ]; then
157+
echo "[]"
158+
return
159+
fi
160+
161+
local label_names="${labels//,/\",\"}"
162+
local response
163+
response=$(curl -s -X POST 'https://api.github.com/graphql' \
164+
-H "Authorization: bearer ${github_token}" \
165+
-H "Content-Type: application/json" \
166+
--data @- << EOF
167+
{
168+
"query": "query(\$owner: String!, \$repo: String!) { repository(owner: \$owner, name: \$repo) { labels(first: 100) { nodes { id name } } } }",
169+
"variables": {
170+
"owner": "${owner}",
171+
"repo": "${repo}"
172+
}
173+
}
174+
EOF
175+
)
176+
177+
# Extract and filter label IDs that match our requested labels...
178+
echo "$response" | jq --arg names "${label_names}" '
179+
.data.repository.labels.nodes |
180+
map(select(.name as $n | [$names] | contains([$n]))) |
181+
map(.id)
182+
'
183+
}
184+
162185
# Creates a sub-issue relationship.
163186
#
164187
# $1 - parent issue ID
@@ -194,7 +217,15 @@ main() {
194217
exit 1
195218
fi
196219

197-
echo "Creating child issue for ${lint_type} lint failures..."
220+
if [ -n "$labels" ]; then
221+
echo "Fetching label IDs..."
222+
label_array=$(fetch_label_ids)
223+
if [ "$label_array" = "[]" ]; then
224+
echo -e "Warning: No valid labels found for the provided label names."
225+
fi
226+
fi
227+
228+
echo "Creating child issue..."
198229
child_issue_response=$(create_child_issue "$repo_id" "$issue_body")
199230

200231
child_issue_id=$(echo "$child_issue_response" | jq -r '.data.createIssue.issue.id')

0 commit comments

Comments
 (0)