From 44fce72c8e0bcae0a6ef1b21ca7e500384af057c Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 15 Mar 2025 15:00:29 -0400 Subject: [PATCH 1/3] build: create multiple declarations PRs --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .github/workflows/namespace_declarations.yml | 112 +++++++++---------- 1 file changed, 52 insertions(+), 60 deletions(-) diff --git a/.github/workflows/namespace_declarations.yml b/.github/workflows/namespace_declarations.yml index 246c16bc5b09..89a41d79869c 100644 --- a/.github/workflows/namespace_declarations.yml +++ b/.github/workflows/namespace_declarations.yml @@ -83,64 +83,56 @@ jobs: make install-node-modules || make install-node-modules || make install-node-modules timeout-minutes: 15 - # Update namespace Typescript declarations: - - name: 'Update declarations' + # Update namespace Typescript declarations and create PRs: + - name: 'Update declarations and create PRs' run: | - make list-pkgs-namespaces | node lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js - - # Disable Git hooks: - - name: 'Disable Git hooks' - run: | - rm -rf .git/hooks - - # Import GPG key to sign commits: - - name: 'Import GPG key to sign commits' - # Pin action to full length commit SHA - uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 - with: - gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }} - git_user_signingkey: true - git_commit_gpgsign: true - - # Create a pull request with the updated declarations: - - name: 'Create pull request' - id: cpr - # Pin action to full length commit SHA - uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6 - with: - title: 'feat: update namespace TypeScript declarations' - body: | - This PR - - - updates namespace TypeScript declarations - - ## Reviewer Checklist - - - [ ] **Check the scope of the changes** (following [Conventional Commits](https://www.conventionalcommits.org)): - - Are these **new APIs**? Then this is a `feat`. - - Are these **changes to existing APIs** that could break compatibility? Then this is a `feat!` (i.e., a breaking change). - - Are these **only documentation** changes to existing APIs? Then this is `docs`. - - [ ] Update the PR title to align with the change type (`feat`, `feat!`, or `docs`). - - [ ] Approve the PR once you are confident about the classification and changes made. - - commit-message: 'feat: update namespace TypeScript declarations' - committer: 'stdlib-bot <82920195+stdlib-bot@users.noreply.github.com>' - signoff: true - token: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} - labels: | - documentation - automated-pr - team-reviewers: | - reviewers - branch: update-namespace-declarations - delete-branch: true - - # Create Markdown summary of the pull request: - - name: 'Create summary' - run: | - echo "# :tada: Pull Request created! :tada:" >> $GITHUB_STEP_SUMMARY - echo "" >> $GITHUB_STEP_SUMMARY - echo "Pull request ${{ steps.cpr.outputs.pull-request-number }} was successfully ${{ steps.cpr.outputs.pull-request-operation }}." - echo ":link: [${{ steps.cpr.outputs.pull-request-url }}](${{ steps.cpr.outputs.pull-request-url }})." >> $GITHUB_STEP_SUMMARY - 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 + # Create a temporary file to store the list of namespaces: + make list-pkgs-namespaces > namespaces.txt + + # Process each namespace: + while IFS= read -r namespace; do + if [ -n "$namespace" ] && [[ $namespace != *"_tools"* ]]; then + branch_name="update-$(echo "$namespace" | sed 's/@stdlib\///' | sed 's/\//-/g')-declarations" + git checkout -b "$branch_name" + + # Generate declarations for this namespace + echo "$namespace" | node lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js + + # Check if there are changes: + if ! git diff --quiet -- lib/node_modules/@stdlib; then + # Stage only changes in the stdlib directory: + git add lib/node_modules/@stdlib + + # Commit changes: + git commit -m "feat: update \`${namespace}\` TypeScript declarations" --signoff + + # Push branch and create PR + git push origin "$branch_name" + + gh pr create \ + --title "feat: update \`${namespace}\` TypeScript declarations" \ + --body "This PR updates TypeScript declarations for the \`${namespace}\` namespace. + + ## Reviewer Checklist + + - [ ] **Check the scope of the changes** (following [Conventional Commits](https://www.conventionalcommits.org)): + - Are these **new APIs**? Then this is a \`feat\`. + - Are these **changes to existing APIs** that could break compatibility? Then this is a \`feat!\` (i.e., a breaking change). + - Are these **only documentation** changes to existing APIs? Then this is \`docs\`. + - [ ] Update the PR title to align with the change type (\`feat\`, \`feat!\`, or \`docs\`). + - [ ] Approve the PR once you are confident about the classification and changes made." \ + --label "Documentation" \ + --label "automated-pr" \ + --reviewer "reviewers" \ + --base develop \ + --head "$branch_name" + fi + + git checkout develop + fi + done < namespaces.txt + + # Clean up temporary file: + rm namespaces.txt + env: + GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_PAT_REPO_WRITE }} From bb271d56d318c386171ec4a7e9a402f8f95b8243 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 15 Mar 2025 15:03:11 -0400 Subject: [PATCH 2/3] build: re-add removed steps --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .github/workflows/namespace_declarations.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/namespace_declarations.yml b/.github/workflows/namespace_declarations.yml index 89a41d79869c..0ae4ff33b041 100644 --- a/.github/workflows/namespace_declarations.yml +++ b/.github/workflows/namespace_declarations.yml @@ -83,6 +83,21 @@ jobs: make install-node-modules || make install-node-modules || make install-node-modules timeout-minutes: 15 + # Disable Git hooks: + - name: 'Disable Git hooks' + run: | + rm -rf .git/hooks + + # Import GPG key to sign commits: + - name: 'Import GPG key to sign commits' + # Pin action to full length commit SHA + uses: crazy-max/ghaction-import-gpg@cb9bde2e2525e640591a934b1fd28eef1dcaf5e5 # v6.2.0 + with: + gpg_private_key: ${{ secrets.STDLIB_BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.STDLIB_BOT_GPG_PASSPHRASE }} + git_user_signingkey: true + git_commit_gpgsign: true + # Update namespace Typescript declarations and create PRs: - name: 'Update declarations and create PRs' run: | From e9248b501fd771f52805db8842085f1612a21b11 Mon Sep 17 00:00:00 2001 From: Athan Date: Tue, 1 Apr 2025 17:27:43 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Signed-off-by: Athan --- .github/workflows/namespace_declarations.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/namespace_declarations.yml b/.github/workflows/namespace_declarations.yml index 7efd66a2e78e..3281bc63a614 100644 --- a/.github/workflows/namespace_declarations.yml +++ b/.github/workflows/namespace_declarations.yml @@ -110,7 +110,7 @@ jobs: branch_name="update-$(echo "$namespace" | sed 's/@stdlib\///' | sed 's/\//-/g')-declarations" git checkout -b "$branch_name" - # Generate declarations for this namespace + # Generate declarations for this namespace: echo "$namespace" | node lib/node_modules/@stdlib/_tools/scripts/create_namespace_types.js # Check if there are changes: @@ -121,7 +121,7 @@ jobs: # Commit changes: git commit -m "feat: update \`${namespace}\` TypeScript declarations" --signoff - # Push branch and create PR + # Push branch and create PR: git push origin "$branch_name" gh pr create \