Skip to content

Commit 7927319

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 308005e + 6f3e683 commit 7927319

File tree

17 files changed

+309
-89
lines changed

17 files changed

+309
-89
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 The Stdlib Authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#/
18+
19+
# Workflow name:
20+
name: check_contributing_guidelines_acceptance
21+
22+
# Workflow triggers:
23+
on:
24+
# Allow the workflow to be triggered by other workflows
25+
workflow_call:
26+
# Define the input parameters for the workflow:
27+
inputs:
28+
pull_request_number:
29+
description: 'Pull request number'
30+
required: true
31+
type: number
32+
user:
33+
required: true
34+
type: string
35+
# Define the secrets accessible by the workflow:
36+
secrets:
37+
STDLIB_BOT_GITHUB_TOKEN:
38+
description: 'stdlib-bot GitHub token to create pull request comments'
39+
required: true
40+
41+
# Trigger on pull request events:
42+
pull_request_target:
43+
types: [opened, edited, synchronize, reopened]
44+
45+
# Global permissions:
46+
permissions:
47+
# Allow read-only access to the repository contents:
48+
contents: read
49+
50+
# Allow write access to pull requests:
51+
pull-requests: write
52+
53+
# Workflow jobs:
54+
jobs:
55+
56+
# Define a job for checking the contributing guidelines acknowledgment...
57+
check_acknowledgment:
58+
59+
# Define a display name:
60+
name: 'Check Contributing Guidelines Acknowledgment'
61+
62+
# Define the type of virtual host machine:
63+
runs-on: ubuntu-latest
64+
65+
# Define the sequence of job steps...
66+
steps:
67+
# Checkout the repository:
68+
- name: 'Checkout repository'
69+
# Pin action to full length commit SHA
70+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
71+
with:
72+
# Specify whether to remove untracked files before checking out the repository:
73+
clean: true
74+
75+
# Limit clone depth to the most recent commit:
76+
fetch-depth: 1
77+
78+
# Specify whether to download Git-LFS files:
79+
lfs: false
80+
timeout-minutes: 10
81+
82+
# Check contributing guidelines acceptance:
83+
- name: 'Check contributing guidelines acceptance'
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
86+
PR_NUMBER: ${{ github.event.pull_request.number || inputs.pull_request_number }}
87+
run: |
88+
. "$GITHUB_WORKSPACE/.github/workflows/scripts/check_contributing_guidelines_acceptance" $PR_NUMBER
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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 check if a pull request contains the checked contributing guidelines acknowledgment checkbox.
20+
#
21+
# Usage: check_contributing_guidelines PR_NUMBER
22+
#
23+
# Arguments:
24+
#
25+
# PR_NUMBER Pull request number.
26+
#
27+
# Environment variables:
28+
#
29+
# GITHUB_TOKEN GitHub token for authentication.
30+
31+
# Ensure that the exit status of pipelines is non-zero in the event that at least one of the commands in a pipeline fails:
32+
set -o pipefail
33+
34+
# VARIABLES #
35+
36+
# Get the pull request number:
37+
pr_number="$1"
38+
39+
# Set the repository name:
40+
GITHUB_REPOSITORY="stdlib-js/stdlib"
41+
42+
# Set the contributing guidelines link:
43+
CONTRIBUTING_LINK="https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md"
44+
45+
# FUNCTIONS #
46+
47+
# Error handler.
48+
#
49+
# $1 - error status
50+
on_error() {
51+
echo 'ERROR: An error was encountered during execution.' >&2
52+
exit "$1"
53+
}
54+
55+
# Prints a success message.
56+
print_success() {
57+
echo 'Success!' >&2
58+
}
59+
60+
# Main execution sequence.
61+
main() {
62+
echo "Checking contributing guidelines acknowledgment for PR #${pr_number}..."
63+
64+
# Fetch the pull request body:
65+
if ! pr_body=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" \
66+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" | \
67+
jq -r .body); then
68+
echo "Failed to fetch PR body."
69+
on_error 1
70+
fi
71+
72+
# Check for the contributing guidelines checkbox:
73+
if echo "${pr_body}" | grep -qE '^\s*-\s*\[x\]\s*Read,\s*understood,\s*and\s*followed\s*the\s*\[contributing\s*guidelines\]'; then
74+
echo "Contributing guidelines acknowledged."
75+
print_success
76+
exit 0
77+
else
78+
echo "Contributing guidelines not acknowledged."
79+
80+
# Post a comment on the PR:
81+
comment="Hello! Thank you for your contribution to stdlib.
82+
83+
We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
84+
85+
1. Please read our [contributing guidelines][contributing].
86+
2. Update your pull request description to include this checked box:
87+
88+
\`- [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)\`
89+
90+
This acknowledgment confirms that you've read the guidelines, which include:
91+
92+
- The developer's certificate of origin
93+
- Your agreement to license your contributions under the project's terms
94+
95+
We can't review or accept contributions without this acknowledgment.
96+
97+
Thank you for your understanding and cooperation. We look forward to reviewing your contribution!
98+
99+
[contributing]: ${CONTRIBUTING_LINK}"
100+
101+
if ! curl -s -X POST \
102+
-H "Authorization: token ${GITHUB_TOKEN}" \
103+
-H "Accept: application/vnd.github.v3+json" \
104+
"https://api.github.com/repos/${GITHUB_REPOSITORY}/issues/${pr_number}/comments" \
105+
-d "{\"body\":$(echo "$comment" | jq -R -s -c .)}"; then
106+
echo "Failed to post comment on PR."
107+
on_error 1
108+
fi
109+
110+
exit 1
111+
fi
112+
}
113+
114+
# Set an error handler to print captured output and perform any clean-up tasks:
115+
trap 'on_error' ERR
116+
117+
# Run main:
118+
main

.github/workflows/scripts/lint_javascript_files

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,35 @@ files=$(echo "${files_to_lint}" | tr ' ' '\n' | grep '\.js$' | grep -v -e '/exam
5454
# Build native addons if present:
5555
packages=$(echo "${files}" | tr ' ' '\n' | sed 's/^lib\/node_modules\///g' | sed 's/\/lib\/.*//g' | sort | uniq)
5656
for pkg in ${packages}; do
57-
if [ -f "lib/node_modules/${pkg}/binding.gyp" ]; then
58-
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
59-
fi
57+
if [ -f "lib/node_modules/${pkg}/binding.gyp" ]; then
58+
NODE_ADDONS_PATTERN="${pkg}" make install-node-addons
59+
fi
6060
done
6161

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

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

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

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

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

.github/workflows/scripts/remove_related_packages

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,30 @@
3232
set -o pipefail
3333

3434
for file in ${@}; do
35-
if [[ $file == *README.md ]]; then
36-
awk '
37-
BEGIN { print_mode = 1; in_related = 0; in_related_links = 0 }
38-
/<section class="related">/ {
39-
print; print ""; print "</section>";
40-
in_related = 1; print_mode = 0; next
41-
}
42-
/<\/section>/ {
43-
if (in_related) { in_related = 0; print_mode = 1 }
44-
else { print }
45-
next
46-
}
47-
/<!-- <related-links> -->/ {
48-
print; print ""; print "<!-- </related-links> -->";
49-
in_related_links = 1; print_mode = 0; next
50-
}
51-
/<!-- <\/related-links> -->/ {
52-
if (in_related_links) { in_related_links = 0; print_mode = 1 }
53-
else { print }
54-
next
55-
}
56-
{ if (print_mode == 1) print }
57-
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
58-
fi
35+
if [[ $file == *README.md ]]; then
36+
awk '
37+
BEGIN { print_mode = 1; in_related = 0; in_related_links = 0 }
38+
/<section class="related">/ {
39+
print; print ""; print "</section>";
40+
in_related = 1; print_mode = 0; next
41+
}
42+
/<\/section>/ {
43+
if (in_related) { in_related = 0; print_mode = 1 }
44+
else { print }
45+
next
46+
}
47+
/<!-- <related-links> -->/ {
48+
print; print ""; print "<!-- </related-links> -->";
49+
in_related_links = 1; print_mode = 0; next
50+
}
51+
/<!-- <\/related-links> -->/ {
52+
if (in_related_links) { in_related_links = 0; print_mode = 1 }
53+
else { print }
54+
next
55+
}
56+
{ if (print_mode == 1) print }
57+
' "$file" > "${file}.tmp" && mv "${file}.tmp" "$file"
58+
fi
5959
done
6060

6161
echo "All files processed successfully."

.github/workflows/scripts/track_fixmes

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ comment="<!-- This comment is automatically generated by a GitHub Action. -->
2525

2626
# Search for FIXME annotations in the codebase:
2727
for file in $(find bin dist docs tools etc examples lib test tools -type f); do
28-
fixmes=$(grep -E -on "FIXME:" $file) || true
29-
for fixme in $fixmes; do
30-
if [ -n "$fixme" ]; then
31-
# Since a maximum of 65,535 characters can be included in a GitHub comment body, we break out of the loop if the comment body would exceed this limit.
32-
if [ $(( ${#comment} + ${#fixme} )) -gt 65535 ]; then
33-
break
34-
fi
35-
lineNumber=$(echo $fixme | cut -d ":" -f 1)
36-
lineContent=$(awk "NR==$lineNumber" $file)
37-
lineContent=$(echo $lineContent | sed -e 's/<!--/\\<!--/g' -e 's/-->/\\-->/g')
38-
if [ ${#lineContent} -gt 80 ]; then
39-
lineContent=$(echo $lineContent | cut -c 1-80)
40-
lineContent="$lineContent..."
41-
continue
42-
fi
43-
comment="$comment
28+
fixmes=$(grep -E -on "FIXME:" $file) || true
29+
for fixme in $fixmes; do
30+
if [ -n "$fixme" ]; then
31+
# Since a maximum of 65,535 characters can be included in a GitHub comment body, we break out of the loop if the comment body would exceed this limit.
32+
if [ $(( ${#comment} + ${#fixme} )) -gt 65535 ]; then
33+
break
34+
fi
35+
lineNumber=$(echo $fixme | cut -d ":" -f 1)
36+
lineContent=$(awk "NR==$lineNumber" $file)
37+
lineContent=$(echo $lineContent | sed -e 's/<!--/\\<!--/g' -e 's/-->/\\-->/g')
38+
if [ ${#lineContent} -gt 80 ]; then
39+
lineContent=$(echo $lineContent | cut -c 1-80)
40+
lineContent="$lineContent..."
41+
continue
42+
fi
43+
comment="$comment
4444
- [$file#L$lineNumber](https://github.com/stdlib-js/stdlib/blob/develop/$file#L$lineNumber): $lineContent"
45-
fi
46-
done
45+
fi
46+
done
4747
done
4848

4949
echo "$comment"

.github/workflows/scripts/track_todos

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ comment="<!-- This comment is automatically generated by a GitHub Action. -->
2525

2626
# Search for TODO annotations in the codebase:
2727
for file in $(find bin dist docs tools etc examples lib test tools -type f); do
28-
todos=$(grep -E -on "TODO:" $file) || true
29-
for todo in $todos; do
30-
if [ -n "$todo" ]; then
31-
# Since a maximum of 65,535 characters can be included in a GitHub comment body, we break out of the loop if the comment body would exceed this limit.
32-
if [ $(( ${#comment} + ${#todo} )) -gt 65535 ]; then
33-
break
34-
fi
35-
lineNumber=$(echo $todo | cut -d ":" -f 1)
36-
lineContent=$(awk "NR==$lineNumber" $file)
37-
lineContent=$(echo $lineContent | sed -e 's/<!--/\\<!--/g' -e 's/-->/\\-->/g')
38-
if [ ${#lineContent} -gt 80 ]; then
39-
lineContent=$(echo $lineContent | cut -c 1-80)
40-
lineContent="$lineContent..."
41-
continue
42-
fi
43-
comment="$comment
28+
todos=$(grep -E -on "TODO:" $file) || true
29+
for todo in $todos; do
30+
if [ -n "$todo" ]; then
31+
# Since a maximum of 65,535 characters can be included in a GitHub comment body, we break out of the loop if the comment body would exceed this limit.
32+
if [ $(( ${#comment} + ${#todo} )) -gt 65535 ]; then
33+
break
34+
fi
35+
lineNumber=$(echo $todo | cut -d ":" -f 1)
36+
lineContent=$(awk "NR==$lineNumber" $file)
37+
lineContent=$(echo $lineContent | sed -e 's/<!--/\\<!--/g' -e 's/-->/\\-->/g')
38+
if [ ${#lineContent} -gt 80 ]; then
39+
lineContent=$(echo $lineContent | cut -c 1-80)
40+
lineContent="$lineContent..."
41+
continue
42+
fi
43+
comment="$comment
4444
- [$file#L$lineNumber](https://github.com/stdlib-js/stdlib/blob/develop/$file#L$lineNumber): $lineContent"
45-
fi
46-
done
45+
fi
46+
done
4747
done
4848

4949
echo "$comment"

0 commit comments

Comments
 (0)