Skip to content

Commit b3c73fe

Browse files
gunjjoshikgryte
andauthored
build: add workflow to update unary function database
PR-URL: stdlib-js#8291 Co-authored-by: Athan Reines <kgryte@gmail.com> Reviewed-by: Athan Reines <kgryte@gmail.com>
1 parent 7fd6312 commit b3c73fe

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
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: update_math_scaffold_databases
21+
22+
# Workflow triggers:
23+
on:
24+
push:
25+
paths:
26+
# List paths for which changes should trigger this workflow:
27+
- 'lib/node_modules/@stdlib/math/special/data/unary_function_database.json'
28+
- 'lib/node_modules/@stdlib/math/base/special/*/package.json'
29+
- 'lib/node_modules/@stdlib/number/float64/base/*/package.json'
30+
- 'lib/node_modules/@stdlib/number/float32/base/*/package.json'
31+
- 'lib/node_modules/@stdlib/number/float16/base/*/package.json'
32+
- 'lib/node_modules/@stdlib/complex/float64/base/*/package.json'
33+
- 'lib/node_modules/@stdlib/complex/float32/base/*/package.json'
34+
- 'lib/node_modules/@stdlib/complex/float16/base/*/package.json'
35+
36+
# Allow the workflow to be manually run:
37+
workflow_dispatch:
38+
39+
# Global permissions:
40+
permissions:
41+
# Allow read-only access to the repository contents:
42+
contents: read
43+
44+
# Workflow jobs:
45+
jobs:
46+
47+
# Define a job for updating databases which are used for scaffolding mathematical packages...
48+
update:
49+
50+
# Define a display name:
51+
name: 'Update Scaffold Databases'
52+
53+
# Ensure the job does not run on forks:
54+
if: github.repository == 'stdlib-js/stdlib'
55+
56+
# Define the type of virtual host machine:
57+
runs-on: ubuntu-latest
58+
59+
# Define the sequence of job steps...
60+
steps:
61+
62+
# Checkout the repository:
63+
- name: 'Checkout repository'
64+
# Pin action to full length commit SHA
65+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
66+
with:
67+
# Specify whether to remove untracked files before checking out the repository:
68+
clean: true
69+
70+
# Limit clone depth to the most recent commit:
71+
fetch-depth: 1
72+
73+
# Specify whether to download Git-LFS files:
74+
lfs: false
75+
76+
# Avoid storing GitHub token in local Git configuration:
77+
persist-credentials: false
78+
timeout-minutes: 10
79+
80+
# Install Node.js:
81+
- name: 'Install Node.js'
82+
# Pin action to full length commit SHA
83+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
84+
with:
85+
node-version: '20' # 'lts/*'
86+
timeout-minutes: 5
87+
88+
# Install dependencies (accounting for possible network failures, etc, when installing node module dependencies):
89+
- name: 'Install dependencies'
90+
run: |
91+
make install-node-modules || make install-node-modules || make install-node-modules
92+
timeout-minutes: 15
93+
94+
# Update the unary database:
95+
- name: 'Update unary database'
96+
run: |
97+
node lib/node_modules/@stdlib/math/special/scripts/generate_unary_database.js
98+
99+
# Check if there are any changes to the unary database:
100+
- name: 'Check for changes'
101+
id: check_changes
102+
run: |
103+
if [ -z "$(git diff lib/node_modules/@stdlib/math/special/data/unary.json)" ]; then
104+
echo "No changes detected in unary database. Skipping PR creation."
105+
echo "has_changes=false" >> $GITHUB_OUTPUT
106+
else
107+
echo "Changes detected in unary database."
108+
echo "has_changes=true" >> $GITHUB_OUTPUT
109+
fi
110+
111+
# Import GPG key to sign commits:
112+
- name: 'Import GPG key to sign commits'
113+
if: steps.check_changes.outputs.has_changes == 'true'
114+
# Pin action to full length commit SHA
115+
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
116+
with:
117+
gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }}
118+
passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }}
119+
git_user_signingkey: true
120+
git_commit_gpgsign: true
121+
122+
# Create a pull request with the updated databases:
123+
- name: 'Create pull request'
124+
if: steps.check_changes.outputs.has_changes == 'true'
125+
id: cpr
126+
# Pin action to full length commit SHA
127+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
128+
with:
129+
title: 'feat: update math scaffold databases'
130+
body: |
131+
This PR
132+
133+
- updates the databases for scaffolding mathematical databases
134+
135+
commit-message: 'feat: update math scaffold databases'
136+
committer: 'stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>'
137+
signoff: true
138+
token: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }}
139+
labels: |
140+
automated-pr
141+
team-reviewers: |
142+
reviewers
143+
branch: update-math-scaffold-databases
144+
delete-branch: true
145+
146+
# Create a pull request summary:
147+
- name: 'Create summary'
148+
if: steps.check_changes.outputs.has_changes == 'true'
149+
run: |
150+
echo "# :tada: Pull Request created! :tada:" >> $GITHUB_STEP_SUMMARY
151+
echo "" >> $GITHUB_STEP_SUMMARY
152+
echo "Pull request ${{ steps.cpr.outputs.pull-request-number }} was successfully ${{ steps.cpr.outputs.pull-request-operation }}."
153+
echo ":link: [${{ steps.cpr.outputs.pull-request-url }}](${{ steps.cpr.outputs.pull-request-url }})." >> $GITHUB_STEP_SUMMARY
154+
echo "Head SHA: [${{ steps.cpr.outputs.pull-request-head-sha }}](${{ steps.cpr.outputs.pull-request-url }}/commits/${{ steps.cpr.outputs.pull-request-head-sha }})." >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)