diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c19aba0..bf7373a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,29 +16,21 @@ on: - '.github/dependabot.yml' workflow_dispatch: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: plugin_test: - name: asdf plugin test + name: asdf plugin test (${{ matrix.os }}) runs-on: ${{ matrix.os }} + defaults: + run: + shell: bash strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, macos-15-intel] - tool: - - plugin: clang-format - command: clang-format --version - - plugin: clang-query - command: clang-query --version - - plugin: clang-tidy - command: clang-tidy --version - - plugin: clang-apply-replacements - command: clang-apply-replacements --version - version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22"] - exclude: - # clang-apply-replacements-12_linux-amd64 is missing from upstream static-binaries - - os: ubuntu-latest - tool: { plugin: clang-apply-replacements, command: "clang-apply-replacements --version" } - version: "12" + os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, macos-15-intel] steps: - uses: actions/checkout@v6 @@ -46,16 +38,39 @@ jobs: - name: Install asdf uses: asdf-vm/actions/setup@v4 - - name: Add plugin ${{ matrix.tool.plugin }} + - name: Install and test all clang tools run: | - asdf plugin add ${{ matrix.tool.plugin }} "$GITHUB_WORKSPACE" + tools=("clang-format" "clang-query" "clang-tidy" "clang-apply-replacements" "clang-include-cleaner") + cmds=("clang-format --version" "clang-query --version" "clang-tidy --version" "clang-apply-replacements --version" "clang-include-cleaner --version") + versions=("11" "14" "18" "22") + count=${#tools[@]} - - name: Install and test ${{ matrix.tool.plugin }} ${{ matrix.version }} on ${{ matrix.os }} - run: | - asdf install ${{ matrix.tool.plugin }} ${{ matrix.version }} - asdf set ${{ matrix.tool.plugin }} ${{ matrix.version }} - which ${{ matrix.tool.plugin }} - ${{ matrix.tool.command }} + i=0 + while [ "$i" -lt "$count" ]; do + plugin="${tools[$i]}" + cmd="${cmds[$i]}" + + asdf plugin add "$plugin" "$GITHUB_WORKSPACE" 2>/dev/null || true + + for version in "${versions[@]}"; do + # clang-include-cleaner is only available from version 18+ + if [ "$plugin" = "clang-include-cleaner" ] && [ "$version" -lt 18 ] 2>/dev/null; then + continue + fi + + echo "" + echo "========================================" + echo "Testing $plugin $version on ${{ matrix.os }}" + echo "========================================" + + asdf install "$plugin" "$version" + asdf set "$plugin" "$version" + which "$plugin" + $cmd + done + + i=$((i + 1)) + done env: ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index 4bc4fed..8f4c2a3 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ This is an asdf plugin for installing several clang tools: - clang-tidy - clang-query - clang-apply-replacements +- clang-include-cleaner (version 18+) This plugin uses the pre-compiled binaries from the very handy [cpp-linter/clang-tools-static-binaries](https://github.com/cpp-linter/clang-tools-static-binaries) repo. @@ -29,8 +30,9 @@ Clang versions **11** through **22** are supported. - Pre-compiled binaries are provided for: - Linux: `amd64` (`x86_64`), `arm64` (`aarch64`) - macOS: `amd64` (Intel), `arm64` (Apple Silicon) - - Windows: `amd64` (`x86_64`) + - Windows: `amd64` (`x86_64`), `arm64` (`aarch64`) - Signed binaries are not provided for macOS. This plugin will offer to de-quarantine the binaries for you, but please make sure you understand the consequences. +- `clang-include-cleaner` is only available from version 18 onward. # Dependencies @@ -47,6 +49,7 @@ Plugin: | clang-query | `asdf plugin add clang-query https://github.com/cpp-linter/asdf-clang-tools.git` | | clang-tidy | `asdf plugin add clang-tidy https://github.com/cpp-linter/asdf-clang-tools.git` | | clang-apply-replacements | `asdf plugin add clang-apply-replacements https://github.com/cpp-linter/asdf-clang-tools.git` | +| clang-include-cleaner | `asdf plugin add clang-include-cleaner https://github.com/cpp-linter/asdf-clang-tools.git` | Example: diff --git a/bin/help.overview b/bin/help.overview index 6355d46..d1d7eeb 100755 --- a/bin/help.overview +++ b/bin/help.overview @@ -5,5 +5,6 @@ echo "- clang-format" echo "- clang-tidy" echo "- clang-query" echo "- clang-apply-replacements" +echo "- clang-include-cleaner (version 18+)" echo "See https://github.com/cpp-linter/asdf-clang-tools for more information" echo diff --git a/lib/utils.bash b/lib/utils.bash index d8eda0c..bff323f 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -114,6 +114,17 @@ validate_platform() { esac fi ;; + MINGW* | MSYS* | CYGWIN*) + USE_KERNEL=windows + case $arch in + x86_64) + USE_ARCH=amd64 + ;; + arm64 | aarch64) + USE_ARCH=arm64 + ;; + esac + ;; esac if [ -z "${USE_KERNEL}" ] || [ -z "${USE_ARCH}" ]; then @@ -143,15 +154,22 @@ list_all_versions() { } download_release() { - local toolname version url + local toolname version url asset_pattern toolname="$1" version="$2" validate_platform + # Windows assets have an .exe extension + if [ "$USE_KERNEL" = "windows" ]; then + asset_pattern="^${toolname}-${version}_${USE_PLATFORM}.exe\s" + else + asset_pattern="^${toolname}-${version}_${USE_PLATFORM}\s" + fi + # TODO: split output without piping to awk url=$(fetch_all_assets | - grep "^${toolname}-${version}_${USE_PLATFORM}\s" | + grep "$asset_pattern" | awk '{print $2}') ( @@ -208,12 +226,21 @@ install_version() { # TODO: detect this instead of hard-coding in case the format changes? full_tool_cmd=${toolname}-${version}_${USE_PLATFORM} + # Windows assets have an .exe extension + if [ "$USE_KERNEL" = "windows" ]; then + full_tool_cmd="${full_tool_cmd}.exe" + fi tool_cmd="$(echo "$toolname" | cut -d' ' -f1)" chmod +x "${asset_path}/${full_tool_cmd}" mkdir -p "${install_path}/bin" || true - ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd" + # Use cp on Windows where symlinks may not work + if [ "$USE_KERNEL" = "windows" ]; then + cp "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd" + else + ln -s "${asset_path}/${full_tool_cmd}" "$install_path/bin/$tool_cmd" + fi if [ "$USE_KERNEL" == "macosx" ]; then if [ "$ASDF_CLANG_TOOLS_MACOS_DEQUARANTINE" != 1 ]; then