Skip to content

Commit 6e8b5d6

Browse files
authored
Merge branch 'develop' into philipp/update-readme-var-declarations
Signed-off-by: Philipp Burckhardt <[email protected]>
2 parents 6697ba4 + 009becd commit 6e8b5d6

File tree

108 files changed

+2676
-457
lines changed

Some content is hidden

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

108 files changed

+2676
-457
lines changed

.github/workflows/lint_autofix.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,26 @@ on:
2525
# Allow the workflow to be triggered by other workflows
2626
workflow_call:
2727
# 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
28+
inputs:
29+
pull_request_number:
30+
description: 'PR number'
31+
required: true
32+
type: number
33+
34+
# Define the secrets accessible by the workflow:
35+
secrets:
36+
STDLIB_BOT_GITHUB_TOKEN:
37+
description: 'GitHub token for stdlb-bot'
38+
required: true
39+
REPO_GITHUB_TOKEN:
40+
description: 'GitHub token for accessing the repository'
41+
required: true
42+
STDLIB_BOT_GPG_PRIVATE_KEY:
43+
description: 'GPG private key for stdlb-bot'
44+
required: true
45+
STDLIB_BOT_GPG_PASSPHRASE:
46+
description: 'GPG passphrase for stdlb-bot'
47+
required: true
4748

4849
# Workflow jobs:
4950
jobs:
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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_copyright_years'
21+
22+
# Workflow triggers:
23+
on:
24+
pull_request:
25+
types: [opened, synchronize, reopened]
26+
27+
# Global permissions:
28+
permissions:
29+
# Allow read-only access to the repository contents:
30+
contents: read
31+
32+
# Workflow jobs:
33+
jobs:
34+
# Define a job for linting copyright years in newly added files:
35+
lint:
36+
name: 'Lint Copyright Years'
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
# Checkout the repository:
41+
- name: 'Checkout repository'
42+
# Pin action to full length commit SHA
43+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
44+
with:
45+
# Specify whether to remove untracked files before checking out the repository:
46+
clean: true
47+
48+
# Limit clone depth to the last 1000 commits:
49+
fetch-depth: 100
50+
51+
# Specify whether to download Git-LFS files:
52+
lfs: false
53+
timeout-minutes: 10
54+
55+
# Get list of newly added files:
56+
- name: 'Get list of newly added files'
57+
id: added-files
58+
run: |
59+
page=1
60+
files=""
61+
while true; do
62+
new_files=$(curl -s \
63+
-H "Accept: application/vnd.github.v3+json" \
64+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
65+
"${{ github.api_url }}/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" \
66+
| jq -r '.[] | select(.status == "added") | .filename')
67+
if [ -z "$new_files" ]; then
68+
break
69+
fi
70+
files="$files $new_files"
71+
page=$((page+1))
72+
done
73+
files=$(echo "$files" | tr '\n' ' ' | sed 's/^ //;s/ $//')
74+
echo "files=${files}" >> $GITHUB_OUTPUT
75+
76+
# Check copyright years in newly added files:
77+
- name: 'Check copyright years'
78+
run: |
79+
current_year=$(date +"%Y")
80+
files="${{ steps.added-files.outputs.files }}"
81+
exit_code=0
82+
83+
echo "## 📄 Copyright Year Check Results" >> $GITHUB_STEP_SUMMARY
84+
echo "_Only newly added files are checked for the current year in the copyright notice._" >> $GITHUB_STEP_SUMMARY
85+
echo "" >> $GITHUB_STEP_SUMMARY
86+
87+
if [[ -z "$files" ]]; then
88+
echo "No newly added files to check."
89+
echo "No newly added files to check." >> $GITHUB_STEP_SUMMARY
90+
exit 0
91+
fi
92+
93+
for file in $files; do
94+
if [[ ! -f "$file" ]]; then
95+
continue
96+
fi
97+
98+
# Check if file contains stdlib copyright notice:
99+
year=$(grep -oP \
100+
'Copyright \(c\) \K[0-9]{4}(?= The Stdlib Authors\.)' \
101+
"$file")
102+
103+
if [[ -n "$year" ]]; then
104+
if [[ "$year" == "$current_year" ]]; then
105+
echo "✅ $file: Correct year $year"
106+
echo "- ✅ \`$file\`: Year is correct (**$year**)" >> $GITHUB_STEP_SUMMARY
107+
else
108+
echo "❌ $file: Expected $current_year, found $year"
109+
echo "- ❌ **Error**: \`$file\` — Expected year **$current_year**, found **$year**" >> $GITHUB_STEP_SUMMARY
110+
exit_code=1
111+
fi
112+
else
113+
echo "⚠️ $file: No copyright notice found"
114+
echo "- ⚠️ No copyright notice found in \`$file\`" >> $GITHUB_STEP_SUMMARY
115+
fi
116+
done
117+
118+
exit $exit_code
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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: pr_merge_develop
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+
34+
# Define the secrets accessible by the workflow:
35+
secrets:
36+
STDLIB_BOT_GITHUB_TOKEN:
37+
description: 'GitHub token for stdlb-bot'
38+
required: true
39+
REPO_GITHUB_TOKEN:
40+
description: 'GitHub token for accessing the repository'
41+
required: true
42+
STDLIB_BOT_GPG_PRIVATE_KEY:
43+
description: 'GPG private key for stdlb-bot'
44+
required: true
45+
STDLIB_BOT_GPG_PASSPHRASE:
46+
description: 'GPG passphrase for stdlb-bot'
47+
required: true
48+
49+
# Workflow jobs:
50+
jobs:
51+
merge:
52+
# Define a display name:
53+
name: 'Merge Develop into PR Branch'
54+
55+
# Define the type of virtual host machine:
56+
runs-on: ubuntu-latest
57+
58+
# Define the job's steps:
59+
steps:
60+
# Get PR details:
61+
- name: 'Get PR details'
62+
id: pr-details
63+
run: |
64+
pr_response=$(curl -s \
65+
-H "Accept: application/vnd.github.v3+json" \
66+
-H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
67+
"https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}")
68+
69+
# Escape control characters:
70+
pr_response=$(echo "$pr_response" | tr -d '\000-\031')
71+
72+
# Extract the needed details:
73+
pr_branch=$(echo "$pr_response" | jq -r '.head.ref')
74+
pr_repo_full_name=$(echo "$pr_response" | jq -r '.head.repo.full_name')
75+
76+
echo "branch=$pr_branch" >> $GITHUB_OUTPUT
77+
echo "repository=$pr_repo_full_name" >> $GITHUB_OUTPUT
78+
79+
# Checkout the repository:
80+
- name: 'Checkout repository'
81+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
82+
with:
83+
ref: ${{ steps.pr-details.outputs.branch }}
84+
repository: ${{ steps.pr-details.outputs.repository }}
85+
token: ${{ secrets.REPO_GITHUB_TOKEN }}
86+
fetch-depth: 0
87+
88+
# Disable Git hooks:
89+
- name: 'Disable Git hooks'
90+
run: |
91+
rm -rf .git/hooks
92+
93+
# Import GPG key to sign commits:
94+
- name: 'Import GPG key to sign commits'
95+
# Pin action to full length commit SHA
96+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
97+
with:
98+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
99+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
100+
git_user_signingkey: true
101+
git_commit_gpgsign: true
102+
103+
# Merge the develop branch into the PR branch:
104+
- name: 'Merge develop branch'
105+
env:
106+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
107+
USER_NAME: stdlb-bot
108+
BRANCH_NAME: ${{ steps.pr-details.outputs.branch }}
109+
REPO_NAME: ${{ steps.pr-details.outputs.repository }}
110+
run: |
111+
git config --local user.email "[email protected]"
112+
git config --local user.name "stdlib-bot"
113+
git fetch origin develop:develop
114+
git merge develop --no-edit
115+
git push "https://$USER_NAME:[email protected]/$REPO_NAME.git" $BRANCH_NAME
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
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: pr_rebase_develop
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+
34+
# Define the secrets accessible by the workflow:
35+
secrets:
36+
STDLIB_BOT_GITHUB_TOKEN:
37+
description: 'GitHub token for stdlb-bot'
38+
required: true
39+
REPO_GITHUB_TOKEN:
40+
description: 'GitHub token for accessing the repository'
41+
required: true
42+
STDLIB_BOT_GPG_PRIVATE_KEY:
43+
description: 'GPG private key for stdlb-bot'
44+
required: true
45+
STDLIB_BOT_GPG_PASSPHRASE:
46+
description: 'GPG passphrase for stdlb-bot'
47+
required: true
48+
49+
# Workflow jobs:
50+
jobs:
51+
rebase:
52+
# Define a display name:
53+
name: 'Rebase PR Branch onto Develop'
54+
55+
# Define the type of virtual host machine:
56+
runs-on: ubuntu-latest
57+
58+
# Define the job's steps:
59+
steps:
60+
# Get PR details:
61+
- name: 'Get PR details'
62+
id: pr-details
63+
run: |
64+
pr_response=$(curl -s \
65+
-H "Accept: application/vnd.github.v3+json" \
66+
-H "Authorization: Bearer ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}" \
67+
"https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ inputs.pull_request_number }}")
68+
69+
# Escape control characters:
70+
pr_response=$(echo "$pr_response" | tr -d '\000-\031')
71+
72+
# Extract the needed details:
73+
pr_branch=$(echo "$pr_response" | jq -r '.head.ref')
74+
pr_repo_full_name=$(echo "$pr_response" | jq -r '.head.repo.full_name')
75+
76+
echo "branch=$pr_branch" >> $GITHUB_OUTPUT
77+
echo "repository=$pr_repo_full_name" >> $GITHUB_OUTPUT
78+
79+
# Checkout the repository:
80+
- name: 'Checkout repository'
81+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
82+
with:
83+
ref: ${{ steps.pr-details.outputs.branch }}
84+
repository: ${{ steps.pr-details.outputs.repository }}
85+
token: ${{ secrets.REPO_GITHUB_TOKEN }}
86+
fetch-depth: 0
87+
88+
# Disable Git hooks:
89+
- name: 'Disable Git hooks'
90+
run: |
91+
rm -rf .git/hooks
92+
93+
# Import GPG key to sign commits:
94+
- name: 'Import GPG key to sign commits'
95+
# Pin action to full length commit SHA
96+
uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0
97+
with:
98+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
99+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
100+
git_user_signingkey: true
101+
git_commit_gpgsign: true
102+
103+
# Rebase on develop branch:
104+
- name: 'Rebase on develop branch'
105+
env:
106+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
107+
USER_NAME: stdlb-bot
108+
BRANCH_NAME: ${{ steps.pr-details.outputs.branch }}
109+
REPO_NAME: ${{ steps.pr-details.outputs.repository }}
110+
run: |
111+
git config --local user.email "[email protected]"
112+
git config --local user.name "stdlib-bot"
113+
git fetch origin develop:develop
114+
git rebase develop
115+
git push --force-with-lease "https://$USER_NAME:[email protected]/$REPO_NAME.git" $BRANCH_NAME

0 commit comments

Comments
 (0)