forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'stdlib-js:develop' into max-safe-fibonacci
- Loading branch information
Showing
879 changed files
with
80,440 additions
and
2,680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|
@@ -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 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# | ||
# Contributors listed in alphabetical order. | ||
|
||
Aayush Khanna <[email protected]> | ||
Adarsh Palaskar <[email protected]> | ||
Aditya Sapra <[email protected]> | ||
AgPriyanshu18 <[email protected]> | ||
|
@@ -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]> | ||
|
@@ -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]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.