Skip to content

Commit

Permalink
Merge branch 'stdlib-js:develop' into max-safe-fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjjoshi authored Sep 16, 2024
2 parents 73f0ca8 + a12d0f0 commit 10afe1b
Show file tree
Hide file tree
Showing 879 changed files with 80,440 additions and 2,680 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/autoclose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
If you would prefer to avoid manual setup, you could also consider using a pre-configured [development container](https://github.com/stdlib-js/stdlib/tree/develop/.devcontainer) for use locally or in GitHub Codespaces.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contriubtions.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
# Define a job which closes a pull request if a contributor failed to follow contributing guidelines:
contributor_guidelines:
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
If you would prefer to avoid manual setup, you could also consider using a pre-configured [development container](https://github.com/stdlib-js/stdlib/tree/develop/.devcontainer) for use locally or in GitHub Codespaces.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contriubtions.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
# Define a job which closes a pull request if a contributor failed to follow project conventions:
project_conventions:
Expand Down Expand Up @@ -138,7 +138,7 @@ jobs:
In short, the more effort you put in to ensure that your contribution looks and feels like stdlib—including variables names, bracket spacing, line breaks, etc—the more likely that your contribution will be reviewed and ultimately accepted. We encourage you to closely study the codebase **before** continuing to work on this pull request.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contriubtions.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
# Define a job which closes a pull request if a pull request is considered spam:
spam:
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
BODY: |
Thank you for working on this pull request. However, we cannot accept your contribution as this pull request does not meet the standards of this project.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contriubtions.
Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.
# Lock pull request conversation:
- name: 'Lock conversation'
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/generate_pr_commit_message.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/

# Workflow name:
name: generate_pr_commit_message

# Workflow triggers:
on:
pull_request:
types:
- labeled

# Global permissions:
permissions:
contents: read
issues: write
pull-requests: write

# Workflow jobs:
jobs:

# Job to generate commit message draft:
generate-commit-message:

# Define a display name:
name: 'Generate PR Commit Message Draft'

# Define the type of virtual host machine:
runs-on: ubuntu-latest

# Ensure the job only runs when the specified label is added:
if: github.event.label.name == 'Ready to Merge'

# Define environment variables:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}

# Define the sequence of job steps...
steps:
# Checkout repository:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
# Fetch all commits to ensure we have the full commit history:
fetch-depth: 0

# Generate commit message:
- name: 'Generate commit message'
id: commit_message
run: |
COMMIT_MESSAGE=$($GITHUB_WORKSPACE/.github/workflows/scripts/generate_pr_commit_message $PR_NUMBER)
echo "commit_message<<EOF" >> $GITHUB_OUTPUT
echo "$COMMIT_MESSAGE" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# Post commit message as PR comment:
- name: 'Post commit message as PR comment'
uses: peter-evans/create-or-update-comment@v3
with:
token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body: |
### PR Commit Message
```text
${{ steps.commit_message.outputs.commit_message }}
```
*Please review the above commit message and make any necessary adjustments.*
2 changes: 1 addition & 1 deletion .github/workflows/good_first_issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
In short, the more effort you put in to ensure that your contribution looks and feels like stdlib—including variables names, bracket spacing, line breaks, etc—the more likely that your contribution will be reviewed and ultimately accepted. We encourage you to closely study the codebase **before** beginning work on this issue.
:sparkles: Thank you again for your interest in stdlib, and we look forward to reviewing your future contriubtions. :sparkles:
:sparkles: Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions. :sparkles:
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ GITHUB_REPOSITORY="stdlib-js/stdlib"
# Set the contributing guidelines link:
CONTRIBUTING_LINK="https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md"


# FUNCTIONS #

# Error handler.
Expand Down
162 changes: 162 additions & 0 deletions .github/workflows/scripts/generate_pr_commit_message
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#!/bin/bash
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/

# Script to generate a commit message for a pull request.
#
# Usage: generate_pr_commit_message PR_NUMBER
#
# Arguments:
#
# PR_NUMBER Pull request number.
#
# Environment variables:
#
# GITHUB_TOKEN GitHub token for authentication.

# Ensure that the exit status of pipelines is non-zero in the event that at least one of the commands in a pipeline fails:
set -o pipefail


# VARIABLES #

# Get the pull request number:
pr_number="$1"

# GitHub API base URL
GITHUB_API_URL="https://api.github.com"

# Repository owner and name
REPO_OWNER="stdlib-js"
REPO_NAME="stdlib"


# FUNCTIONS #

# Error handler.
#
# $1 - error status
on_error() {
echo 'ERROR: An error was encountered during execution.' >&2
exit "$1"
}

# Function to resolve GitHub handle to name and email using .mailmap
#
# $1 - GitHub handle
resolve_user() {
local github_handle="$1"
local mailmap_file=".mailmap"
local name_email

# Try to find a match for the GitHub handle:
name_email=$(grep -i "$github_handle" "$mailmap_file" | head -n 1)

if [ -n "$name_email" ]; then
# Extract name and email from the matching line:
echo "$name_email" | sed -E 's/^(.*)<(.*)>.*$/\1 <\2>/' | xargs
else
# If no match found, use the GitHub handle as is:
echo "$github_handle <$github_handle@users.noreply.github.com>"
fi
}

# Function to make authenticated GitHub API requests
#
# $1 - HTTP method (GET or POST)
# $2 - API endpoint
# $3 - Data for POST requests
github_api() {
local method="$1"
local endpoint="$2"
local data="$3"

if [ "$method" == "GET" ]; then
curl -s -H "Authorization: token $GITHUB_TOKEN" "$GITHUB_API_URL$endpoint"
elif [ "$method" == "POST" ]; then
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/json" -d "$data" "$GITHUB_API_URL$endpoint"
else
echo "Invalid HTTP method: $method"
on_error 1
fi
}

# Main execution sequence.
main() {
# Fetch pull request details:
pr_details=$(github_api "GET" "/repos/$REPO_OWNER/$REPO_NAME/pulls/$pr_number")
pr_title=$(echo "$pr_details" | jq -r '.title')
pr_body=$(echo "$pr_details" | jq -r '.body // ""')
pr_url=$(echo "$pr_details" | jq -r '.html_url')

# Extract reviewers:
pr_reviews=$(github_api "GET" "/repos/$REPO_OWNER/$REPO_NAME/pulls/$pr_number/reviews")
reviewers=$(echo "$pr_reviews" | jq -r '.[] | select(.state == "APPROVED" ) | .user.login' | sort -u)

# Fetch commits in the PR:
pr_commits=$(github_api "GET" "/repos/$REPO_OWNER/$REPO_NAME/pulls/$pr_number/commits")

# Extract co-authors from commits:
co_authors=$(echo "$pr_commits" | jq -r '.[].commit.message' | grep -i "Co-authored-by:" | awk -F': ' '{print $2}' | sort | uniq | paste -sd '\n' -)

# Extract linked issues from PR body (e.g., #123)
issue_numbers=$(echo "$pr_body" | grep -oE '#[0-9]+' | grep -oE '[0-9]+' | sort | uniq)
closes_issues=""
ref_issues=""
for issue in $issue_numbers; do
if echo "$pr_body" | grep -qi "closes.*#$issue"; then
closes_issues+="Closes: https://github.com/$REPO_OWNER/$REPO_NAME/issues/$issue\n"
else
ref_issues+="Ref: https://github.com/$REPO_OWNER/$REPO_NAME/issues/$issue\n"
fi
done
closes_issues=$(echo -e "$closes_issues" | sed '$ s/\n$//')
ref_issues=$(echo -e "$ref_issues" | sed '$ s/\n$//')

# Assemble commit message components:
commit_subject="$pr_title"
commit_body="PR-URL: $pr_url"

if [ -n "$closes_issues" ]; then
commit_body+="\n$closes_issues"
fi
if [ -n "$ref_issues" ]; then
commit_body+="\n$ref_issues"
fi
if [ -n "$co_authors" ]; then
commit_body+="\n$co_authors"
fi
for reviewer in $reviewers; do
resolved_reviewer=$(resolve_user "$reviewer")
commit_body+="\nReviewed-by: $resolved_reviewer"
done

# Add Signed-off-by line:
pr_author=$(echo "$pr_details" | jq -r '.user.login')
signed_off_by=$(resolve_user "$pr_author")
commit_body+="\nSigned-off-by: $signed_off_by"

# Combine subject and body:
commit_message="$commit_subject\n\n$commit_body"

# Output the commit message:
echo -e "$commit_message"
}

# Call main with all command-line arguments:
main "$@"
2 changes: 1 addition & 1 deletion .github/workflows/windows_test_npm_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ jobs:
TEST_NPM_INSTALL_GITHUB_URL: 'https://github.com/stdlib-js/stdlib'
run: |
. "${{ env.NVS_HOME }}/nvs.sh" && nvs use ${{ matrix.NODE_VERSION }}
. "./.github/workflows/scripts/task_runner" ${{ matrix.BUILD_TASK }} "${{ env.LOG_FILE_BUILD_TASK }}"
. "$GITHUB_WORKSPACE/.github/workflows/scripts/task_runner" ${{ matrix.BUILD_TASK }} "${{ env.LOG_FILE_BUILD_TASK }}"
timeout-minutes: 360

# View the log file if the previous step fails:
Expand Down
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ Stephannie Jiménez Gacha <[email protected]> Stephannie Jimenez Gacha

Tudor Pagu <[email protected]> tudor-pagu

Tufailahmed Bargir <[email protected]> Tufailahmed-Bargir

# U

Utkarsh <http://[email protected]> <[email protected]>
Expand All @@ -156,6 +158,8 @@ Utkarsh Raj <[email protected]> utkarsh_raj

# V

Vaibhav Patel <[email protected]> ProCoderVP

Varad Gupta <[email protected]> <[email protected]>
Varad Gupta <[email protected]> vr-varad

Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Contributors listed in alphabetical order.

Aayush Khanna <[email protected]>
Adarsh Palaskar <[email protected]>
Aditya Sapra <[email protected]>
AgPriyanshu18 <[email protected]>
Expand Down Expand Up @@ -32,6 +33,7 @@ Hridyanshu <[email protected]>
Jaimin Godhani <[email protected]>
James Gelok <[email protected]>
Jaysukh Makvana <[email protected]>
Jenish Thapa <[email protected]>
Jithin KS <[email protected]>
Joel Mathew Koshy <[email protected]>
Joey Reed <[email protected]>
Expand Down Expand Up @@ -87,8 +89,10 @@ Stephannie Jiménez Gacha <[email protected]>
Suraj kumar <[email protected]>
Tirtadwipa Manunggal <[email protected]>
Tudor Pagu <[email protected]>
Tufailahmed Bargir <[email protected]>
Utkarsh <http://[email protected]>
Utkarsh Raj <[email protected]>
Vaibhav Patel <[email protected]>
Varad Gupta <[email protected]>
Xiaochuan Ye <[email protected]>
Yernar Yergaziyev <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion etc/eslint/rules/stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -4231,7 +4231,8 @@ rules[ 'stdlib/no-redeclare' ] = [ 'error', {
'Uint8ClampedArray',
'Uint16Array',
'Uint32Array',
'URIError'
'URIError',
'WebAssembly'
]
}];

Expand Down
9 changes: 9 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,15 @@ setReadOnly( stdlib, 'types', require( '@stdlib/types' ) );
*/
setReadOnly( stdlib, 'utils', require( '@stdlib/utils' ) );

/**
* @name wasm
* @memberof stdlib
* @readonly
* @type {Namespace}
* @see {@link module:@stdlib/wasm}
*/
setReadOnly( stdlib, 'wasm', require( '@stdlib/wasm' ) );


// EXPORTS //

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ var EXT = [
'py',
'R',
'sh',
'ts',
'wat',
'yml',
'default' // Not a language, but serves as a fallback when unable to determine a file type based on filename extension or basename
];

// Leading comment characters: /** (JS, C, C++), /* (CSS), !> (Fortran), # (R, Python, Julia, AWK, bash, GYP), #/ (make, YAML, INI), <!-- (HTML, Markdown)
var RE_LEADING_COMMENT = /^\/\*\*|^\/\*|^!>|^#\/{0,1}|^<!--/;
// Leading comment characters: /** (JS, C, C++), /* (CSS), !> (Fortran), # (R, Python, Julia, AWK, bash, GYP), ;; (WAT), #/ (make, YAML, INI), <!-- (HTML, Markdown)
var RE_LEADING_COMMENT = /^\/\*\*|^\/\*|^!>|^#\/{0,1}|^;;|^<!--/;

// Trailing comment characters: */ (JS, C, C++), */ (CSS), !< (Fortran), #/ (make, YAML, INI), --> (HTML, Markdown)
var RE_TRAILING_COMMENT = /\*\/$|!<$|#\/$|-->$/;
Expand Down
Loading

0 comments on commit 10afe1b

Please sign in to comment.