Skip to content

Commit

Permalink
Merge branch 'stdlib-js:develop' into dtrmv
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-095 authored Jul 30, 2024
2 parents 1d6841c + b308eb8 commit 81ef001
Show file tree
Hide file tree
Showing 3,115 changed files with 83,761 additions and 20,826 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
9 changes: 3 additions & 6 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
Resolves # .
Resolves #{{TODO: add issue number}}.

## Description

> What is the purpose of this pull request?
This pull request:

- a
- b
- c
- {{TODO: add description describing what this pull request does}}

## Related Issues

> Does this pull request have any related issues?
This pull request:

- resolves #
- fixes #
- resolves #{{TODO: add issue number}}

## Questions

Expand Down
91 changes: 91 additions & 0 deletions .github/workflows/check_contributing_guidelines_acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#/
# @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: check_contributing_guidelines_acceptance

# Workflow triggers:
on:
# Allow the workflow to be triggered by other workflows
workflow_call:
# Define the input parameters for the workflow:
inputs:
pull_request_number:
description: 'Pull request number'
required: true
type: number
user:
required: true
type: string
# Define the secrets accessible by the workflow:
secrets:
STDLIB_BOT_GITHUB_TOKEN:
description: 'stdlib-bot GitHub token to create pull request comments'
required: true

# Trigger on pull request events:
pull_request_target:
types: [opened, reopened]

# Global permissions:
permissions:
# Allow read-only access to the repository contents:
contents: read

# Allow write access to pull requests:
pull-requests: write

# Workflow jobs:
jobs:

# Define a job for checking the contributing guidelines acceptance...
check_acknowledgment:

# Define a display name:
name: 'Check Contributing Guidelines Acceptance'

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

# Skip this job for PRs opened by the stdlib-bot:
if: github.event.pull_request.user.login != 'stdlib-bot'

# Define the sequence of job steps...
steps:
# Checkout the repository:
- name: 'Checkout repository'
# Pin action to full length commit SHA
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# Specify whether to remove untracked files before checking out the repository:
clean: true

# Limit clone depth to the most recent commit:
fetch-depth: 1

# Specify whether to download Git-LFS files:
lfs: false
timeout-minutes: 10

# Check contributing guidelines acceptance:
- name: 'Check contributing guidelines acceptance'
env:
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request_number }}
run: |
. "$GITHUB_WORKSPACE/.github/workflows/scripts/check_contributing_guidelines_acceptance" $PR_NUMBER
4 changes: 2 additions & 2 deletions .github/workflows/scaffold_pkg_via_branch_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
added-files: ${{ steps.changed-files.outputs.files }}

# Configure git:
- name: 'Configure git'
# Configure Git:
- name: 'Configure Git'
run: |
git config --local user.email "82920195+stdlib-bot@users.noreply.github.com"
git config --local user.name "stdlib-bot"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/scripts/add_trailing_newlines
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@
# 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 #

# List of file extensions to process:
extensions=("js" "mjs" "cjs" "json" "ts" "py" "jl" "R" "c" "h" "cpp" "hpp" "f" "sh" "awk" "html" "xml" "css" "md" "yml" "gypi" "bib" "tex")


# FUNCTIONS #

# Convert Windows CRLF to Unix LF line endings.
Expand Down
115 changes: 115 additions & 0 deletions .github/workflows/scripts/check_contributing_guidelines_acceptance
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#!/usr/bin/env 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 check if a pull request contains the checked contributing guidelines acknowledgment checkbox.
#
# Usage: check_contributing_guidelines 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"

# Set the repository name:
GITHUB_REPOSITORY="stdlib-js/stdlib"


# FUNCTIONS #

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

# Prints a success message.
print_success() {
echo 'Success!' >&2
}

# Main execution sequence.
main() {
echo "Checking contributing guidelines acknowledgment for PR #${pr_number}..."

# Fetch the pull request body:
if ! pr_body=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" | \
jq -r .body); then
echo "Failed to fetch PR body."
on_error 1
fi

# Check for the contributing guidelines checkbox:
if echo "${pr_body}" | grep -qE '^\s*-\s*\[x\]\s*Read,\s*understood,\s*and\s*followed\s*the\s*\[contributing\s*guidelines\]'; then
echo "Contributing guidelines acknowledged."
print_success
exit 0
else
echo "Contributing guidelines not acknowledged."

# Post a comment on the PR:
comment="Hello! Thank you for your contribution to stdlib.
We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
1. Please read our [contributing guidelines][contributing].
2. Update your pull request description to include this checked box:
\`- [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)\`
This acknowledgment confirms that you've read the guidelines, which include:
- The developer's certificate of origin
- Your agreement to license your contributions under the project's terms
We can't review or accept contributions without this acknowledgment.
Thank you for your understanding and cooperation. We look forward to reviewing your contribution!"

if ! curl -s -X POST \
-H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" \
-d "{\"body\":$(echo "$comment" | jq -R -s -c .)}"; then
echo "Failed to post comment on PR."
on_error 1
fi

exit 1
fi
}

# Set an error handler to print captured output and perform any clean-up tasks:
trap 'on_error' ERR

# Run main:
main
16 changes: 8 additions & 8 deletions .github/workflows/scripts/lint_javascript_files
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,35 @@ files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -v -e '/exam
# Build native addons if present:
packages=$(echo "${files}" | tr ' ' '\n' | sed 's/^lib\/node_modules\///g' | sed 's/\/lib\/.*//g' | sort | uniq)
for pkg in ${packages}; do
if [ -f "lib/node_modules/${pkg}/binding.gyp" ]; then
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
fi
if [ -f "lib/node_modules/${pkg}/binding.gyp" ]; then
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
fi
done

if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${fix}" FILES="${files}"
make lint-javascript-files FIX="${fix}" FILES="${files}"
fi

# Lint JavaScript command-line interfaces...
file=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -E '/bin/cli$' | tr '\n' ' ' | sed 's/ $//')
if [[ -n "${file}" ]]; then
make lint-javascript-files FIX="${fix}" FILES="${file}"
make lint-javascript-files FIX="${fix}" FILES="${file}"
fi

# Lint JavaScript example files:
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/examples/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_examples_conf}"
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_examples_conf}"
fi

# Lint JavaScript test files:
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/test/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_tests_conf}"
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_tests_conf}"
fi

# Lint JavaScript benchmark files:
files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '/benchmark/.*\.js$' | tr '\n' ' ' | sed 's/ $//')
if [[ -n "${files}" ]]; then
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
make lint-javascript-files FIX="${fix}" FILES="${files}" ESLINT_CONF="${eslint_benchmarks_conf}"
fi
48 changes: 24 additions & 24 deletions .github/workflows/scripts/remove_related_packages
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,30 @@
set -o pipefail

for file in ${@}; do
if [[ $file == *README.md ]]; then
awk '
BEGIN { print_mode = 1; in_related = 0; in_related_links = 0 }
/<section class="related">/ {
print; print ""; print "</section>";
in_related = 1; print_mode = 0; next
}
/<\/section>/ {
if (in_related) { in_related = 0; print_mode = 1 }
else { print }
next
}
/<!-- <related-links> -->/ {
print; print ""; print "<!-- </related-links> -->";
in_related_links = 1; print_mode = 0; next
}
/<!-- <\/related-links> -->/ {
if (in_related_links) { in_related_links = 0; print_mode = 1 }
else { print }
next
}
{ if (print_mode == 1) print }
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi
if [[ $file == *README.md ]]; then
awk '
BEGIN { print_mode = 1; in_related = 0; in_related_links = 0 }
/<section class="related">/ {
print; print ""; print "</section>";
in_related = 1; print_mode = 0; next
}
/<\/section>/ {
if (in_related) { in_related = 0; print_mode = 1 }
else { print }
next
}
/<!-- <related-links> -->/ {
print; print ""; print "<!-- </related-links> -->";
in_related_links = 1; print_mode = 0; next
}
/<!-- <\/related-links> -->/ {
if (in_related_links) { in_related_links = 0; print_mode = 1 }
else { print }
next
}
{ if (print_mode == 1) print }
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
fi
done

echo "All files processed successfully."
Loading

0 comments on commit 81ef001

Please sign in to comment.