From d8a6c74b282d3408336aed025fdf983aac04bf69 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 15 Apr 2026 20:49:02 -0700 Subject: [PATCH 1/2] chore(dev): prepare to release individual packages This allows us to release each package in this workspace (monorepo) individually. ## Tags The tags will now be prefixed with the package name as it appears in the respective Cargo.toml: - cpp-linter/v2.0.0-rc.1 - cpp-linter-js/v2.0.0-rc.1 - cpp-linter-js/v2.0.0-rc.1 - clang-installer/v0.1.1 > [!IMPORTANT] > Publishing a release will still happen from the bump-n-release CI workflow's manual trigger (`workflow_dispatch`). > There's an added input to select which package to publish. ## Change Logs Each package will now have its own CHANGELOG.md file (alongside the Cargo.toml) `git-cliff` is now configured to only put relevant changes in each CHANGELOG.md. The relevant changes are determined by changed file's path. ## Binary builds I updated the binary-builds CI workflow to build both rust binary executables. Upon release, the binary executables matching the released package will be uploaded as release assets (for all supported build targets). --- .github/common.nu | 41 +++ .github/workflows/binary-builds.yml | 49 ++-- .github/workflows/bump-n-release.nu | 268 ++++++++++++++++++++ .github/workflows/bump-n-release.yml | 60 ++++- .github/workflows/bump_version.py | 164 ------------ .github/workflows/node-js-packaging.yml | 4 +- .github/workflows/pre-commit-hooks.yml | 2 +- .github/workflows/python-packaging.yml | 12 +- .gitignore | 1 + CONTRIBUTING.md | 21 +- Cargo.lock | 2 +- Cargo.toml | 1 - bindings/node/CHANGELOG.md | 9 + bindings/node/Cargo.toml | 2 +- bindings/python/CHANGELOG.md | 9 + bindings/python/Cargo.toml | 2 +- clang-installer/CHANGELOG.md | 9 + clang-installer/Cargo.toml | 3 + clang-installer/README.md | 2 +- clang-installer/src/downloader/mod.rs | 4 +- clang-installer/src/downloader/pypi.rs | 8 +- clang-installer/src/tool.rs | 2 +- cpp-linter/CHANGELOG.md | 9 + CHANGELOG.md => cpp-linter/CHANGELOG.old.md | 0 cpp-linter/Cargo.toml | 5 +- cpp-linter/clippy.toml | 1 - cpp-linter/src/clang_tools/clang_format.rs | 2 + cpp-linter/src/clang_tools/clang_tidy.rs | 2 + cpp-linter/src/cli/mod.rs | 2 + cpp-linter/src/cli/structs.rs | 6 +- cpp-linter/src/run.rs | 2 + cspell.config.yml | 2 + docs/Cargo.toml | 2 +- docs/docs/changelog.md | 8 - docs/docs/changelog/clang-installer.md | 8 + docs/docs/changelog/cpp-linter-js.md | 8 + docs/docs/changelog/cpp-linter-py.md | 8 + docs/docs/changelog/cpp-linter.md | 8 + docs/license_gen.py | 15 +- docs/mkdocs.yml | 6 +- nurfile | 43 +--- 41 files changed, 546 insertions(+), 266 deletions(-) create mode 100644 .github/common.nu create mode 100644 .github/workflows/bump-n-release.nu delete mode 100644 .github/workflows/bump_version.py create mode 100644 bindings/node/CHANGELOG.md create mode 100644 bindings/python/CHANGELOG.md create mode 100644 clang-installer/CHANGELOG.md create mode 100644 cpp-linter/CHANGELOG.md rename CHANGELOG.md => cpp-linter/CHANGELOG.old.md (100%) delete mode 100644 cpp-linter/clippy.toml delete mode 100644 docs/docs/changelog.md create mode 100644 docs/docs/changelog/clang-installer.md create mode 100644 docs/docs/changelog/cpp-linter-js.md create mode 100644 docs/docs/changelog/cpp-linter-py.md create mode 100644 docs/docs/changelog/cpp-linter.md diff --git a/.github/common.nu b/.github/common.nu new file mode 100644 index 00000000..937eaf45 --- /dev/null +++ b/.github/common.nu @@ -0,0 +1,41 @@ + +# A helper function to display the command being executed. +# +# This also prints the elapsed time the command took to execute. +export def --wrapped run-cmd [...cmd: string] { + let app = if ( + ($cmd | first) == "cargo" + or ($cmd | first) == "yarn" + or ($cmd | first) == 'git' + or ($cmd | first) == 'gh' + ) { + ($cmd | first 2) | str join ' ' + } else if (($cmd | first) == "uv") { + mut sub_cmd = $cmd.1 + if ($sub_cmd == "run") { + mut index = 2 + mut skip_val = false + for arg in ($cmd | skip 2) { + if ($arg | str starts-with "-") { + $skip_val = true + } else if $skip_val { + $skip_val = false + } else { + break + } + $index = $index + 1 + } + if (($cmd | get $index) == "cargo") { + $sub_cmd = $cmd | skip $index | first 2 | str join ' ' + } + $sub_cmd + } else { + ($cmd | first 2) | str join ' ' + } + } else { + ($cmd | first) + } + print $"(ansi blue)\nRunning(ansi reset) ($cmd | str join ' ')" + let elapsed = timeit {|| ^($cmd | first) ...($cmd | skip 1)} + print $"(ansi magenta)($app) took ($elapsed)(ansi reset)" +} diff --git a/.github/workflows/binary-builds.yml b/.github/workflows/binary-builds.yml index 364fc319..a513dada 100644 --- a/.github/workflows/binary-builds.yml +++ b/.github/workflows/binary-builds.yml @@ -6,15 +6,20 @@ on: paths: - cpp-linter/src/** - cpp-linter/Cargo.toml + - clang-installer/src/** + - clang-installer/Cargo.toml - Cargo.toml - Cargo.lock tags: - - v* + - cpp-linter/v* + - clang-installer/v* pull_request: branches: [main] paths: - cpp-linter/src/** - cpp-linter/Cargo.toml + - clang-installer/src/** + - clang-installer/Cargo.toml - Cargo.toml - Cargo.lock @@ -127,8 +132,8 @@ jobs: run: >- ${{ matrix.cross && 'cross' || 'cargo '}} build - --manifest-path cpp-linter/Cargo.toml --bin cpp-linter + --bin clang-tools --release --target ${{ matrix.target }} --features ${{ matrix.vendored && 'bin,openssl-vendored' || 'bin' }} @@ -139,7 +144,12 @@ jobs: run: |- tgt="cpp-linter" mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}" - arc_name="cpp-linter-${{ matrix.target }}.tar.gz" + arc_name="${tgt}-${{ matrix.target }}.tar.gz" + tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE + + tgt="clang-tools" + mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}" + arc_name="${tgt}-${{ matrix.target }}.tar.gz" tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE - name: Prepare artifacts (windows) if: runner.os == 'Windows' @@ -147,20 +157,30 @@ jobs: # `tar.exe` in powershell is different from `tar` in bash. # need to use `tar.exe` in powershell to create a valid zip file. run: |- - $tgt = "cpp-linter.exe" - mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}" - $arc_name = "cpp-linter-${{ matrix.target }}.zip" + $tgt = "cpp-linter" + mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe" + $arc_name = "${tgt}-${{ matrix.target }}.zip" tar -a -c -v -f "${arc_name}" ${tgt} LICENSE - - name: Upload artifacts + $tgt = "clang-tools" + mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe" + $arc_name = "${tgt}-${{ matrix.target }}.zip" + tar -a -c -v -f "${arc_name}" ${tgt} LICENSE + - name: Upload cpp-linter artifacts uses: actions/upload-artifact@v7 with: name: cpp-linter-${{ matrix.target }} path: cpp-linter-${{ matrix.target }}* if-no-files-found: error + - name: Upload clang-tools artifacts + uses: actions/upload-artifact@v7 + with: + name: clang-tools-${{ matrix.target }} + path: clang-tools-${{ matrix.target }}* + if-no-files-found: error publish: - if: startswith(github.ref, 'refs/tags') + if: startswith(github.ref, 'refs/tags/cpp-linter/v') || startswith(github.ref, 'refs/tags/clang-installer/v') runs-on: ubuntu-latest needs: [create-assets] permissions: @@ -172,26 +192,25 @@ jobs: persist-credentials: false - name: Install Rust run: rustup update stable --no-self-update - - uses: actions/setup-python@v6 - with: - python-version: 3.x - name: Download built assets uses: actions/download-artifact@v8 with: - pattern: cpp-linter-* + pattern: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }}-* path: dist merge-multiple: true - name: Create a Github Release env: + BIN_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-tools' }} GH_TOKEN: ${{ github.token }} GIT_REF: ${{ github.ref_name }} run: | - files=$(ls dist/cpp-linter*) - gh release upload "$GIT_REF" $files + files=$(ls dist/${BIN_NAME}*) + gh release upload "${GIT_REF}" ${files} - name: Establish provenance id: auth uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4 - name: Publish package env: + PKG_NAME: ${{ startsWith(github.ref_name, 'cpp-linter') && 'cpp-linter' || 'clang-installer' }} CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }} - run: cargo publish -p cpp-linter + run: cargo publish -p ${PKG_NAME} diff --git a/.github/workflows/bump-n-release.nu b/.github/workflows/bump-n-release.nu new file mode 100644 index 00000000..fb8e5193 --- /dev/null +++ b/.github/workflows/bump-n-release.nu @@ -0,0 +1,268 @@ +# This script automates the release process for all of the packages in this repository. +# In order, this script does the following: +# +# 1. Bump version number in appropriate Cargo.toml manifest. +# +# This step requires `cargo-edit` installed. +# +# 2. Updates the appropriate CHANGELOG.md +# +# Requires `git-cliff` (see https://git-cliff.org) to be installed +# to regenerate the change logs from git history. +# +# NOTE: `git cliff` uses GITHUB_TOKEN env var to access GitHub's REST API for +# fetching certain data (like PR labels and commit author's username). +# +# 3. Pushes the changes from (steps 1 and 2) to remote +# +# 4. Creates a GitHub Release and uses the section from the CHANGELOG about the new tag +# as a release description. +# +# Requires `gh-cli` (see https://cli.github.com) to be installed to create the release +# and push the tag. +# +# NOTE: This step also tags the commit from step 3. +# When a tag is pushed to the remote, the CI builds are triggered and +# a package are published to crates.io +# +# NOTE: In a CI run, the GITHUB_TOKEN env var to authenticate access. +# Locally, you can use `gh login` to interactively authenticate the user account. +# +# The GITHUB_TOKEN permissions shall include: +# - read access to Pull Requests (for better CHANGELOG generation). +# - write (and inherently read) access to the repository "Contents" +# for publishing a GitHub release and pushing metadata changes. + +use ../common.nu run-cmd + +const COMMON_EXCLUDES = [ + '.github/**/*' + 'docs/**/*' + '.config/*' + 'README.md' + '.gitattributes' + '.gitignore' + '.pre-commit-config.yaml' + 'crates/README.md' + 'package.json' + 'codecov.yml' + 'Cargo.toml' + 'cspell.config.yml' + '**/CHANGELOG.md' +] + +const PkgPaths = { + 'cpp-linter': { + include: ['cpp-linter/**/*'] + exclude: [ + 'clang-installer/**/*' + 'bindings/**/*' + 'yarn.lock' + '.yarnrc.yml' + ...$COMMON_EXCLUDES + ] + path: 'cpp-linter' + }, + 'clang-installer': { + include: ['clang-installer/**'] + exclude: [ + 'cpp-linter/**/*' + 'bindings/**/*' + 'yarn.lock' + '.yarnrc.yml' + ...$COMMON_EXCLUDES + ] + path: 'clang-installer' + }, + 'cpp-linter-py': { + include: [] + exclude: ['bindings/node/**/*', 'yarn.lock', '.yarnrc.yml', ...$COMMON_EXCLUDES] + path: 'bindings/python' + }, + 'cpp-linter-js': { + include: [] + exclude: ['bindings/python/**', ...$COMMON_EXCLUDES] + path: 'bindings/node' + } +} +export def get-changed-pkgs [] { + let changed_files = ( + git 'diff' '--name-only' 'HEAD~1' 'HEAD' + | lines + | str trim + | where {not ($in | str starts-with ".")} + ) + print "Changed files:" + print $changed_files + mut pkgs = [] + for row in ($PkgPaths | transpose) { + let pkg = $row.column0 + let paths = $row.column1 + print $"Checking changes for ($pkg)..." + let has_changed = if ($paths.include | is-empty) { + true + } else { + $changed_files | any {|file| $paths.include | each {|p| glob $p | any {|g| $g == $file}}} + } + print $" Has changes: ($has_changed)" + let has_excluded_change = if ($paths.exclude | is-empty) { false } else { + $changed_files | any {|file| $paths.exclude | each {|p| glob $p | any {|g| $g == $file}}} + } + print $" Has excluded changes: ($has_excluded_change)" + if $has_changed and not $has_excluded_change { + print $" Package ($pkg) has relevant changes" + $pkgs = $pkgs | append $pkg + } + } + if ($pkgs | length) == 0 { + print "No packages changed in the last commit." + } else { + print "Changed packages:" + print $pkgs + } + $pkgs | to json --raw +} + +# Is this executed in a CI run? +# +# Uses env var CI to determine the resulting boolean +export def is-in-ci [] { + $env | get --optional CI | default 'false' | (($in == 'true') or ($in == true)) +} + +# Bump the version per the given component name (major, minor, patch) +# +# This function also updates known occurrences of the old version spec to +# the new version spec in various places (like README.md and action.yml). +export def bump-version [ + pkg: string, # The crate name to bump in respective Cargo.toml manifests + component: string, # The version component to bump +] { + mut args = ['-p', $pkg, '--bump', $component] + if (not (is-in-ci)) { + $args = $args | append '--dry-run' + } + let result = cargo 'set-version' ...$args | complete + if ($result.exit_code != 0) { + error make {msg: $"cargo set-version failed: ($result.stderr)"} + } + let parsed = ( + $result.stderr + | lines + | where {|line| $line | str trim | str starts-with 'Upgrading'} + | first + | str trim + | parse 'Upgrading {pkg} from {old} to {new}' + ) + if ($parsed | is-empty) { + error make {msg: $"Failed to parse version from: ($result.stderr)"} + } + let result = $parsed | first + + print $"bumped ($result | get 'old') to ($result | get 'new')" + # update the version in various places + if (($pkg == 'cpp-linter-js') and (is-in-ci)) { + cd ($PkgPaths | get $pkg | get 'path') + run-cmd 'yarn' 'version' ($result | get 'new') + print 'Updated version in bindings/node/package.json' + cd '../..' + } + $result | get new +} + +# Use `git-cliff` tp generate changes. +# +# If `--unreleased` is asserted, then the `git-cliff` output will be saved to .config/ReleaseNotes.md. +# Otherwise, the generated changes will span the entire git history and be saved to CHANGELOG.md. +export def gen-changes [ + pkg: string, # The crate name being bumped. + --tag (-t): string = '', # The new version tag to use for unreleased changes. + --unreleased (-u), # only generate changes from unreleased version. +] { + let paths = $PkgPaths | get $pkg + let path = $paths | get path | path expand + let config_path = '.config' | path expand + + mut args = [ + '--config' $"($config_path | path join 'cliff.toml')" + '--tag-pattern' $"($pkg)/*" + '--workdir' $path + '--repository' (pwd) + ] + if (($tag | str length) > 0) { + $args = $args | append ['--tag', $tag] + } + let prompt = if $unreleased { + let out_path = $config_path | path join 'ReleaseNotes.md' + $args = $args | append [ + '--strip', 'header', '--unreleased', '--output', $out_path + ] + {out_path: ($out_path | path relative-to (pwd)), log_prefix: 'Generated'} + } else { + let out_path = $path | path expand | path join 'CHANGELOG.md' + $args = $args | append [--output $out_path] + {out_path: ($out_path | path relative-to (pwd)), log_prefix: 'Updated'} + } + if (($paths | get 'include' | length) > 0) { + $args = $args | append ['--include-path', ...($paths | get 'include')] + } + if (($paths | get 'exclude' | length) > 0) { + $args = $args | append ['--exclude-path', ...($paths | get 'exclude')] + } + run-cmd 'git-cliff' ...$args + print ($prompt | format pattern '{log_prefix} {out_path}') +} + +# Is the the default branch currently checked out? +# +# Only accurate if the default branch is named "main". +export def is-on-main [] { + let branch = ( + ^git branch + | lines + | where {$in | str starts-with '*'} + | first + | str trim --left --char '*' + | str trim + ) == 'main' + $branch +} + +# The main function of this script. +# +# The `pkg` and `component` parameters are required CLI options: +# nu .github/workflows/bump-n-release.nu cpp-linter patch +# +# The acceptable `pkg` value are defined in the Cargo.toml manifests' `[package.name]` field. +# +# The acceptable `component` values are what `cargo set-version` accepts: +# +# - major +# - minor +# - patch +# - rc +def main [ + pkg: string, # The crate name to bump in respective Cargo.toml manifests + component: string, # The version component to bump +] { + let ver = bump-version $pkg $component + let tag = $"($pkg)/v($ver)" + gen-changes $pkg --tag $tag + gen-changes $pkg --tag $tag --unreleased + let is_main = is-on-main + if not $is_main { + print $"(ansi yellow)\nNot checked out on default branch!(ansi reset)" + } + if (is-in-ci) and $is_main { + print 'Pushing metadata changes' + run-cmd 'git' 'config' '--global' 'user.name' $"($env.GITHUB_ACTOR)" + run-cmd 'git' 'config' '--global' 'user.email' $"($env.GITHUB_ACTOR_ID)+($env.GITHUB_ACTOR)@users.noreply.github.com" + run-cmd 'git' 'add' '--all' + run-cmd 'git' 'commit' '-m' $"build: bump version to ($tag)" + run-cmd 'git' 'push' + print $"Deploying ($tag)" + run-cmd 'gh' 'release' 'create' $tag '--notes-file' '.config/ReleaseNotes.md' '--title' $"($pkg) v($ver)" + } else if $is_main { + print $"(ansi yellow)Not deploying from local clone.(ansi reset)" + } +} diff --git a/.github/workflows/bump-n-release.yml b/.github/workflows/bump-n-release.yml index 134c6637..744aaea9 100644 --- a/.github/workflows/bump-n-release.yml +++ b/.github/workflows/bump-n-release.yml @@ -11,6 +11,16 @@ on: - "main" workflow_dispatch: inputs: + package: + description: The package to release + type: choice + required: true + default: cpp-linter + options: + - cpp-linter + - cpp-linter-js + - cpp-linter-py + - clang-installer component: description: The version component to increase type: choice @@ -37,46 +47,80 @@ jobs: fetch-tags: true persist-credentials: true # needed for `git push` - name: Set up Python + if: inputs.package == 'cpp-linter-py' uses: actions/setup-python@v6 with: python-version: 3.x - name: Install Node.js + if: inputs.package == 'cpp-linter-js' uses: actions/setup-node@v6 with: node-version: 24.x - run: yarn install + if: inputs.package == 'cpp-linter-js' - uses: cargo-bins/cargo-binstall@f8ce4d55b131f4a1e373b8747ca6b6a54133ae5a # v1.18.0 - run: cargo binstall -y git-cliff env: GITHUB_TOKEN: ${{ github.token }} + - name: Install nushell + uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 - name: Bump ${{ inputs.component }} version env: GITHUB_TOKEN: ${{ secrets.BUMP_N_RELEASE }} GH_TOKEN: ${{ secrets.BUMP_N_RELEASE }} - run: python .github/workflows/bump_version.py ${{ inputs.component }} + run: nu .github/workflows/bump-n-release.nu ${{ inputs.package }} ${{ inputs.component }} id: tagged + get-changed-pkgs: + if: github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + outputs: + pkgs: ${{ steps.set-pkgs.outputs.pkgs }} + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + persist-credentials: false + - name: Install nushell + uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 + - name: Get changed packages + id: set-pkgs + shell: nu {0} + run: |- + source .github/workflows/bump-n-release.nu + let pkgs = get-changed-pkgs.nu + "pkgs=($pkgs)\n" | save --append $env.GITHUB_OUTPUT update-changelog: if: github.event_name != 'workflow_dispatch' + needs: get-changed-pkgs permissions: contents: read pull-requests: read runs-on: ubuntu-latest + strategy: + matrix: + pkg: ${{ fromJSON(needs.get-changed-pkgs.outputs.pkgs) }} steps: - uses: actions/checkout@v6 with: fetch-depth: 0 fetch-tags: true persist-credentials: false - - uses: actions/setup-python@v6 - with: - python-version: 3.x + - uses: cargo-bins/cargo-binstall@f8ce4d55b131f4a1e373b8747ca6b6a54133ae5a # v1.18.0 + - run: cargo binstall -y git-cliff + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Install nushell + uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 - name: Generate a release notes env: + PKG: ${{ matrix.pkg }} GITHUB_TOKEN: ${{ github.token }} GITHUB_REPO: ${{ github.repository }} GIT_CLIFF_CONFIG: .config/cliff.toml - run: >- - pipx run git-cliff - --unreleased - --output "$GITHUB_STEP_SUMMARY" + shell: nu {0} + run: |- + source .github/workflows/bump-n-release.nu + gen-changes $env.PKG --unreleased + let out = open --raw .config/ReleaseNotes.md + $"## ($env.PKG)\n\n($out)" | save --append $env.GITHUB_STEP_SUMMARY diff --git a/.github/workflows/bump_version.py b/.github/workflows/bump_version.py deleted file mode 100644 index 651afb84..00000000 --- a/.github/workflows/bump_version.py +++ /dev/null @@ -1,164 +0,0 @@ -"""This script automates the release process for all of the packages in this repository. -In order, this script does the following: - -1. Bump version number in manifest files according to given required arg (see `--help`). - This alters the Cargo.toml in repo root and the package.json files in node-binding. - - Requires `yarn` (see https://yarnpkg.com) and `napi` (see https://napi.rs) to be - installed to bump node-binding versions. - -2. Updates the CHANGELOG.md - - Requires `git-cliff` (see https://git-cliff.org) to be installed - to regenerate the change logs from git history. - - NOTE: `git cliff` uses GITHUB_TOKEN env var to access GitHub's REST API for - fetching certain data (like PR labels and commit author's username). - -3. Pushes the changes from above 2 steps to remote - -4. Creates a GitHub Release and uses the section from the CHANGELOG about the new tag - as a release description. - - Requires `gh-cli` (see https://cli.github.com) to be installed to create the release - and push the tag. - - NOTE: This step also tags the commit from step 3. - When a tag is pushed to the remote, the CI builds are triggered and - - - release assets are uploaded to the Github Release corresponding to the new tag - - packages are published for npm, pip, and cargo - - NOTE: In a CI run, the GH_TOKEN env var to authenticate access. - Locally, you can use `gh login` to interactively authenticate the user account. -""" - -import argparse -from pathlib import Path -from os import environ -import subprocess -import re - -VER_PATTERN = re.compile( - r'^version = "(\d+)\.(\d+)\.(\d+)(?:\-rc)?(\d*)[^"]*" # auto', re.MULTILINE -) -VER_REPLACE = 'version = "%d.%d.%d%s" # auto' -COMPONENTS = ("major", "minor", "patch", "rc") -VERSION_LOG = re.compile(r"^## \[\d+\.\d+\.\d+(?:\-rc)?\d*\]") - - -class Updater: - component: str = "patch" - new_version: str = "0.0.0" - - @staticmethod - def replace(match: re.Match[str]) -> str: - ver = [] - for v in match.groups(): - try: - ver.append(int(v)) - except ValueError: - ver.append(0) - old_version = ".".join([str(x) for x in ver[:3]]) - rc_str = "" - if ver[3] > 0: - rc_str = f"-rc{ver[3]}" - old_version += rc_str - print("old version:", old_version) - index = COMPONENTS.index(Updater.component) - ver[index] += 1 - for i in range(index + 1, len(COMPONENTS)): - ver[i] = 0 - new_version = ".".join([str(x) for x in ver[:3]]) - rc_str = f"-rc{ver[3]}" if ver[3] > 0 else "" - new_version += rc_str - print("new version:", new_version) - Updater.new_version = new_version - return VER_REPLACE % (tuple(ver[:3]) + (rc_str,)) - - -def get_release_notes(tag: str = Updater.new_version): - title, buf = "", "" - log_file = Path(__file__).parent.parent.parent / "CHANGELOG.md" - tag_pattern = f"[{tag}]" - with open(str(log_file), "r", encoding="utf-8") as logs: - found_notes = False - for line in logs: - matched = VERSION_LOG.match(line) - if matched is not None: - if tag_pattern in matched.group(0): - title = tag + line[matched.end() :] - found_notes = True - else: - found_notes = False - elif found_notes: - buf += line - return title.rstrip(), buf.strip() - - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("component", default="patch", choices=COMPONENTS) - parser.parse_args(namespace=Updater) - - cargo_path = Path("Cargo.toml") - doc = cargo_path.read_text(encoding="utf-8") - doc = VER_PATTERN.sub(Updater.replace, doc) - cargo_path.write_text(doc, encoding="utf-8", newline="\n") - subprocess.run(["cargo", "update", "--workspace"], check=True) - print("Updated version in Cargo.toml") - subprocess.run( - [ - "yarn", - "version", - Updater.new_version, - ], - cwd="bindings/node", - check=True, - ) - print("Updated version in bindings/node/package.json") - - subprocess.run( - [ - "git-cliff", - "--config", - ".config/cliff.toml", - "--tag", - f"v{Updater.new_version}", - "--output", - "CHANGELOG.md", - ], - check=True, - ) - print("Updated CHANGELOG.md") - - if environ.get("CI", "false") == "true": - # configure git credentials on CI runner - # NOTE: this is design to fail locally with `KeyError` - git_config = {"name": environ["GITHUB_ACTOR"]} - git_config["email"] = ( - f"{environ['GITHUB_ACTOR_ID']}+{git_config['name']}@users.noreply.github.com" - ) - for key, value in git_config.items(): - subprocess.run( - ["git", "config", "--global", f"user.{key}", value], check=True - ) - subprocess.run(["git", "add", "--all"], check=True) - tag = "v" + Updater.new_version - subprocess.run(["git", "commit", "-m", f"Bump version to {tag}"], check=True) - subprocess.run(["git", "push"], check=True) - print("Pushed commit to 'Bump version to", tag, "'") - - title, notes = get_release_notes() - gh_cmd = ["gh", "release", "create", tag, "--title", title, "--notes", notes] - if Updater.component == "rc": - gh_cmd.append("--prerelease") - try: - subprocess.run(gh_cmd, check=True) - print("Created tag", tag, "and corresponding GitHub Release") - except subprocess.CalledProcessError as exc: - raise RuntimeError("Failed to create GitHub Release") from exc - - -if __name__ == "__main__": - main() diff --git a/.github/workflows/node-js-packaging.yml b/.github/workflows/node-js-packaging.yml index 7877f17d..8139c604 100644 --- a/.github/workflows/node-js-packaging.yml +++ b/.github/workflows/node-js-packaging.yml @@ -13,7 +13,7 @@ on: - yarn.lock - .github/workflows/node-js-packaging.yml tags: - - '*' + - 'cpp-linter-js/v*' pull_request: branches: [main] paths: @@ -340,6 +340,6 @@ jobs: working-directory: bindings/node shell: bash - name: Publish - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/cpp-linter-js/v') working-directory: bindings/node run: npm publish ${{ contains(github.ref_name, '-rc') && '--tag next' || '' }} diff --git a/.github/workflows/pre-commit-hooks.yml b/.github/workflows/pre-commit-hooks.yml index c1c04f26..7a5ba06a 100644 --- a/.github/workflows/pre-commit-hooks.yml +++ b/.github/workflows/pre-commit-hooks.yml @@ -32,7 +32,7 @@ jobs: path: ~/.cargo key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} - name: cargo clippy - run: cargo clippy -- -D warnings + run: cargo clippy --all-features --all-targets -- -D warnings - name: cargo fmt run: cargo fmt --check diff --git a/.github/workflows/python-packaging.yml b/.github/workflows/python-packaging.yml index 65d8be14..5b259280 100644 --- a/.github/workflows/python-packaging.yml +++ b/.github/workflows/python-packaging.yml @@ -17,16 +17,20 @@ on: branches: [main] paths: - cpp-linter/**.{rs,toml} + - clang-installer/src/** + - clang-installer/Cargo.toml - bindings/python/** - Cargo.{toml,lock} - .github/workflows/python-packaging.yml - pyproject.toml tags: - - '*' + - 'cpp-linter-py/v*' pull_request: branches: [main] paths: - cpp-linter/**.{rs,toml} + - clang-installer/src/** + - clang-installer/Cargo.toml - bindings/python/** - Cargo.{toml,lock} - .github/workflows/python-packaging.yml @@ -195,15 +199,15 @@ jobs: path: dist merge-multiple: true - name: Setup Python - if: ${{ !startsWith(github.ref, 'refs/tags/') }} + if: ${{ !startsWith(github.ref, 'refs/tags/cpp-linter-py/v') }} uses: actions/setup-python@v6 with: python-version: 3.x - name: Check distributions - if: ${{ !startsWith(github.ref, 'refs/tags/') }} + if: ${{ !startsWith(github.ref, 'refs/tags/cpp-linter-py/v') }} run: pipx run twine check dist/* - name: Publish to PyPI - if: startsWith(github.ref, 'refs/tags/') + if: startsWith(github.ref, 'refs/tags/cpp-linter-py/v') uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0 with: skip-existing: true diff --git a/.gitignore b/.gitignore index 4c683a41..72e973fc 100644 --- a/.gitignore +++ b/.gitignore @@ -346,3 +346,4 @@ docs/site cpp-linter-py/docs/cli_args.rst lcov.info coverage.json +.config/ReleaseNotes.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 779e636b..23539d3c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,8 @@ This project requires the following tools installed: - :simple-rust: [rust](https://rustup.rs/) - :simple-uv: [`uv` (Python Project management tool)](https://docs.astral.sh/uv/) -- :simple-nushell: [nushell](https://www.nushell.sh/) (for running tasks via `nur`) +- :simple-nushell: [nur] for running tasks via [nushell](https://www.nushell.sh/) +- :simple-yarn: [`yarn` (Node.js package management tool)](https://yarnpkg.com/) ## Getting started @@ -27,13 +28,22 @@ for more detailed usage. > uv run pre-commit install > ``` +You can quickly run pre-commit hooks using our [nur] task as well: + +```sh +nur pre-commit +``` + +See `nur pre-commit -h` for more detail. + ## Running tests First ensure that the following cargo-managed binaries are installed: - [`cargo-llvm-cov`](https://github.com/taiki-e/cargo-llvm-cov) - [`cargo-nextest`](https://nexte.st/docs/installation/pre-built-binaries/) -Use `nur` to run tests: + +Use [nur] to run tests: ```sh nur test @@ -52,7 +62,8 @@ To generate a coverage report: nur test llvm-cov --open ``` -The `--open` flag is optional. It opens the built coverage report in your default browser. +The `--open` flag is optional. It opens the built coverage report in your +default browser. The uploaded codecov report is generated with @@ -62,7 +73,7 @@ nur test lcov ## Generating docs -To view the docs locally, use +To view the docs locally, use our [nur] task: ```sh nur docs --open @@ -75,3 +86,5 @@ In CI, docs are built using ```sh nur docs --build ``` + +[nur]: https://nur-taskrunner.github.io/docs/ diff --git a/Cargo.lock b/Cargo.lock index 46a4685e..88d213a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,7 +284,7 @@ checksum = "3a822ea5bc7590f9d40f1ba12c0dc3c2760f3482c6984db1573ad11031420831" [[package]] name = "cli-gen" -version = "2.0.0-rc15" +version = "0.1.0" dependencies = [ "clap", "cpp-linter", diff --git a/Cargo.toml b/Cargo.toml index 7ce3fa6e..c5de9c41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,6 @@ members = ["cpp-linter", "bindings/python", "bindings/node", "docs", "clang-inst resolver = "2" [workspace.package] -version = "2.0.0-rc15" # auto authors = [ "Brendan Doherty", "Xianpeng Shen", diff --git a/bindings/node/CHANGELOG.md b/bindings/node/CHANGELOG.md new file mode 100644 index 00000000..68c31995 --- /dev/null +++ b/bindings/node/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + diff --git a/bindings/node/Cargo.toml b/bindings/node/Cargo.toml index 1349c322..71ff9edc 100644 --- a/bindings/node/Cargo.toml +++ b/bindings/node/Cargo.toml @@ -4,7 +4,7 @@ readme = "README.md" keywords = ["clang-tidy", "clang-format", "linter"] categories = ["command-line-utilities", "development-tools", "filesystem"] repository = "https://github.com/cpp-linter/cpp-linter-rs" -version.workspace = true +version = "2.0.0-rc15" edition.workspace = true authors.workspace = true description.workspace = true diff --git a/bindings/python/CHANGELOG.md b/bindings/python/CHANGELOG.md new file mode 100644 index 00000000..68c31995 --- /dev/null +++ b/bindings/python/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index da377946..75458e5b 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -2,7 +2,7 @@ name = "cpp-linter-py" readme = "README.md" repository = "https://github.com/cpp-linter/cpp-linter-rs/tree/main/bindings/python" -version.workspace = true +version = "2.0.0-rc15" edition.workspace = true authors.workspace = true description.workspace = true diff --git a/clang-installer/CHANGELOG.md b/clang-installer/CHANGELOG.md new file mode 100644 index 00000000..68c31995 --- /dev/null +++ b/clang-installer/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + diff --git a/clang-installer/Cargo.toml b/clang-installer/Cargo.toml index e197304b..e01f3fe7 100644 --- a/clang-installer/Cargo.toml +++ b/clang-installer/Cargo.toml @@ -50,3 +50,6 @@ clap = ["dep:clap"] tokio = ["dep:tokio"] anyhow = ["dep:anyhow"] colored = ["dep:colored"] + +[package.metadata.binstall] +pkg-url = "{ repo }/releases/download/{ name }/v{ version }/{ bin }-{ target }{ archive-suffix }" diff --git a/clang-installer/README.md b/clang-installer/README.md index d0aae38d..1b8487b1 100644 --- a/clang-installer/README.md +++ b/clang-installer/README.md @@ -5,7 +5,7 @@ A Rust crate to ensure clang-format and/or clang-tidy are installed. This is a utility for cpp-linter CLI, thus its API is considered internal to cpp-linter crate. -To run the binary for this crate: +To run the binary for this crate (from git source): ```text cargo run --bin clang-tools --features bin -- --help diff --git a/clang-installer/src/downloader/mod.rs b/clang-installer/src/downloader/mod.rs index a825b127..9427373f 100644 --- a/clang-installer/src/downloader/mod.rs +++ b/clang-installer/src/downloader/mod.rs @@ -145,7 +145,7 @@ mod tests { .create(); let tmp_file = NamedTempFile::new().unwrap(); let err = download(&url, tmp_file.path(), 1).await.unwrap_err(); - println!("{}", err.to_string()); + println!("{}", err); assert!(matches!(err, DownloadError::RequestError(_))); mock.assert(); log::logger().flush(); @@ -168,7 +168,7 @@ mod tests { .create(); let tmp_file = NamedTempFile::new().unwrap(); let err = download(&url, tmp_file.path(), 1).await.unwrap_err(); - println!("{}", err.to_string()); + println!("{}", err); assert!(matches!(err, DownloadError::RequestError(_))); mock.assert(); } diff --git a/clang-installer/src/downloader/pypi.rs b/clang-installer/src/downloader/pypi.rs index 1ad5993f..bcc222f3 100644 --- a/clang-installer/src/downloader/pypi.rs +++ b/clang-installer/src/downloader/pypi.rs @@ -603,7 +603,7 @@ mod test { } "#; let result = serde_json::from_str::(json).unwrap_err(); - println!("{}", result.to_string()); + println!("{}", result); } #[test] @@ -614,14 +614,14 @@ mod test { let bad_tag = "manylinux1-x86-64"; let err = PlatformTag::from_str(bad_tag).unwrap_err(); - println!("{}", err.to_string()); + println!("{}", err); } #[test] fn unknown_platform_tag() { let bad_tag = "unknown_platform"; let err = PlatformTag::from_str(bad_tag).unwrap_err(); - println!("{}", err.to_string()); + println!("{}", err); } #[test] @@ -629,6 +629,6 @@ mod test { // should have at least 5 hyphenated segments. let bad_wheel_name = "clang_format-17.0.0-py3-none_manylinux_2_17_x86_64.whl"; let err = WheelTags::from_str(bad_wheel_name).unwrap_err(); - println!("{}", err.to_string()); + println!("{}", err); } } diff --git a/clang-installer/src/tool.rs b/clang-installer/src/tool.rs index fdf4ffb0..ae93df06 100644 --- a/clang-installer/src/tool.rs +++ b/clang-installer/src/tool.rs @@ -234,7 +234,7 @@ mod tests { #[test] fn get_exe_by_path() { - static TOOL_NAME: &'static str = CLANG_FORMAT.as_str(); + static TOOL_NAME: &str = CLANG_FORMAT.as_str(); let clang_version = which(TOOL_NAME).unwrap(); let bin_path = clang_version.parent().unwrap().to_str().unwrap(); println!("binary exe path: {bin_path}"); diff --git a/cpp-linter/CHANGELOG.md b/cpp-linter/CHANGELOG.md new file mode 100644 index 00000000..68c31995 --- /dev/null +++ b/cpp-linter/CHANGELOG.md @@ -0,0 +1,9 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + + diff --git a/CHANGELOG.md b/cpp-linter/CHANGELOG.old.md similarity index 100% rename from CHANGELOG.md rename to cpp-linter/CHANGELOG.old.md diff --git a/cpp-linter/Cargo.toml b/cpp-linter/Cargo.toml index 77bdf5e7..d684b287 100644 --- a/cpp-linter/Cargo.toml +++ b/cpp-linter/Cargo.toml @@ -3,8 +3,8 @@ name = "cpp-linter" readme = "README.md" keywords = ["clang-tidy", "clang-format", "linter", "cpp-linter"] categories = ["command-line-utilities", "development-tools", "filesystem"] +version = "2.0.0-rc15" repository.workspace = true -version.workspace = true edition.workspace = true authors.workspace = true description.workspace = true @@ -50,3 +50,6 @@ path = "src/main.rs" test = false bench = false required-features = ["bin"] + +[package.metadata.binstall] +pkg-url = "{ repo }/releases/download/{ name }/v{ version }/{ bin }-{ target }{ archive-suffix }" diff --git a/cpp-linter/clippy.toml b/cpp-linter/clippy.toml deleted file mode 100644 index 154626ef..00000000 --- a/cpp-linter/clippy.toml +++ /dev/null @@ -1 +0,0 @@ -allow-unwrap-in-tests = true diff --git a/cpp-linter/src/clang_tools/clang_format.rs b/cpp-linter/src/clang_tools/clang_format.rs index 5031bcbd..c4bb2c99 100644 --- a/cpp-linter/src/clang_tools/clang_format.rs +++ b/cpp-linter/src/clang_tools/clang_format.rs @@ -186,6 +186,8 @@ pub fn run_clang_format( #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + use super::{FormatAdvice, Replacement, summarize_style}; #[test] diff --git a/cpp-linter/src/clang_tools/clang_tidy.rs b/cpp-linter/src/clang_tools/clang_tidy.rs index e733042e..a45abad8 100644 --- a/cpp-linter/src/clang_tools/clang_tidy.rs +++ b/cpp-linter/src/clang_tools/clang_tidy.rs @@ -369,6 +369,8 @@ pub fn run_clang_tidy( #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + use std::{ env, path::PathBuf, diff --git a/cpp-linter/src/cli/mod.rs b/cpp-linter/src/cli/mod.rs index 6437c845..6a7d586c 100644 --- a/cpp-linter/src/cli/mod.rs +++ b/cpp-linter/src/cli/mod.rs @@ -547,6 +547,8 @@ pub fn convert_extra_arg_val(args: &[String]) -> Vec { #[cfg(all(test, feature = "bin"))] mod test { + #![allow(clippy::unwrap_used)] + use super::{Cli, convert_extra_arg_val}; use clap::Parser; diff --git a/cpp-linter/src/cli/structs.rs b/cpp-linter/src/cli/structs.rs index aa173d26..115a1c59 100644 --- a/cpp-linter/src/cli/structs.rs +++ b/cpp-linter/src/cli/structs.rs @@ -245,6 +245,8 @@ impl Default for FeedbackInput { #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + #[cfg(feature = "bin")] use clap::{Parser, ValueEnum}; @@ -264,13 +266,13 @@ mod test { fn display_lines_changed_only_enum() { let input = "Diff"; assert_eq!( - LinesChangedOnly::from_str(&input, true).unwrap(), + LinesChangedOnly::from_str(input, true).unwrap(), LinesChangedOnly::Diff ); assert_eq!(format!("{}", LinesChangedOnly::Diff), input.to_lowercase()); assert_eq!( - LinesChangedOnly::from_str(&input, false).unwrap(), + LinesChangedOnly::from_str(input, false).unwrap(), LinesChangedOnly::Off ); } diff --git a/cpp-linter/src/run.rs b/cpp-linter/src/run.rs index f9ff317e..6229acd5 100644 --- a/cpp-linter/src/run.rs +++ b/cpp-linter/src/run.rs @@ -169,6 +169,8 @@ pub async fn run_main(args: Vec) -> Result<()> { #[cfg(test)] mod test { + #![allow(clippy::unwrap_used)] + use super::run_main; use std::env; diff --git a/cspell.config.yml b/cspell.config.yml index faa23912..76ac65fa 100644 --- a/cspell.config.yml +++ b/cspell.config.yml @@ -123,6 +123,7 @@ words: - Werror - winget - Xianpeng + - yarnrc - zigbuild - zizmor ignorePaths: @@ -140,3 +141,4 @@ ignorePaths: - .yarn/releases/* - "*.lock" - bindings/node/index.js + - "**/*/CHANGELOG*.md" diff --git a/docs/Cargo.toml b/docs/Cargo.toml index 47e153c2..39d69bac 100644 --- a/docs/Cargo.toml +++ b/docs/Cargo.toml @@ -4,7 +4,7 @@ name = "cli-gen" edition = "2021" description = "A function exposed in python that generates a CLI doc from rust source code." repository = "https://github.com/cpp-linter/cpp-linter-rs/tree/main/docs" -version.workspace = true +version = "0.1.0" authors.workspace = true license.workspace = true diff --git a/docs/docs/changelog.md b/docs/docs/changelog.md deleted file mode 100644 index 633db5d6..00000000 --- a/docs/docs/changelog.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Changes ---- - - -{% - include "../../CHANGELOG.md" -%} diff --git a/docs/docs/changelog/clang-installer.md b/docs/docs/changelog/clang-installer.md new file mode 100644 index 00000000..2f746d9b --- /dev/null +++ b/docs/docs/changelog/clang-installer.md @@ -0,0 +1,8 @@ +--- +title: Changes in clang-installer +--- + + +{% + include "../../../clang-installer/CHANGELOG.md" +%} diff --git a/docs/docs/changelog/cpp-linter-js.md b/docs/docs/changelog/cpp-linter-js.md new file mode 100644 index 00000000..455bf642 --- /dev/null +++ b/docs/docs/changelog/cpp-linter-js.md @@ -0,0 +1,8 @@ +--- +title: Changes in Node.js binding +--- + + +{% + include "../../../bindings/node/CHANGELOG.md" +%} diff --git a/docs/docs/changelog/cpp-linter-py.md b/docs/docs/changelog/cpp-linter-py.md new file mode 100644 index 00000000..87778c66 --- /dev/null +++ b/docs/docs/changelog/cpp-linter-py.md @@ -0,0 +1,8 @@ +--- +title: Changes in Python Binding +--- + + +{% + include "../../../bindings/python/CHANGELOG.md" +%} diff --git a/docs/docs/changelog/cpp-linter.md b/docs/docs/changelog/cpp-linter.md new file mode 100644 index 00000000..46bd3adc --- /dev/null +++ b/docs/docs/changelog/cpp-linter.md @@ -0,0 +1,8 @@ +--- +title: Changes in cpp-linter +--- + + +{% + include "../../../cpp-linter/CHANGELOG.md" +%} diff --git a/docs/license_gen.py b/docs/license_gen.py index ab889c47..cbb3e87e 100644 --- a/docs/license_gen.py +++ b/docs/license_gen.py @@ -13,6 +13,16 @@ TABLE_HEADER = "| Dependency | License |\n|:------------|:-------|\n" +CPP_LINTER_DEPS = f"""## cpp-linter's dependencies + +{TABLE_HEADER}\ +""" + +CLANG_INSTALLER_DEPS = f"""## clang-installer's dependencies + +{TABLE_HEADER}\ +""" + OPTIONAL_DEPS = f"""## Optional dependencies The following are conditionally included in binaries (using the `openssl-vendored` @@ -82,7 +92,7 @@ def get_output(self) -> str: with mkdocs_gen_files.open(FILENAME, "w") as io_doc: tg = TreeGetter() print(INTRO, file=io_doc) - doc = TABLE_HEADER + doc = CPP_LINTER_DEPS doc += tg.get_output() # print(doc) print(doc, file=io_doc) @@ -93,5 +103,8 @@ def get_output(self) -> str: tg.package("cpp-linter-js") doc = tg.get_output() print(f"\n{JS_BINDING_HEADER}{doc}", file=io_doc) + tg.package("clang-installer") + doc = tg.get_output() + print(f"\n{CLANG_INSTALLER_DEPS}{doc}", file=io_doc) mkdocs_gen_files.set_edit_path(FILENAME, "license-gen.py") diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index e6a92c7a..a2f0e36f 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -11,7 +11,11 @@ nav: - permissions.md - python.md - node.md - - changelog.md + - Changes: + - changelog/cpp-linter.md + - changelog/cpp-linter-py.md + - changelog/cpp-linter-js.md + - changelog/clang-installer.md - contributing.md - other-licenses.md diff --git a/nurfile b/nurfile index a63455f4..d818d962 100644 --- a/nurfile +++ b/nurfile @@ -1,43 +1,4 @@ - -# A helper function to display the command being executed. -# -# This also prints the elapsed time the command took to execute. -export def --wrapped run-cmd [...cmd: string] { - let app = if ( - ($cmd | first) == "cargo" - or ($cmd | first) == "yarn" - ) { - ($cmd | first 2) | str join ' ' - } else if (($cmd | first) == "uv") { - mut sub_cmd = $cmd.1 - if ($sub_cmd == "run") { - mut index = 2 - mut skip_val = false - for arg in ($cmd | skip 2) { - if ($arg | str starts-with "-") { - $skip_val = true - } else if $skip_val { - $skip_val = false - } else { - break - } - $index = $index + 1 - } - if (($cmd | get $index) == "cargo") { - $sub_cmd = $cmd | skip $index | first 2 | str join ' ' - } - $sub_cmd - } else { - ($cmd | first 2) | str join ' ' - } - } else { - ($cmd | first) - } - print $"(ansi blue)\nRunning(ansi reset) ($cmd | str join ' ')" - let elapsed = timeit {|| ^($cmd | first) ...($cmd | skip 1)} - print $"(ansi magenta)($app) took ($elapsed)(ansi reset)" -} - +use .github/common.nu run-cmd # Build rust API docs def "nur docs rs" [ @@ -165,7 +126,7 @@ export def "nur test lcov" [] { export def "nur lint" [ --check (-c), # Only check, do not fix ] { - mut clippy = [cargo clippy --features bin] + mut clippy = [cargo clippy --all-features --all-targets] if $check { $clippy = $clippy | append [-- -D warnings] } else { From 9499b697dba6591817abafa604820fab4178293e Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Wed, 15 Apr 2026 23:21:28 -0700 Subject: [PATCH 2/2] various CI fixes --- .github/workflows/binary-builds.yml | 24 ++++++++++++++++-------- .github/workflows/bump-n-release.yml | 16 +++++++++------- benchmark/benchmark.nu | 2 +- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.github/workflows/binary-builds.yml b/.github/workflows/binary-builds.yml index a513dada..cd00db17 100644 --- a/.github/workflows/binary-builds.yml +++ b/.github/workflows/binary-builds.yml @@ -142,13 +142,17 @@ jobs: if: runner.os != 'Windows' shell: bash run: |- + mkdir dist + cp LICENSE dist/LICENSE + cd dist + tgt="cpp-linter" - mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}" + mv "../target/${{ matrix.target }}/release/${tgt}" "./${tgt}" arc_name="${tgt}-${{ matrix.target }}.tar.gz" tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE tgt="clang-tools" - mv "target/${{ matrix.target }}/release/${tgt}" "${tgt}" + mv "../target/${{ matrix.target }}/release/${tgt}" "./${tgt}" arc_name="${tgt}-${{ matrix.target }}.tar.gz" tar -a -c -v -z -f "${arc_name}" ${tgt} LICENSE - name: Prepare artifacts (windows) @@ -157,26 +161,30 @@ jobs: # `tar.exe` in powershell is different from `tar` in bash. # need to use `tar.exe` in powershell to create a valid zip file. run: |- + mkdir dist + Copy-Item ./LICENSE ./dist/LICENSE + cd dist + $tgt = "cpp-linter" - mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe" + mv "../target/${{ matrix.target }}/release/${tgt}.exe" "./${tgt}.exe" $arc_name = "${tgt}-${{ matrix.target }}.zip" - tar -a -c -v -f "${arc_name}" ${tgt} LICENSE + tar -a -c -v -f "${arc_name}" ${tgt}.exe LICENSE $tgt = "clang-tools" - mv "target/${{ matrix.target }}/release/${tgt}.exe" "${tgt}.exe" + mv "../target/${{ matrix.target }}/release/${tgt}.exe" "./${tgt}.exe" $arc_name = "${tgt}-${{ matrix.target }}.zip" - tar -a -c -v -f "${arc_name}" ${tgt} LICENSE + tar -a -c -v -f "${arc_name}" ${tgt}.exe LICENSE - name: Upload cpp-linter artifacts uses: actions/upload-artifact@v7 with: name: cpp-linter-${{ matrix.target }} - path: cpp-linter-${{ matrix.target }}* + path: dist/cpp-linter-${{ matrix.target }}* if-no-files-found: error - name: Upload clang-tools artifacts uses: actions/upload-artifact@v7 with: name: clang-tools-${{ matrix.target }} - path: clang-tools-${{ matrix.target }}* + path: dist/clang-tools-${{ matrix.target }}* if-no-files-found: error publish: diff --git a/.github/workflows/bump-n-release.yml b/.github/workflows/bump-n-release.yml index 744aaea9..463b661a 100644 --- a/.github/workflows/bump-n-release.yml +++ b/.github/workflows/bump-n-release.yml @@ -75,7 +75,7 @@ jobs: if: github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/') runs-on: ubuntu-latest outputs: - pkgs: ${{ steps.set-pkgs.outputs.pkgs }} + pkgs: ${{ steps.get-pkgs.outputs.pkgs }} steps: - uses: actions/checkout@v6 with: @@ -84,15 +84,17 @@ jobs: - name: Install nushell uses: hustcer/setup-nu@92c296ba1ba2ba04cc948ab64ddefe192dc13f0c # v3.23 - name: Get changed packages - id: set-pkgs + id: get-pkgs shell: nu {0} run: |- - source .github/workflows/bump-n-release.nu - let pkgs = get-changed-pkgs.nu - "pkgs=($pkgs)\n" | save --append $env.GITHUB_OUTPUT + print (pwd) + use ("./.github/workflows/bump-n-release.nu" | path expand) get-changed-pkgs + let pkgs = (get-changed-pkgs) + $"pkgs=($pkgs)\n" | save --append $env.GITHUB_OUTPUT + update-changelog: if: github.event_name != 'workflow_dispatch' - needs: get-changed-pkgs + needs: [get-changed-pkgs] permissions: contents: read pull-requests: read @@ -120,7 +122,7 @@ jobs: GIT_CLIFF_CONFIG: .config/cliff.toml shell: nu {0} run: |- - source .github/workflows/bump-n-release.nu + use ("./.github/workflows/bump-n-release.nu" | path expand) gen-changes gen-changes $env.PKG --unreleased let out = open --raw .config/ReleaseNotes.md $"## ($env.PKG)\n\n($out)" | save --append $env.GITHUB_STEP_SUMMARY diff --git a/benchmark/benchmark.nu b/benchmark/benchmark.nu index 4ea57f26..9427d076 100644 --- a/benchmark/benchmark.nu +++ b/benchmark/benchmark.nu @@ -9,7 +9,7 @@ # nu benchmark/benchmark.nu # To use this script in CI, see .github/workflows/benchmark.yml. -use "../nurfile" run-cmd +use "../.github/common.nu" run-cmd # Build release version of cpp-linter (rust) binary #