Skip to content

Commit b3f1175

Browse files
authored
Merge branch 'develop' into feature/add
Signed-off-by: Athan <[email protected]>
2 parents 77543cb + 3123b73 commit b3f1175

File tree

18,015 files changed

+1129478
-196045
lines changed

Some content is hidden

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

18,015 files changed

+1129478
-196045
lines changed

.github/workflows/pr_commands_comment.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ on:
2929
description: 'Pull request number'
3030
required: true
3131
type: number
32+
debug:
33+
description: 'Enable debug output'
34+
required: false
35+
default: false
36+
type: boolean
3237

3338
# Define the secrets accessible by the workflow:
3439
secrets:
@@ -43,6 +48,14 @@ on:
4348
description: 'Pull request number'
4449
required: true
4550
type: number
51+
debug:
52+
description: 'Enable debug output'
53+
required: false
54+
default: 'false'
55+
type: choice
56+
options:
57+
- 'true'
58+
- 'false'
4659

4760
# Global permissions:
4861
permissions:
@@ -63,11 +76,23 @@ jobs:
6376

6477
# Define the sequence of job steps...
6578
steps:
79+
# Checkout the repository:
80+
- name: 'Checkout repository'
81+
# Pin action to full length commit SHA
82+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
83+
with:
84+
# Ensure we have access to the scripts directory:
85+
sparse-checkout: |
86+
.github/workflows/scripts
87+
sparse-checkout-cone-mode: false
88+
timeout-minutes: 10
6689

6790
# Leave comment with package make command instructions:
6891
- name: 'Leave comment with package make command instructions'
6992
env:
7093
PR_NUMBER: ${{ inputs.pull_request_number }}
94+
GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN || secrets.STDLIB_BOT_PAT_REPO_WRITE }}
95+
DEBUG: ${{ inputs.debug || 'false' }}
7196
run: |
7297
. "$GITHUB_WORKSPACE/.github/workflows/scripts/package_commands_comment" "$PR_NUMBER"
7398
timeout-minutes: 30
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2025 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: random_benchmarks
21+
22+
# Workflow triggers:
23+
on:
24+
# Trigger the workflow every 24 hours:
25+
schedule:
26+
- cron: '0 0 * * *'
27+
28+
# Allow the workflow to be manually run:
29+
workflow_dispatch:
30+
31+
# Global permissions:
32+
permissions:
33+
# Allow read-only access to the repository contents:
34+
contents: read
35+
36+
# Workflow jobs:
37+
jobs:
38+
39+
# Define a job for running random benchmarks...
40+
process:
41+
42+
# Define a display name:
43+
name: 'Run random benchmarks'
44+
45+
# Ensure the job does not run on forks:
46+
if: github.repository == 'stdlib-js/stdlib'
47+
48+
# Define the type of virtual host machine:
49+
runs-on: ubuntu-latest
50+
51+
# Define the sequence of job steps...
52+
steps:
53+
# Checkout the repository:
54+
- name: 'Checkout repository'
55+
# Pin action to full length commit SHA
56+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
57+
with:
58+
# Specify whether to remove untracked files before checking out the repository:
59+
clean: true
60+
61+
# Limit clone depth to the last 1000 commits:
62+
fetch-depth: 1000
63+
64+
# Specify whether to download Git-LFS files:
65+
lfs: false
66+
67+
# Avoid storing GitHub token in local Git configuration:
68+
persist-credentials: false
69+
timeout-minutes: 10
70+
71+
# Install Node.js:
72+
- name: 'Install Node.js'
73+
# Pin action to full length commit SHA
74+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
75+
with:
76+
node-version: '18' # 'lts/*'
77+
timeout-minutes: 5
78+
79+
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
80+
- name: 'Install dependencies'
81+
run: |
82+
make install-node-modules || make install-node-modules || make install-node-modules
83+
timeout-minutes: 15
84+
85+
# Run JavaScript and native add-on benchmarks:
86+
- name: 'Run JavaScript and native add-on benchmarks'
87+
run: |
88+
make benchmark-random-javascript RANDOM_SELECTION_SIZE=50 BUILD_ADDONS=1
89+
timeout-minutes: 60
90+
91+
# Run C benchmarks:
92+
- name: 'Run C benchmarks'
93+
run: |
94+
make benchmark-random-c RANDOM_SELECTION_SIZE=10
95+
timeout-minutes: 60

.github/workflows/random_examples.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,9 @@ jobs:
8787
run: |
8888
make examples-random-javascript RANDOM_SELECTION_SIZE=50
8989
timeout-minutes: 60
90+
91+
# Run C examples:
92+
- name: 'Run C examples'
93+
run: |
94+
make examples-random-c RANDOM_SELECTION_SIZE=10
95+
timeout-minutes: 60

.github/workflows/run_affected_benchmarks.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ jobs:
5050

5151
# Define a job for running changed benchmarks...
5252
process:
53-
5453
# Define a display name:
5554
name: 'Run affected benchmarks'
5655

56+
# Only run this job if a pull request does not have a "ci: Skip" label:
57+
if: "${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci: Skip') }}"
58+
5759
# Define the type of virtual host machine:
5860
runs-on: ubuntu-latest
5961

@@ -149,4 +151,4 @@ jobs:
149151
directories="${{ steps.changed-directories.outputs.directories }}"
150152
fi
151153
. "$GITHUB_WORKSPACE/.github/workflows/scripts/run_affected_benchmarks" "$directories"
152-
timeout-minutes: 30
154+
timeout-minutes: 60

.github/workflows/run_affected_examples.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
# Define a display name:
5252
name: 'Run changed examples'
5353

54+
# Only run this job if a pull request does not have a "ci: Skip" label:
55+
if: "${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci: Skip') }}"
56+
5457
# Define the type of virtual host machine:
5558
runs-on: ubuntu-latest
5659

.github/workflows/run_affected_tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ jobs:
8686
# Define a display name:
8787
name: 'Run affected tests'
8888

89+
# Only run this job if a pull request does not have a "ci: Skip" label:
90+
if: "${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci: Skip') }}"
91+
8992
# Define the type of virtual host machine:
9093
runs-on: ubuntu-latest
9194

.github/workflows/run_tests_coverage.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ jobs:
8686
# Define a display name:
8787
name: 'Calculate test coverage for packages'
8888

89+
# Only run this job if a pull request does not have a "ci: Skip" label:
90+
if: "${{ github.event_name != 'pull_request' || !contains(github.event.pull_request.labels.*.name, 'ci: Skip') }}"
91+
8992
# Define the type of virtual host machine:
9093
runs-on: ubuntu-latest
9194

.github/workflows/scripts/lint_package_json_files

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,30 @@ root=$(git rev-parse --show-toplevel)
3232
# Define the path to a utility for linting package.json files:
3333
lint_package_json="${root}/lib/node_modules/@stdlib/_tools/lint/pkg-json/bin/cli"
3434

35+
# Define the path to the package name validation tool:
36+
validate_package_names="${root}/lib/node_modules/@stdlib/_tools/lint/pkg-json-names/bin/cli"
37+
3538
# Define paths to utilities for updating package.json metadata fields:
3639
update_package_json_directories="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_directories"
3740
update_package_json_gypfile="${root}/lib/node_modules/@stdlib/_tools/package-json/scripts/update_gypfile"
3841

3942
# Files to process:
4043
files_to_process="$*"
4144

45+
# Initialize needs_changes flag:
46+
needs_changes=0
47+
4248
# Lint package.json files:
4349
files=$(echo "${files_to_process}" | tr ' ' '\n' | grep 'package\.json$' | grep -v 'datapackage\.json$' | tr '\n' ' ' | sed 's/ $//')
4450
if [ -n "${files}" ]; then
4551
echo "Linting package.json files..."
4652
printf '%s' "${files}" | "${lint_package_json}" --split=" "
53+
54+
echo "Validating package names..."
55+
if ! printf '%s' "${files}" | "${validate_package_names}" --split=" "; then
56+
echo "ERROR: Package name validation failed"
57+
needs_changes=1
58+
fi
4759
else
4860
echo "No package.json files to lint."
4961
fi
@@ -55,8 +67,6 @@ dirs=$(echo "${files_to_process}" | tr ' ' '\n' | \
5567
sort -u)
5668

5769
echo "Checking package.json files in directories: ${dirs}"
58-
59-
needs_changes=0
6070
for dir in ${dirs}; do
6171
echo "Checking package.json in ${dir}..."
6272
package_json="${dir}/package.json"

.github/workflows/scripts/package_commands_comment

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# Environment variables:
2828
#
2929
# GITHUB_TOKEN GitHub token for authentication.
30+
# DEBUG Whether to enable verbose debug output. Default: `false`.
3031

3132
# Ensure that the exit status of pipelines is non-zero in the event that at least one of the commands in a pipeline fails:
3233
set -o pipefail
@@ -44,9 +45,22 @@ github_api_url="https://api.github.com"
4445
repo_owner="stdlib-js"
4546
repo_name="stdlib"
4647

48+
# Set debug mode:
49+
debug="${DEBUG:-false}"
50+
4751

4852
# FUNCTIONS #
4953

54+
# Prints debug messages if DEBUG environment variable is set to "true".
55+
#
56+
# $1 - debug message
57+
debug_log() {
58+
# Only print debug messages if DEBUG environment variable is set to "true":
59+
if [ "$debug" = true ]; then
60+
echo "[DEBUG] $1" >&2
61+
fi
62+
}
63+
5064
# Error handler.
5165
#
5266
# $1 - error status
@@ -70,6 +84,8 @@ github_api() {
7084
local endpoint="$2"
7185
local data="$3"
7286

87+
debug_log "Making API request: ${method} ${endpoint}"
88+
7389
# Initialize an array to hold curl headers:
7490
local headers=()
7591

@@ -117,12 +133,20 @@ main() {
117133
on_error 1
118134
fi
119135

136+
debug_log "Processing PR #${pr_number}"
137+
120138
# Fetch changed files in pull request:
121139
response=$(github_api "GET" "/repos/${repo_owner}/${repo_name}/pulls/${pr_number}/files?per_page=100")
122140
files=$(echo "${response}" | jq -r '.[] | .filename')
141+
debug_log "Found $(echo "${files}" | wc -l) changed files"
123142

124143
# Extract files associated with native add-ons:
125-
c_files=$(echo "${files}" | grep -e '/benchmark/c' -e '/examples/c' -e '/binding.gyp' -e '/include.gypi' -e '/src/')
144+
c_files=$(echo "${files}" | grep -e '/benchmark/c' -e '/examples/c' -e '/binding.gyp' -e '/include.gypi' -e '/src/' || true)
145+
if [[ -z "${c_files}" ]]; then
146+
debug_log "No native add-on files found"
147+
else
148+
debug_log "Found native add-on files: $(echo "${c_files}" | wc -l) files"
149+
fi
126150

127151
# Find unique package directories:
128152
directories=$(echo "${files}" | tr ' ' '\n' | \
@@ -133,6 +157,7 @@ main() {
133157

134158
# Extract package names from changed package directories (e.g., @stdlib/math/base/special/sin) by removing the leading 'lib/node_modules/':
135159
packages=$(echo "${directories}" | sed -E 's/^lib\/node_modules\///')
160+
debug_log "Found packages: $(echo "${packages}" | tr '\n' ' ')"
136161

137162
# Documentation links:
138163
docs_links="
@@ -148,9 +173,11 @@ main() {
148173

149174
# Count the number of packages:
150175
package_count=$(echo "${packages}" | wc -l)
176+
debug_log "Package count: ${package_count}"
151177

152178
if [[ $package_count -gt 1 ]]; then
153179
# Multiple packages case:
180+
debug_log "Multiple packages detected, generating multi-package comment"
154181
comment="Hello! 👋
155182
156183
Pro-tip: This PR changes multiple packages. You can use various \`make\` rules with \`*_FILTER\` environment variables to run tests, benchmarks, and examples for specific packages.
@@ -174,7 +201,9 @@ ${docs_links}"
174201

175202
else
176203
# Single package case:
177-
if [[ "${#c_files[@]}" -eq 0 ]]; then
204+
debug_log "Single package detected: ${packages}"
205+
if [[ -z "${c_files}" ]]; then
206+
debug_log "No C files found, generating JS-only comment"
178207
comment="Hello! 👋
179208
180209
Pro-tip: Use the \`make\` commands below during local development to ensure that all tests, examples, and benchmark files in your PR run successfully.
@@ -200,6 +229,7 @@ make examples EXAMPLES_FILTER=\".*/${packages}/.*\"
200229
\`\`\`
201230
${docs_links}"
202231
else
232+
debug_log "C files found, generating native addon comment"
203233
comment="Hello! 👋
204234
205235
Pro-tip: Use the \`make\` below commands during local development to ensure that all tests, examples, and benchmark files in your PR run successfully.
@@ -241,10 +271,12 @@ ${docs_links}"
241271
fi
242272
fi
243273

274+
debug_log "Posting comment on PR #${pr_number}"
244275
if ! github_api "POST" "/repos/${repo_owner}/${repo_name}/issues/${pr_number}/comments" "{\"body\":$(echo "${comment}" | jq -R -s -c .)}"; then
245276
echo "Failed to post comment on PR."
246277
on_error 1
247278
fi
279+
debug_log "Successfully posted comment on PR #${pr_number}"
248280

249281
print_success
250282
exit 0

.github/workflows/scripts/run_tests_coverage

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,10 @@ compare_cov() {
144144
main() {
145145
start_heartbeat "${heartbeat_interval}"
146146

147-
# Only keep files which reside in package directories:
148-
changed=$(echo "${changed}" | tr ' ' '\n' | grep '^lib/node_modules/@stdlib') || true
147+
# Only keep files which reside in package directories, but exclude _tools:
148+
changed=$(echo "${changed}" | tr ' ' '\n' | \
149+
grep '^lib/node_modules/@stdlib' | \
150+
grep -v '^lib/node_modules/@stdlib/_tools') || true
149151

150152
# Find unique package directories:
151153
directories=$(echo "${changed}" | tr ' ' '\n' | sed -E 's/\/(benchmark|bin|data|docs|etc|examples|include|lib|scripts|src|test)(\/.*)?\/?$//' | uniq)

0 commit comments

Comments
 (0)