Skip to content

Commit 3f61e2c

Browse files
Merge pull request #1 from stdlib-js/develop
update
2 parents 39b8176 + d40dbaf commit 3f61e2c

File tree

1,089 files changed

+66674
-4719
lines changed

Some content is hidden

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

1,089 files changed

+66674
-4719
lines changed

.github/workflows/check_licenses.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
# Install Node.js:
8282
- name: 'Install Node.js'
8383
# Pin action to full length commit SHA
84-
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
84+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
8585
with:
8686
node-version: '20' # 'lts/*'
8787
timeout-minutes: 5

.github/workflows/check_required_files.yml

Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,33 @@ name: check_required_files
2121

2222
# Workflow triggers:
2323
on:
24-
# Trigger the workflow when a PR review is requested:
25-
pull_request_target:
26-
types: [review_requested]
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+
# Allow the workflow to be manually triggered:
42+
workflow_dispatch:
43+
inputs:
44+
pull_request_number:
45+
description: 'Pull request number'
46+
required: true
47+
type: number
48+
user:
49+
required: true
50+
type: string
2751

2852
# Global permissions:
2953
permissions:
@@ -45,58 +69,15 @@ jobs:
4569
# Define the sequence of job steps...
4670
steps:
4771

48-
# Checkout the repository:
49-
- name: 'Checkout repository'
50-
# Pin action to full length commit SHA
51-
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
52-
with:
53-
# Specify whether to remove untracked files before checking out the repository:
54-
clean: true
55-
56-
# Refers to the development branch:
57-
ref: 'develop'
58-
59-
# Refers to the repository name of the pull request:
60-
repository: ${{ github.event.pull_request.head.repo.full_name }}
61-
62-
# Limit clone depth to the most recent commit:
63-
fetch-depth: 1
64-
65-
# Specify whether to download Git-LFS files:
66-
lfs: false
67-
timeout-minutes: 10
68-
69-
# Check if the review is requested from the `stdlib-bot` user:
70-
- name: 'Check if review is requested from stdlib-bot'
71-
id: check-reviewers
72-
run: |
73-
# Get the list of reviewers:
74-
reviewers=$(jq -r '.pull_request.requested_reviewers | .[] | .login' "$GITHUB_EVENT_PATH")
75-
76-
# Check if the list of reviewers contains the `stdlib-bot` user:
77-
if [[ $reviewers == *"stdlib-bot"* ]]; then
78-
echo "is_stdlib_bot=true" >> $GITHUB_OUTPUT
79-
else
80-
echo "is_stdlib_bot=false" >> $GITHUB_OUTPUT
81-
fi
82-
83-
# Configure git:
84-
- name: 'Configure git'
85-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
86-
run: |
87-
git config --local user.email "[email protected]"
88-
git config --local user.name "stdlib-bot"
89-
git fetch --all
90-
9172
# Get list of added files:
9273
- name: 'Get list of added files'
93-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
9474
id: added-files
9575
run: |
9676
page=1
9777
files=""
9878
while true; do
99-
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "added") | .filename')
79+
new_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN
80+
}}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}/files?page=$page&per_page=100" | jq -r '.[] | select(.status == "added") | .filename')
10081
if [ -z "$new_files" ]; then
10182
break
10283
fi
@@ -108,7 +89,6 @@ jobs:
10889
10990
# Check whether the pull request contains a new `README.md` file; if not, exit with a non-zero exit code:
11091
- name: 'Exit if pull request does not contain a new README.md file'
111-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
11292
run: |
11393
if [[ ! "${{ steps.added-files.outputs.files }}" =~ "README.md" ]]; then
11494
echo "Pull request does not contain a new README.md file."
@@ -117,8 +97,6 @@ jobs:
11797
11898
# Check whether the pull request contains files which are required to be present for all packages:
11999
- name: 'Check whether the pull request contains files which are required to be present for all packages'
120-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
121-
id: check-required-files
122100
run: |
123101
# Define a list of required files:
124102
required_files=(
@@ -188,15 +166,15 @@ jobs:
188166
189167
body=""
190168
if [[ "${#missing_files[@]}" -eq 0 ]]; then
191-
body="Hi @${{ github.event.pull_request.user.login }}, thank you for your contribution!
169+
body="Hi @${{ inputs.user }}, thank you for your contribution!
192170
193171
:tada: Your pull request contains all required files for the new package: :tada:
194172
195173
${checkbox_list}
196174
197175
-- stdlib-bot"
198176
else
199-
body="Hi @${{ github.event.pull_request.user.login }}, thank you for your contribution! Your pull request contains a new package, but is missing some of the required files.
177+
body="Hi @${{ inputs.user }}, thank you for your contribution! Your pull request contains a new package, but is missing some of the required files.
200178
201179
Use the following checklist to keep track of the required files and which ones are still missing:
202180
@@ -207,23 +185,22 @@ jobs:
207185
-- stdlib-bot"
208186
fi
209187
210-
# Add the comment body to the workflow output after escaping to preserve newlines:
211-
body="${body//'%'/'%25'}"
212-
body="${body//$'\n'/'%0A'}"
213-
body="${body//$'\r'/'%0D'}"
214-
echo "comment-body=${body}" >> $GITHUB_OUTPUT
188+
# Write the comment body to a file:
189+
echo "${body}" > ./comment-body.txt
215190
216191
shell: bash
217192
timeout-minutes: 10
218193

219194
# Create a comment on the pull request informing the user whether the pull request is missing required files:
220195
- name: 'Create a comment on the pull request informing the user whether the pull request is missing required files'
221-
if: steps.check-reviewers.outputs.is_stdlib_bot == 'true'
222196
# Pin action to full length commit SHA
223197
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
224198
with:
225199
# Specify the issue or pull request number:
226-
issue-number: ${{ github.event.pull_request.number }}
200+
issue-number: ${{ inputs.pull_request_number }}
201+
202+
# Specify the comment body path:
203+
body-path: ./comment-body.txt
227204

228-
# Specify the comment body:
229-
body: ${{ steps.check-required-files.outputs.comment-body }}
205+
# GitHub token:
206+
token: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
# Install Node.js:
119119
- name: 'Install Node.js'
120120
# Pin action to full length commit SHA
121-
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
121+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
122122
with:
123123
node-version: '20' # 'lts/*'
124124
timeout-minutes: 5

.github/workflows/lint_autofix.yml

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
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: lint_autofix
21+
22+
# Workflow triggers:
23+
on:
24+
25+
# Allow the workflow to be triggered by other workflows
26+
workflow_call:
27+
# Define the input parameters for the workflow:
28+
inputs:
29+
pull_request_number:
30+
description: 'PR number'
31+
required: true
32+
type: number
33+
# Define the secrets accessible by the workflow:
34+
secrets:
35+
STDLIB_BOT_GITHUB_TOKEN:
36+
description: 'GitHub token for stdlb-bot'
37+
required: true
38+
REPO_GITHUB_TOKEN:
39+
description: 'GitHub token for accessing the repository'
40+
required: true
41+
STDLIB_BOT_GPG_PRIVATE_KEY:
42+
description: 'GPG private key for stdlb-bot'
43+
required: true
44+
STDLIB_BOT_GPG_PASSPHRASE:
45+
description: 'GPG passphrase for stdlb-bot'
46+
required: true
47+
48+
# Workflow jobs:
49+
jobs:
50+
51+
# Define a job for automatically fixing lint errors:
52+
autofix:
53+
54+
# Define a display name:
55+
name: 'Fix lint errors'
56+
57+
# Define the type of virtual host machine:
58+
runs-on: ubuntu-latest
59+
60+
# Define the sequence of job steps...
61+
steps:
62+
63+
# Get PR details:
64+
- name: 'Get PR details'
65+
id: pr-details
66+
run: |
67+
pr_response=$(curl -s \
68+
-H "Accept: application/vnd.github.v3+json" \
69+
-H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
70+
"https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}")
71+
72+
# Escape control characters:
73+
pr_response=$(echo "$pr_response" | tr -d '\000-\031')
74+
75+
# Extract the needed details:
76+
pr_branch=$(echo "$pr_response" | jq -r '.head.ref') # PR's branch
77+
pr_repo_full_name=$(echo "$pr_response" | jq -r '.head.repo.full_name') # PR's repo full name
78+
79+
# Set outputs for the branch and repository:
80+
echo "branch=$pr_branch" >> $GITHUB_OUTPUT
81+
echo "repository=$pr_repo_full_name" >> $GITHUB_OUTPUT
82+
83+
# Checkout the repository:
84+
- name: 'Checkout repository'
85+
# Pin action to full length commit SHA
86+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
87+
with:
88+
# Refers to the branch name of the branch being pushed:
89+
ref: ${{ steps.pr-details.outputs.branch }}
90+
91+
# Refers to the repository name:
92+
repository: ${{ steps.pr-details.outputs.repository }}
93+
94+
# Token for accessing the repository:
95+
token: ${{ secrets.REPO_GITHUB_TOKEN }}
96+
97+
# File path to checkout to:
98+
path: './'
99+
100+
# Install Node.js:
101+
- name: 'Install Node.js'
102+
# Pin action to full length commit SHA
103+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
104+
with:
105+
node-version: '20' # 'lts/*'
106+
timeout-minutes: 5
107+
108+
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
109+
- name: 'Install dependencies'
110+
run: |
111+
make install-node-modules || make install-node-modules || make install-node-modules
112+
timeout-minutes: 15
113+
114+
# Initialize development environment:
115+
- name: 'Initialize development environment'
116+
run: |
117+
make init
118+
timeout-minutes: 5
119+
120+
# Get list of changed files:
121+
- name: 'Get list of changed files'
122+
id: changed-files
123+
run: |
124+
page=1
125+
files=""
126+
while true; do
127+
changed_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN
128+
}}" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename')
129+
if [ -z "$changed_files" ]; then
130+
break
131+
fi
132+
files="$files $changed_files"
133+
page=$((page+1))
134+
done
135+
files=$(echo "$files" | tr '\n' ' ' | sed 's/^ //;s/ $//')
136+
echo "files=${files}" >> $GITHUB_OUTPUT
137+
138+
# Fix JavaScript lint errors:
139+
- name: 'Fix JavaScript lint errors'
140+
id: fix-lint-errors
141+
run: |
142+
files="${{ steps.changed-files.outputs.files }}"
143+
FIX=1 . "$GITHUB_WORKSPACE/.github/workflows/scripts/lint_javascript_files" "$files"
144+
145+
# Disable Git hooks:
146+
- name: 'Disable Git hooks'
147+
run: |
148+
rm -rf .git/hooks
149+
150+
# Import GPG key to sign commits:
151+
- name: 'Import GPG key to sign commits'
152+
# Pin action to full length commit SHA
153+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
154+
with:
155+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
156+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
157+
git_user_signingkey: true
158+
git_commit_gpgsign: true
159+
160+
# Commit and push changes:
161+
- name: 'Commit and push changes'
162+
env:
163+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
164+
USER_NAME: stdlb-bot
165+
BRANCH_NAME: ${{ steps.pr-details.outputs.branch }}
166+
REPO_NAME: ${{ steps.pr-details.outputs.repository }}
167+
run: |
168+
git config --local user.email "[email protected]"
169+
git config --local user.name "stdlib-bot"
170+
git add .
171+
git commit -m "fix: resolve lint errors"
172+
git push "https://$USER_NAME:[email protected]/$REPO_NAME.git" $BRANCH_NAME

.github/workflows/lint_changed_files.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
# Install Node.js:
6868
- name: 'Install Node.js'
6969
# Pin action to full length commit SHA
70-
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
70+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
7171
with:
7272
node-version: '20' # 'lts/*'
7373
timeout-minutes: 5
@@ -248,7 +248,7 @@ jobs:
248248
- name: 'Setup R'
249249
if: ( success() || failure() ) && steps.check-r-files.outputs.files != ''
250250
# Pin action to full length commit SHA
251-
uses: r-lib/actions/setup-r@55acd27e7b238c53bbe735b7a459c203a3b3d579 # v2.6.4
251+
uses: r-lib/actions/setup-r@0ed4cdf40958ef43a6b33b9792e07ac76c3239e3 # v2.6.4
252252
with:
253253
r-version: '3.5.3'
254254

0 commit comments

Comments
 (0)