Skip to content

Commit 9874597

Browse files
feat( add C implementation ): add stats/base/dists/arcsine
2 parents 48f947c + 1c56b73 commit 9874597

File tree

256 files changed

+7066
-837
lines changed

Some content is hidden

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

256 files changed

+7066
-837
lines changed

.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: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ name: labeler
2222
# Workflow triggers:
2323
on:
2424
pull_request_target:
25+
types:
26+
- opened
27+
- synchronize
28+
- reopened
29+
- edited
30+
- review_requested
31+
- review_request_removed
32+
- ready_for_review
33+
- converted_to_draft
34+
- labeled
2535

2636
# Workflow jobs:
2737
jobs:
@@ -53,3 +63,73 @@ jobs:
5363
with:
5464
configuration-path: .github/labeler.yml
5565
repo-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
66+
67+
# Add "Needs Review" label when PR is opened and not a draft:
68+
- name: 'Add "Needs Review" label if PR is opened and not draft'
69+
if: ${{ github.event.action == 'opened' && github.event.pull_request.draft == false }}
70+
# Pin action to full length commit SHA
71+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
72+
with:
73+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
74+
script: |
75+
await github.rest.issues.addLabels({
76+
'owner': context.repo.owner,
77+
'repo': context.repo.repo,
78+
'issue_number': context.payload.pull_request.number,
79+
'labels': [ 'Needs Review' ]
80+
})
81+
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' }}
85+
# Pin action to full length commit SHA
86+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
87+
with:
88+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
89+
script: |
90+
await github.rest.issues.addLabels({
91+
'owner': context.repo.owner,
92+
'repo': context.repo.repo,
93+
'issue_number': context.payload.pull_request.number,
94+
'labels': [ 'Needs Review' ]
95+
})
96+
97+
# Remove "Needs Review" label when PR is converted to draft or closed:
98+
- name: 'Remove "Needs Review" label if PR is converted to draft or closed'
99+
if: ${{ github.event.action == 'converted_to_draft' || github.event.action == 'closed' }}
100+
# Pin action to full length commit SHA
101+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
102+
with:
103+
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
104+
script: |
105+
try {
106+
await github.rest.issues.removeLabel({
107+
'owner': context.repo.owner,
108+
'repo': context.repo.repo,
109+
'issue_number': context.payload.pull_request.number,
110+
'name': 'Needs Review'
111+
})
112+
} catch ( error ) {
113+
console.log( 'Error removing label: %s', error.message );
114+
}
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 & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -142,19 +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-
files=$(echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n' | grep 'package\.json$' | grep -v 'datapackage\.json$' | tr '\n' ' ' | sed 's/ $//')
152-
if [ -n "${files}" ]; then
153-
echo "Linting package.json files that have changed..."
154-
printf "${files}" | "${lint_package_json}" --split=" "
155-
else
156-
echo "No package.json files to lint."
157-
fi
145+
. "$GITHUB_WORKSPACE/.github/workflows/scripts/lint_package_json_files" "${{ steps.changed-files.outputs.files }}"
158146
159147
# Lint REPL help files...
160148
- 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: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@
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>
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-
#
3028
#
3129
# Environment variables:
3230
#
@@ -41,10 +39,9 @@ set -o pipefail
4139
# VARIABLES #
4240

4341
# Assign command line arguments to variables:
44-
workflow_url="$1"
45-
lint_type="$2"
42+
issue_title="$1"
43+
body_file="$2"
4644
parent_issue_number="$3"
47-
error_log_file="$4"
4845

4946
# Repository information:
5047
owner="stdlib-js"
@@ -57,28 +54,12 @@ if [ -z "$github_token" ]; then
5754
exit 1
5855
fi
5956

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}"
57+
# Read and validate the body file:
58+
if [ ! -f "$body_file" ]; then
59+
echo -e "ERROR: Body file not found: ${body_file}"
6360
exit 1
6461
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-
"
62+
issue_body=$(cat "$body_file")
8263

8364
# FUNCTIONS #
8465

@@ -130,7 +111,7 @@ create_child_issue() {
130111
"query": "mutation CreateIssue(\$repositoryId: ID!, \$title: String!, \$body: String!) { createIssue(input: {repositoryId: \$repositoryId, title: \$title, body: \$body}) { issue { id number } } }",
131112
"variables": {
132113
"repositoryId": "${repo_id}",
133-
"title": "Fix ${lint_type} lint errors",
114+
"title": "${issue_title}",
134115
"body": $(echo "$issue_body" | jq -R -s '.')
135116
}
136117
}
@@ -194,7 +175,7 @@ main() {
194175
exit 1
195176
fi
196177

197-
echo "Creating child issue for ${lint_type} lint failures..."
178+
echo "Creating child issue..."
198179
child_issue_response=$(create_child_issue "$repo_id" "$issue_body")
199180

200181
child_issue_id=$(echo "$child_issue_response" | jq -r '.data.createIssue.issue.id')
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
#
3+
# @license Apache-2.0
4+
#
5+
# Copyright (c) 2024 The Stdlib Authors.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
# Script to lint package.json files and check/update metadata fields.
20+
#
21+
# Usage: lint_package_json_files file1 [file2 file3 ...]
22+
#
23+
# Arguments:
24+
#
25+
# file1 File path.
26+
# file2 File path.
27+
# file3 File path.
28+
29+
# Determine root directory:
30+
root=$(git rev-parse --show-toplevel)
31+
32+
# Define the path to a utility for linting package.json files:
33+
lint_package_json="${root}/lib/node_modules/@stdlib/_tools/lint/pkg-json/bin/cli"
34+
35+
# Define paths to utilities for updating package.json metadata fields:
36+
update_package_json_directories="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_directories"
37+
update_package_json_gypfile="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile"
38+
39+
# Files to process:
40+
files_to_process="$*"
41+
42+
# Lint package.json files:
43+
files=$(echo "${files_to_process}" | tr ' ' '\n' | grep 'package\.json$' | grep -v 'datapackage\.json$' | tr '\n' ' ' | sed 's/ $//')
44+
if [ -n "${files}" ]; then
45+
echo "Linting package.json files..."
46+
printf '%s' "${files}" | "${lint_package_json}" --split=" "
47+
else
48+
echo "No package.json files to lint."
49+
fi
50+
51+
# Check if metadata fields need to be updated in package.json files of affected packages:
52+
dirs=$(echo "${files_to_process}" | tr ' ' '\n' | \
53+
xargs dirname | \
54+
sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?$//' | \
55+
sort -u)
56+
57+
echo "Checking package.json files in directories: ${dirs}"
58+
59+
needs_changes=0
60+
for dir in ${dirs}; do
61+
echo "Checking package.json in ${dir}..."
62+
package_json="${dir}/package.json"
63+
if [ ! -f "${package_json}" ]; then
64+
continue
65+
fi
66+
original_content=$(cat "${package_json}")
67+
68+
"${update_package_json_directories}" "${dir}"
69+
"${update_package_json_gypfile}" "${dir}"
70+
71+
new_content=$(cat "${package_json}")
72+
if [ "$original_content" != "$new_content" ]; then
73+
echo "ERROR: package.json in ${dir} needs updates to directories and/or gypfile fields"
74+
git --no-pager diff "${package_json}"
75+
needs_changes=1
76+
fi
77+
done
78+
79+
# Exit with failure if any needed changes were detected:
80+
if [ $needs_changes -eq 1 ]; then
81+
exit 1
82+
fi

0 commit comments

Comments
 (0)